Annotate date in the viewport of the 3D visualization

Hi Paraview Member,

I have the dates for every timestep as a string in a file and I want to link this file to create an annotation where I can see the date instead of the time step. I looked at other sources where this question was already asked, but since I already have the file with the date as a string, I thought I would only need to use the python annotation filter. Unfortunately, I am getting the following error and I can’t understand why it does not recognize the column header as a variable name, even though within the error description it is recognized as so.

I am using Time[t_index] within the expression input of the pythonannotation filter

The error I get is this
Failed to evaluate expression ‘Time[t_index]’. The following exception stack should provide additional developer-specific information. This typically implies a malformed expression. Verify that the expression is valid.

Variables in current scope are [‘Hours’, ‘input’, ‘Time’, ‘Id’, ‘Date’]

Traceback (most recent call last):
File “”, line 7, in
File “”, line 5, in vtkPythonAnnotationFilter_EvaluateExpression
File “C:/Program Files/ParaView 5.6.1/bin\Lib/site-packages\paraview\annotation.py”, line 90, in execute
result = calculator.compute(inputs, expression, ns=ns)
File “C:/Program Files/ParaView 5.6.1/bin\Lib/site-packages\paraview\calculator.py”, line 140, in compute
retVal = eval(expression, globals(), mylocals)
File “”, line 1, in
NameError: name ‘t_index’ is not defined

Thank you for the attention

The correct formula is : t_value

Alternatively, you can use the Annotate Time filter.

Hi Mathieu,

Thank you for replying. Using t_value will print the time step on the screen, but I want to print the date associated to that time step. I have this date already in a string format within a .csv file that has as a column header “Time”, which is why I thought using Time[t_index] would work. But I get that error. I understand that a programmable filter has been used before, but it has been used to change the datetime format into a string format. From what I understand basically to create the file that I already have in the .csv file.

Thank you,
Sergio

Can you share your dataset ?

Sure, I have attached the csv file and shared the link for the associated vtk files.

ParaviewRef_v1.csv (58 Bytes)

https://ucdavis.box.com/s/vu7lf1rubvrqt28cip9h1z9jiziokas2

Thank you

Your problem is that your .csv file doesn’t have a time associated to it.
A simple work around is to duplicate and rename it :

ParaViewRef_v1_0.csv
ParaViewRef_v1_1.csv
ParaViewRef_v1_2.csv

You then open the file series : ParaViewRef_v1_..csv and add a PythonAnnotation with the following formula : Time.GetValue(t_index)

The correct fix is to add your time data inside the FieldData of your dataset, but that can’t be done using simple filters in ParaView.