[Paraview] Annotate time as data/time using pythonannotation and programmablefilter

Eelco van Vliet eelcovv at gmail.com
Tue Jun 6 10:53:28 EDT 2017


Dear all,

I have a question on how to convert a time in hours since  0001-01-01
00:00:00 to a normal date time string. In Python a routine is avaiable in
the netCDF4 library, so I thought I used that.

I want to use PythonAnnotate eventually to plot the date time. So know I
have to following steps in my pipeline browser

1: load a netcdf4 file with a Lat/Lon spherical coordinates and a time in
as a float giving the number of hourse since 0001

2 A ProgrammableFilter with the following settings

Output Data Set Type: vtkTable

Script:

import sys

sys.path.append("C://Apps/Anaconda/Anaconda2/envs/paraview/Lib/site-packages/")

import netCDF4 as nc

t = inputs[0].GetInformation().Get(vtk.vtkDataObject.DATA_TIME_STEP())

date_time = nc.num2date(t, units="hours since 0001-01-01 00:00:00",
calendar="gregorian")

output.RowData.append(date_time, "datetime")


This all works. If I create a print statement in the script I see that the
time is indeed correctly converted to a date/time string, eg. 17671944.0 is
now 2017-01-01-00:00:00

The point is: I want to store this resulting datatime value into a vtkTable
so that I can use it to plot it to the screen using the Python annotation
(which I do with the RowData.append line)

In the python annotation, however, I cannot get the value for datatime rom
the RowDATa

I now have for the pythonannotation expression the following

Array Association: Row Data
Expression: "{}".format(input.RowData)
But this gives me just a reference to the row data, not the string of the
date/time I just stored

My question is:
1) How can I get the rowdata which I stored in the ProgrammableFilter in
the vtkTable
2) Is there a better way to do this: convert a float into a date/time
string which you can print

Hopefully anybody can give me a hint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170606/968e7db5/attachment.html>


More information about the ParaView mailing list