Loading data with python

Hi,

I’m using python scripts to automate the loading and slicing of data files. The data I am reading in is stored as point data. The problem I would like to solve is that I don’t always know the variable names that I am trying to load before I run my scripts. When I use the ParaView GUI, I can check the box next to point arrays to have it select all the variables when loading data. I can even go into the settings and check the “Load All Variables” box in the GUI and all of the point array variables will be prechecked when I load them. However when I use python to script this, I have to say something like the following:

dataFile = VisItTecplotBinaryReader(FileName=[fname])
dataFile.PointArrayStatus = [‘Density’, ‘Pressure’, ‘etc’]

However, I have to already know that ‘Density’ and ‘Pressure’ are variables in my dataset so that I can load them in this fashion. Is there a way to load all of the variables in this fashion without specifying the unique variable names? Thanks for your help!

To access all of the available choices and their current status, you need to get the associated Info object which will have a list of the array name then the boolean status.

Note: I do not have any sample VisItTecplot files to try this on but it works in this manner for other readers that have a checklist for data arrays.

>>> reader = VisItTecplotBinaryReader(FileName=[fname])
>>> # Which arrays are available?
>>> reader.GetProperty('PointArrayStatusInfo') # or reader.GetProperty('PointArrayInfo')
['Density', '0', 'Pressure', '0', 'foo', '0', 'goo', '0']

Then you can get that list and use it to activate all data arrays:

status = reader.GetProperty('PointArrayStatusInfo')
dataFile.PointArrayStatus = [status[i] for i in range(0, len(status), 2)]

Let me know if that does/doesn’t work: if it doesn’t, post an example file and I’ll make it work!

1 Like

Using this method with the reader.GetProperty(‘PointArrayInfo’) option worked perfectly! Thanks for the help.

1 Like