How to loop over PartitionedDataSets in a ParatitionedDataSetCollection in paraview.simple

Hello,

I am looking to loop over PartitionedDataSets in a ParatitionedDataSetCollection in paraview.simple. I cannot figure out how. Take the code bellow that uses the example source. How do I get the min and max value of the point variable “Scalars”?

Thanks,
Alexandre

# script-version: 2.0
# Catalyst state generated using paraview version 5.13.3
import paraview
paraview.compatibility.major = 5
paraview.compatibility.minor = 13

#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------

# create a new 'PartitionedDataSetCollection Source'
source = PartitionedDataSetCollectionSource(registrationName='PartitionedDataSetCollectionSource1')

# ----------------------------------------------------------------
# restore active source
SetActiveSource(vTPC1)
# ----------------------------------------------------------------

# ------------------------------------------------------------------------------
# Catalyst options
from paraview import catalyst
options = catalyst.Options()
options.GlobalTrigger = 'Time Step'
options.CatalystLiveTrigger = 'Time Step'

# ------------------------------------------------------------------------------
if __name__ == '__main__':
    from paraview.simple import SaveExtractsUsingCatalystOptions
    # Code for non in-situ environments; if executing in post-processing
    # i.e. non-Catalyst mode, let's generate extracts using Catalyst options
    SaveExtractsUsingCatalystOptions(options)

How do I get the min and max value of the point variable “Scalars”?

source.UpdatePipeline()
print(source.GetDataInformation().GetPointDataInformation().GetArrayInformation(3).GetName())
print(source.GetDataInformation().GetPointDataInformation().GetArrayInformation(3).GetComponentRange(0))

I am looking to loop over PartitionedDataSets in a ParatitionedDataSetCollection in paraview.simple

Since the data are in the server you will need first the Fetch the data and then a loop like this https://gitlab.kitware.com/vtk/vtk/-/blob/v9.4.0/Common/DataModel/Testing/Python/TestPartitionedData.py#L190

Make sure that this is what you really need because it will bring all the data to the client.

I would recommend to use the datainformation method above or create a programmable filter (which runs on the server so, no data movement) and return only what you need with a table or trivial dataset like IntegrateVariables does.

Thanks for your answer. What is the meaning of 3 in GetArrayInformation(3)?

Indeed, I’ve been struggling specifically because I didn’t want to fetch, so most of the documentation / help I find does not apply to the proxy.

Okay, 3 is the array index.

Does this give the range over all partitions? Because here, we only have one partition, and it is only one level down. What if we have n partitions? What if partitions are nested multiple levels beneath the root node?

Thanks

For instance, what is the issue here? It’s still a vtkPartitionedDataSetCollection.


boy = ExtractBlock(registrationName='boy', Input=source)
boy.Selectors = ["Root/Boy"]
print(boy.GetDataInformation().GetDataSetTypeAsString())
print(boy.GetDataInformation().GetPointDataInformation().GetArrayInformation("Scalars").GetComponentRange(0))

It should iterate and give you the actual “global” min/max. The only exception is Catalyst/pvbatsch symmetric where you will get global min/max per rank.

First, you need to call UpdatePipeline() before Getting the information.
Also tracing(Tools>Start Trace) my steps in ParaView I noticed that I had to switch the assembly dropdown to “Hierarchy”. This is the working code

boy = ExtractBlock(registrationName='boy', Input=source)
boy.Assembly='Hierarchy'
boy.Selectors = ["Root/Boy"]
boy.UpdatePipeline()
print(boy)
print(boy.GetDataInformation().GetDataSetTypeAsString())
print(boy.GetDataInformation().GetNumberOfPoints())
print(boy.GetDataInformation().GetPointDataInformation().GetArrayInformation("Scalars").GetComponentRange(0))

Thanks for you help Christos.

1 Like