Dear Utkarsh,

After some more googling and your answer I found the solution. Indeed I
have to store the data as a string in the Programmable Filter and then
retrieve with GetValue in the Python Annoatation.
My ProgrammableFilter with Ouput set to vtkData is now

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")

outputarray = vtk.vtkStringArray()

outputarray.SetName("datetime")

outputarray.SetNumberOfTuples(1)

outputarray.SetValue(0, "{}".format(date_time))

print("{} -> {}".format(t, date_time))

output.RowData.AddArray(outputarray)


and after that I add a PythonAnnotation with Row Data as Array
Association and the following expression


"{}".format(input.RowData["datetime"].GetValue(0))



It is not very trivial I must say, but the result is now that I can
plot a date/time string in stead of a float with number of hourse
since. Excellent! Thanks for your quick help


Regards

Eelco


Ps: for those interessed in using netcdf4 with paraview: you have to
make sure to get all the versions correct. I did this by using
Anaconda and than create a special paraview environment

conda create -n paraview python=2.7.3 netcdf4

activate paraview

conda install numpy=1.8.1




2017-06-06 17:05 GMT+02:00 Utkarsh Ayachit <utkarsh.ayac...@kitware.com>:

> 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
>>
>
> Try using `input.RowData["datatime"].GetValue(0)` instead. String arrays
> are a little cumbersome currently. You have to use the vtkAbstractArray API
> (GetValue) to access elements.
>
> Utkarsh
>
>
>
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to