Issue with python plugin when loading a single time step

I am writing a python plugin in which I need to load time-dependent data. I noticed an issue when I pass a time step list of size 1. Instead of showing just a single time step, Paraview shows the list with the following values: [time, time + 1/9, time + 2/9, ... time + 9/9]

The problem is reproducible using this simple source class:

from paraview.util.vtkAlgorithm import smproperty, smproxy
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase

@smproxy.source(label="test")
class Test(VTKPythonAlgorithmBase):
    def __init__(self):
        super().__init__(nInputPorts=0, nOutputPorts=1)
        self.time_steps = [11, 12, 13, 14, 15]

    
    @smproperty.doublevector(name="TimestepValues", information_only="1", si_class="vtkSITimeStepsProperty")
    def GetTimestepValues(self):
        return self.time_steps
    
    def RequestInformation(self, request, inInfo, outInfo):
        executive = self.GetExecutive()
        outInfo = outInfo.GetInformationObject(0)

        outInfo.Remove(executive.TIME_STEPS())
        outInfo.Remove(executive.TIME_RANGE())

        outInfo.Set(executive.TIME_STEPS(), self.time_steps, len(self.time_steps))
        outInfo.Set(executive.TIME_RANGE(), [self.time_steps[0], self.time_steps[-1]], 2)
        return 1
        
    def RequestData(self, request, inInfo, outInfo):
        executive = self.GetExecutive()
        info = outInfo.GetInformationObject(0)
        time_step = info.Get(executive.UPDATE_TIME_STEP())
        print(f"Using timestep: {time_step}")
        return 1

The code above works as is, without issues and correctly displays the list, as such:
image

However, when changing the list to a single time step, e.g: self.time_steps = [11]
Instead of only showing 11, paraview shows the following list:
image

This issue seems to only occur when the list of time steps only contains a single value. When looking at the information tab in Paraview, under the “Data Statistics” header, it correctly displays “# of TimeSteps 1”. Is there a problem in my implementation or is this an issue with Paraview? Thank you!

When there is a single timestep ParaView switch to a “non-temporal” mode which create timestep to animate other things (like the camera) which comes with its own 10 timestep from Time to Time+1.

So the problem you are describing is a feature although maybe counter intuitive.

However these synthetic time steps should not cause any issue when you use ParaView, do they ?

Aha, I understand. Thanks for the quick reply :slight_smile: ! They do not cause an issue per se, however it could be confusing for the end users of the plugin. I am dealing with data that sometimes contains multiple timesteps and sometimes only a single timestep. If there is only a single timestep in the loaded dataset, but Paraview displays multiple “available” time steps, this might lead users to believe that there are in fact multiple timesteps in the data.

Is there perhaps an option to turn off the “non-temporal” mode, or get around this some how? Thanks!

If there is only a single timestep in the loaded dataset, but Paraview displays multiple “available” time steps, this might lead users to believe that there are in fact multiple timesteps in the data.

I agree

Is there perhaps an option to turn off the “non-temporal” mode, or get around this some how? Thanks!

I’m afraid this is not possible. You can reduce the number of timesteps in this mode by opening the “Time Manager” and reducing the Number of frames, but the minimum number is 2.

That being said, I think this should be improved, do not hesitate to create an issue suggesting it: https://gitlab.kitware.com/paraview/paraview/-/issues :slight_smile:

FYI @nicolas.vuaille

Created an issue here.

1 Like

A global issue about this problem is https://gitlab.kitware.com/paraview/paraview/-/issues/22360.

A “workaround” is:

  • load the single timestep data
  • open “View > Time Manager”
  • uncheck and check again the checkbox “Time Sources”
1 Like