Show text field changing every time step from programmable filter

Hello everyone!
Now I’m trying to get time in YYYY-MM-DD format for animation via programmable filter ( I still haven’t figured out how to write it to new variable, but i’m working on it).

Having a variable same length as number of timesteps, can I write contents of this variable to label (changing along with timestep)?

In raw files (netcdf) time has time like this: “01.01.1948 - 01:00:00”, but now i have to change timeaxis for Paraview.

So, main question is: is it possible to make text source from variable and change it according to timestep?

Side question is, how to make a new variable out of timesteps via programmable filter?

Yes. Use the Python Annotation filter. Attach it to your data source with the field data representing time. If it is named “Time”, your Python Annotation filter should be set to Time[t_index] where t_index is the index of the current timestep selected in ParaView.

1 Like

That’s great!
Also, with this I don’t need programmable filter, just change date format as i want

Once more, thanks for an answer, and I’ve got following question:

Having time units like Hours since …, how to get date from timestep value?
It is possible via datetime Python module, but I haven’t found the way to do it with Python Annotation. Is it possible?

And some story with additional questions, that made me ask this:

After adding timeaxis to my file I have timesteps like


They are interpreted by Paraview as int, and this is source of my problem.

If i choose Animation View Mode Sequence, i get timestep values between 19820131 and 19820204, for example 19820173, which is bad.

If i choose Animation View Mode Snap To TimeSteps and set Camera to Orbit, while transfer from 19820131 19820204 it jumps a lot and animation is not smooth.

Now I’m trying to build pipeline for visualizing model files with minimum (ideally, no) preprocessing, so I’m trying to avoid file conversions. Maybe, the best solution would be just configurate a reader with all specifications that I want.

I’m afraid I don’t know what your timestep values represent, and I’m not that versed in Python date handling to offer suggestions.

I think you are saying ParaView is displaying a time value that isn’t in your dataset. It is displaying the time requested in ParaView, but the data displayed is the closest available timestep, so there is indeed a mismatch in that regard. I suppose you could round the ParaView time to the closest one in your time array with some Python function.

Hi Cory, I know it is a post long time ago, but I have the same problem right now. I want to add a notation “time” varying with time step into the render view, and now I obtain “time” as a dictionary, which looks like:

{0: '1250.0', 1: '1250.5', 2: '1251.0', 3: '1251.5', 4: '1252.0', 5: '1252.5', 6: '1253.0', 7: '1253.5', 8: '1254.0', 9: '1254.5'}

And as you suggested, I use Python Annotation filter in scripting:

pythonAnnotation1 = PythonAnnotation(Input=velocity)
pythonAnnotation1.Expression = time[t_index]
pythonAnnotation1Display = Show(pythonAnnotation1, renderView1)

But I received the error “name ‘t_index’ is not defined”. It seems that I need to get the current time step used in active view. Do you know how to do that in paraview?

Make this line

pythonAnnotation1.Expression = "time[t_index]"

instead. The expression needs to be a string. The way you have it tries to evaluate time[t_index] before setting the value of the Expression attribute, but t_index is not defined in your script.

Hi Cory,
I use t_index = animationScene1.TimeKeeper.TimestepValues to get the time step, which has a type of <class 'paraview.servermanager.VectorProperty'> , and looks like [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] (since I have 10 vtk files for 10 timesteps).

I add the quotation mark for time[t_index], and receive the error:

NameError: name 'time' is not defined

But I have define the variable time in the above in python scripting.

I guess I need to insert the variable “time” into the paraview.simple module? Cause I have the same problem when doing this in GUI. So the questions seems to be how to read variable “time” in paraview…