Querying attribute value within dataset

Hello,

I am trying to apply a moving slice filter to my dataset. I wish for the slice plane to move back and forth along the y-axis. This movement is somewhat complicated, so I included the desired origin y-coordinate as an attribute in the dataset. The attached image shows what the data looks like. I’m plotting Temperature, with TIME storing the time index. The attribute Yc, stored as a scalar field, stores the desired slice plane y-coordinate. I am attempting to move the slice origin with the python animation track shown in the image. However, when I reassign the slice origin, I am struggling with querying the value of Yc. I thought that since Yc is stored as a scalar field, it would be sufficient to query the field data of “data” with GetFieldData, and then query the scalar value of Yc with the command GetScalars(‘Yc’). However, with this implementation, the slice fails to move. Any clarification on what I am misunderstanding would be greatly appreciated!

Sincerely,
Nathaniel Wood

FindSource returns the proxy for the reader, and not the actual dataset. You can either use data-information obtained from the proxy or fetch the data locally and then use that. The former is preferred, if sufficient. For example if Yc is simply a single value, you can indeed just use data-information as follows:

reader = FindSource(...)
ycArrayInfo  = reader.FieldData["Yc"]
component_range = ycArrayInfo.GetRange(0)
# component_range is a tuple `(min, max)`. if it's a single value,
#  they'll be the same, so you can use that in your code subsequently.

Utkarsh,

Based on your suggestion, I have modified the macro so that it now reads:

def start_cue(self): pass
def tick(self): 
reader=FindSource("X_FULL_*") #load in data
ycArrayInfo=reader.FieldData["Yc"] #get Yc field data
ycRange=ycArrayInfo.GetRange[0] #find range of Yc (repeats the same value twice)
yTemp=ycRange[0] #get value of Yc
tempOrigin=tempSlice.SliceType.Origin #query origin of slice
tempOrigin[1]=yTemp #reset y-coordinate of origin to the value Yc
tempSlice.SliceType.Origin=tempOrigin #reassign slice origin
def end_cue(self): pass

I believe this is now reading in the value of Yc properly, and correctly overwriting the origin of the slice filter. However, as the linked animation shows, the slice still does not move. Am I implementing the FindSource incorrectly? My thanks for any continued assistance that you can provide!

Sincerely,
Nathaniel Wood

sample_animation_compressed.wmv (1.6 MB)

Can you share a sample dataset with me, that’ll make this easier? Feel free to email me directly with the dataset.

Utkarsh,

I have emailed a small representative dataset to email address that notified me of your response. Please let me know if you did not receive it.

Sincerely,
Nathaniel Wood

Utkarsh,

My last attempt at sending a dataset failed because of file size constraints. Here is a small sample dataset, consisting of 20 time steps, each represented by a given .vtk file. Please let me know if this is inadequate!

Sincerely,

Nathaniel Wood

sample_dataset.zip (1.81 MB)

Here’s a working state file: state.pvsm (328.2 KB)

The script I used is this:

from paraview import simple

def start_cue(self): pass

def tick(self):
    reader = simple.FindSource("X_FULL_*")
    yc = reader.FieldData["Yc"].GetRange(0)[0]

    slice = simple.FindSource("Slice1")
    slice.SliceType.Origin[1] = yc

def end_cue(self): pass

I just noticed it lagging behind by 1 frame…I recall there’s something about ensuring the pipeline is updated…give me a few to figure that out.

Here’s an updated state file: state-fixed.pvsm (328.3 KB) .

The script is as follows:

from paraview import simple

def start_cue(self): pass

def tick(self):
    reader = simple.FindSource("X_FULL_*")
    time = self.GetClockTime()
    reader.UpdatePipeline(time)
    yc = reader.FieldData["Yc"].GetRange(0)[0]

    slice = simple.FindSource("Slice1")
    slice.SliceType.Origin[1] = yc

def end_cue(self): pass

Utkarsh,

This works! My thanks for all your help!

Sincerely,
Nathaniel Wood