I am prototyping a reader for a code which generates one file per time step. Using advice from here, I was able to correctly read the number of time steps to my Programmable Source and I know I can read the current time step using the helper function below:
#...
def GetUpdateTimestep(algorithm):
"""Returns the requested time value, or None if not present"""
executive = algorithm.GetExecutive()
output_info = executive.GetOutputInformation(0)
return output_info.Get(executive.UPDATE_TIME_STEP()) \
if output_info.Has(executive.UPDATE_TIME_STEP()) else None
How to obtain the time index instead of the time step value? The indices are clearly displayed in the Information tab of the object.
PS Slightly unrelated, but is it possible to also save the file list in vtkInformation or elsewhere?
This will return None in cases when the requested time step is not present! I could improve this, by making sure I select the nearest neighbour.
Perhaps my original request was impossible, because of the way VTK handles time as metadata. My current understanding is that vtkExecutive may receive requests for times that are not necessarily in the dataset it handles. Inside ParaView, this could happen, I think, where there are multiple data sources registering different time series information.