This example first loads two pairs of timesteps of an ensemble of scalar fields inside a cinema database from disk.
Then, the MergeTree is computed on each scalar field for the Split Tree.
These two pairs of timesteps are given respectively to two MergeTreeClustering filters to compute a distance between them.
In terms of visualisation, the matching between the trees of the first pair and the trees of the second pair are visualized using their planar layout and their embedding in the data.
The python script computes the matchings and saves the result (for each pair of trees).
#!/usr/bin/env pythonfromparaview.simpleimport*# create a new 'TTK CinemaReader'tTKCinemaReader1=TTKCinemaReader(DatabasePath="./Isabel.cdb")# create a new 'TTK CinemaQuery'tTKCinemaQuery1=TTKCinemaQuery(InputTable=tTKCinemaReader1)tTKCinemaQuery1.SQLStatement="""SELECT * FROM InputTable0WHERE TimeStep == 2 or TimeStep == 32"""# create a new 'TTK CinemaProductReader'tTKCinemaProductReader1=TTKCinemaProductReader(Input=tTKCinemaQuery1)# create a new 'TTK Merge and Contour Tree'tTKMergeandContourTreeFTM4=TTKMergeTree(Input=tTKCinemaProductReader1)tTKMergeandContourTreeFTM4.ScalarField=["POINTS","velocityMag"]tTKMergeandContourTreeFTM4.TreeType="Split Tree"# create a new 'TTK BlockAggregator'tTKBlockAggregator1=TTKBlockAggregator(Input=[tTKMergeandContourTreeFTM4,OutputPort(tTKMergeandContourTreeFTM4,1),OutputPort(tTKMergeandContourTreeFTM4,2),])tTKBlockAggregator1.FlattenInput=0# create a new 'TTK MergeTreeClustering'tTKMergeTreeClustering3=TTKMergeTreeClustering(Input=tTKBlockAggregator1,OptionalInputclustering=None)tTKMergeTreeClustering3.Deterministic=1tTKMergeTreeClustering3.DimensionSpacing=0.1tTKMergeTreeClustering3.DimensionToshift="Y"tTKMergeTreeClustering3.Epsilon1=20.0tTKMergeTreeClustering3.Epsilon2=100.0tTKMergeTreeClustering3.Epsilon3=100.0tTKMergeTreeClustering3.PersistenceThreshold=2.0tTKMergeTreeClustering3.ImportantPairs=20.0tTKMergeTreeClustering3.ImportantPairsSpacing=20.0tTKMergeTreeClustering3.NonImportantPairsProximity=0.2# create a new 'TTK CinemaQuery'tTKCinemaQuery2=TTKCinemaQuery(InputTable=tTKCinemaReader1)tTKCinemaQuery2.SQLStatement="""SELECT * FROM InputTable0WHERE TimeStep == 32 or TimeStep == 45"""# create a new 'TTK CinemaProductReader'tTKCinemaProductReader2=TTKCinemaProductReader(Input=tTKCinemaQuery2)tTKCinemaProductReader2.AddFieldDataRecursively=1# create a new 'TTK Merge and Contour Tree'tTKMergeandContourTreeFTM5=TTKMergeTree(Input=tTKCinemaProductReader2)tTKMergeandContourTreeFTM5.ScalarField=["POINTS","velocityMag"]tTKMergeandContourTreeFTM5.TreeType="Split Tree"# create a new 'TTK BlockAggregator'tTKBlockAggregator2=TTKBlockAggregator(Input=[tTKMergeandContourTreeFTM5,OutputPort(tTKMergeandContourTreeFTM5,1),OutputPort(tTKMergeandContourTreeFTM5,2),])tTKBlockAggregator2.FlattenInput=0# create a new 'TTK MergeTreeClustering'tTKMergeTreeClustering4=TTKMergeTreeClustering(Input=tTKBlockAggregator2,OptionalInputclustering=None)tTKMergeTreeClustering4.Deterministic=1tTKMergeTreeClustering4.DimensionSpacing=0.1tTKMergeTreeClustering4.DimensionToshift="Y"tTKMergeTreeClustering4.PersistenceThreshold=2.0tTKMergeTreeClustering4.ImportantPairs=23.0tTKMergeTreeClustering4.ImportantPairsSpacing=20.0tTKMergeTreeClustering4.NonImportantPairsProximity=0.2# save the outputSaveData("matching_T2_T32.vtm",OutputPort(tTKMergeTreeClustering3,2))SaveData("matching_T32_T45.vtm",OutputPort(tTKMergeTreeClustering4,2))
To run the above Python script, go to your ttk-data directory and enter the following command: