How to access "Row Data" in Python?

Hello all,

So this is an embarrassingly simple question, but I’ve Googled a lot, and am throwing in the towel and asking for directions.

I’m writing a pvbatch script that reads a cvs/ssv file, which works fine. But when viewed in ParaView proper, the spreadsheet view calls the data “Row Data”. And for the life of me, I can’t figure out how to access “Row Data” in the Python interface. There are functions for “Cell Data” and “Point Data” and “Field Data”, but no “Row Data” (nor a couple others that the Spreadsheet offers).

So I’m loading the data as follows:

frameinfo = CSVReader(registrationName='frame-info', FileName=['.../frame-info'])
frameinfo.FieldDelimiterCharacters = ' '
frameinfo.MergeConsecutiveDelimiters = 1                                                             
frameinfo.UpdatePipeline()

But now what? I’ve used dir() and help() in the Python shell, but again they only refer to cell/point/field data.

I did try this:

>>> calc=Calculator(Input=frameinfo)
>>> calc.Function = 'Rotation(rad)'
>>> calc.ResultArrayName='rot'
>>> calc.UpdatePipeline()

And that seems to produce the data, but once again I don’t know how to access the “calc” data.

Thanks in advance,
Bill

You are looking for servermanager.Fetch(calc)

Hello Mathieu,

Yes! Using servermanager.Fetch() worked for both “calc” and the original “frameinfo”!

Thank you!

Followup: any chance you can give a one or two sentence explanation for what that does / why that’s necessary?

Thanks again!
Bill

Hi Bill,

The scripting layer you are working with accesses the ParaView layer of data management. That’s what takes care of setting up pipelines and coordinating them across client and any existing server processes. The actual data is available on the server side only by default. To access it in the scripting environment in which you are working, you need to explicitly bring over a copy onto the client side, which is what servermanager.Fetch does. Once you have copied the data over, then you can work with it.

2 Likes

Awesome, thanks for the explanation Cory!
Bill

Hello Sherman,

I still haven’t firgured out how to assess Row Data in programmable Filter, can you give one example?

Thanks again!

I also need to know this - that is, to get PV-displayed, multiblock data out of ParaView and into Python as a flat array. Have you tried the Python interface package “paraview?” One of the problems I’m having simply outputting data from ParaView is that it gives data files (CSV) listed in block format, and also doesn’t seem to output the correct number of points, even when requesting cell-center data. My simulation is 48 x 126 = 6,048 cells, but ParaView always puts out 12,283 data points, even when requesting cell center data - so that’s confusing.

Has anyone tried the Python package “paraview?” Does it work for extracting data? I think this package can also access data slices that OP needs…

inputs[0].RowData

Have you tried the Python interface package “paraview?”

Unrelated, this is about programmable filter, not pvpython.

Thanks for the reply! The package “paraview” has a steep learning curve as it’s intended to fully control Paraview. I found a package “openfoamparser” which reads all the OF output files in the correct formats into data arrays.