Emily,
Attached is the python script to use in the filer. I've added a new
MODE that can be used to set to use min or max.
Utkarsh
On Wed, Sep 14, 2011 at 11:51 AM, Guzas, Emily L CIV NUWC NWPT
<[email protected]> wrote:
> Utkarsh,
>
> Thanks! This works pretty well in serial. However, I took your
> MaxLabelFilter and tried to modify it to calculate and display minimum
> (instead of maximum) array values for each time step and for some reason it
> isn't working -- just assigns a zero value as the minimum. Could you take a
> quick look? I saved the XML file as a *.txt file in case my email tries to
> strip the attachment.
>
> And yes, I will be working in parallel, but not right now.
>
> Thanks again,
> Emily
>
> ________________________________
> From: Utkarsh Ayachit
> Sent: Wed 9/14/2011 10:08 AM
> To: Guzas, Emily L CIV NUWC NWPT
> Cc: [email protected]
> Subject: Re: [Paraview] compute min/max of data array and annotate max and
> min values for each time step
>
> Emily,
>
> Attached is a custom filter that you can use to label using maximum
> for point array named ACCL. You change the "ARRAYNAME" and
> "ARRAYASSOCIATION" variable to pick the array of choice. Also, though
> I've only implemented getting the max value for the magnitude of the
> array, you can change the python script to do a min or a particular
> component, for example.
>
> To test,
> 1) Import the attached file using Tools | Manage Custom Filters dialog
> (click Import).
> 2) The open can.ex2 from ParaViewData. Enable all arrays in the array
> selection widget on the properties panel. Hit apply.
> 3) Create "MaxLabelFilter". Hit apply. You'll see a label in the 3D
> view that updates as you animate.
>
> Are you running with a parallel pvserver? If so, I'll have to update
> the filter. It should work in serial though.
>
> Utkarsh
>
> On Tue, Sep 13, 2011 at 2:28 PM, Guzas, Emily L CIV NUWC NWPT
> <[email protected]> wrote:
>> Hello,
>>
>> I am a ParaView newbie and I am trying to compute the maximum and minimum
>> values of one array (e.g. pressure or density) in a multi-block dataset
>> (*.exo) file in ParaView, and then display those maximum and minimum
>> values
>> on screen with text. To make this more fun, the dataset includes time
>> data,
>> and so what I really want to be able to do is to compute the maximum and
>> minimum values of the array and display them on-screen for each time step
>> so
>> that when I animate the data, the max/min values update as the animation
>> runs.
>>
>> Could someone point me in the right direction for how to do this?
>>
>> I looked at the Calculator filter, but I don't see any maximum and minimum
>> functions there (not that I expected to see them). And I just started
>> looking at the Python Programmable Filter, but I am not familiar with the
>> vtk class and so this route will involve a bit of a learning curve to
>> figure
>> out the syntax for what I need to accomplish.
>>
>> Thanks,
>> Emily
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.paraview.org/mailman/listinfo/paraview
>>
>>
>
ARRAYNAME = "DISPL"
ARRAYASSOCIATION = "Point" # or "Cell"
UNITS = "dyne/cm^2"
MODE = "Min" # or "Max"
def get_value(dataset):
"""Function that returns the Min value for ARRAYNAME in the current
dataset"""
if ARRAYASSOCIATION == "Point":
dsa = dataset.GetPointData()
elif ARRAYASSOCIATION == "Cell":
dsa = dataset.GetCellData()
else:
raise RuntimeError, "Unknown assoctiation %s" % ARRAYASSOCIATION
array = dsa.GetArray(ARRAYNAME)
# if arrayname is missing, we silently ignore.
if array:
if MODE == "Min":
return array.GetRange(-1)[0]
elif MODE == "Max":
return array.GetRange(-1)[1]
else:
raise RuntimeError, "Unknown MODE %s" % MODE
return None
input = self.GetInputDataObject(0, 0)
output = self.GetOutputDataObject(0)
chosen_value = None
if input.IsA("vtkMultiBlockDataSet"):
iter = input.NewIterator()
iter.UnRegister(None)
iter.InitTraversal()
while not iter.IsDoneWithTraversal():
curInput = iter.GetCurrentDataObject()
cur_value = get_value(curInput)
if MODE == "Min":
test_result = (chosen_value == None) or (cur_value < chosen_value)
elif MODE == "Max":
test_result = (chosen_value == None) or (cur_value > chosen_value)
else:
raise RuntimeError, "Unknown MODE %s" % MODE
if test_result:
chosen_value = cur_value
iter.GoToNextItem();
else:
cur_value = get_value(input)
# FIXME: Determine Min/Max in parallel.
if chosen_value == None:
print "Could not determine value, using 0"
chosen_value = 0
outputarray = vtk.vtkStringArray()
outputarray.SetName("%s" % MODE)
outputarray.SetNumberOfTuples(1)
outputarray.SetValue(0, "%s %s = %g %s." % (MODE, ARRAYNAME, chosen_value,UNITS))
output.GetRowData().AddArray(outputarray)
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview