This example loads a 2D time-dependent scalar field, where time steps are stored as a sequence of data arrays.
Using TrackingFromFields, a tracking mesh for the temporal evolution of critical points is computed. This filter computes an optimal matching between persistence diagrams (with respect to Wasserstein metric), and discards critical point pairs below a persistence of 1% by default (parameter Tolerance).
The state file further contains an animation of the critical points over time.
#!/usr/bin/env pythonfromparaview.simpleimport*# create a new 'XML Image Data Reader'timeTrackingvti=XMLImageDataReader(FileName=["timeTracking.vti"])timeTrackingvti.CellArrayStatus=[]# select data arrays 000, 002, 004, ..., 118timeTrackingvti.PointArrayStatus=["{:0>3}".format(i)foriinrange(0,120,2)]# create a new 'TTK TrackingFromFields'tTKTrackingFromFields1=TTKTrackingFromFields(Input=timeTrackingvti)tTKTrackingFromFields1.ForceZtranslation=1tTKTrackingFromFields1.ZTranslation=0.125tTKTrackingFromFields1.Fweight=1# create a new 'Threshold', get the minimum trajectoriesthreshold1=Threshold(Input=tTKTrackingFromFields1)threshold1.Scalars="CriticalType"threshold1.LowerThreshold=0.0threshold1.UpperThreshold=0.0# create a new 'Threshold', get the maximum trajectoriesthreshold2=Threshold(Input=tTKTrackingFromFields1)threshold2.Scalars="CriticalType"threshold2.LowerThreshold=3.0threshold2.UpperThreshold=3.0# group minima and maxima trajectoriesappendDatasets1=AppendDatasets(Input=[threshold1,threshold2])# create a new 'Extract Surface'extractSurface1=ExtractSurface(Input=appendDatasets1)# save the outputSaveData("timeTracking.vtp",extractSurface1)
To run the above Python script, go to your ttk-data directory and enter the following command: