ResampleWithDataset in batch python: output only some columns

Dear all,

I wrote a python script to interpolate data using the ResampleWithDataset filter. I also want to output the result of the filter in a csv file. Here is what I tried:


resampleWithDataSet = ResampleWithDataSet(Input = ..., Source = ...)
writer = CreateWriter(myFile.csv, resampleWithDataSet)
writer.UpdatePipeline()

This works, but prints all columns, which are
“u”, “Points:0”, “Points:1”, “Points:2”, and “vtkValidPointMask”.
What I want is to output only the “u” column.

I thought the PassArrays filter helps and I tried

resampleWithDataSet = ResampleWithDataSet(Input = ..., Source = ...)
passArrays = PassArrays(resampleWithDataSet)
passArrays.RowDataArray = ['u']
writer = CreateWriter(myFile.csv, passArrays)
writer.UpdatePipeline()

But this outputs only “Points:0”, “Points:1”, “Points:2”. Regardless of what I write in
passArrays.RowDataArray = [‘u’], always the three columns are printed.

So is the PassArrays filer the right filter for outputting only some columns obtained from ResampleWithDataset ?

Thank you!

EDIT to my question:

I applied the Pass Arrays filter in the GUI to narrow down my problem and there is not even the possibility to not output the points:

As you can see, I can only uncheck the columns u and vtkValidPointMask within the Pass Arrays filter. Unchecking the Points column is not possible.
However, what I want is to output only the u column.

How can I do this?

Click on this button: a
and uncheck the points, then save as csv using this button: b

This is the way to go in the gui, but I have to achieve this with a python script since I do resampling for a bunch of files.

I can “Tools → Start Trace”, do your steps, “Stop Trace”, but this gives like 10-20 lines of script code.

Is there really no easier way to do this in python?

I’m afraid this is not possible in pvpython sadly. You would need to convert your dataset to a vtkTable but there is no such filter. It would be trivial to add though.

I see.

Out of curiosity: Why is the PassArrays filter not working here?

Because points are not an array in a dataset, they are points. You cant have a dataset without points. You need to convert to a table first, which contain only arrays and no geometry/topology.