[Paraview] [EXTERNAL] Extracting min/max values of current data range as a variable in python

Andy Bauer andy.bauer at kitware.com
Wed Apr 12 13:33:24 EDT 2017


Hi Ryan,

You should also be able to get the number of tuples, number of components,
the range for each component, the name (though that is likely already
known) and the data type that is being stored (e.g. double, float, int,
etc.). I don't know how to get all of those of the top of my head but can
poke around if needed.

Best,
Andy

On Wed, Apr 12, 2017 at 1:01 PM, Jamison, Ryan Dale <rdjamis at sandia.gov>
wrote:

> Andy,
>
> I combined the Extract Filter Block with the example you outlined below
> and it worked! I was able to use GetRange() to get the minimum and maximum
> of the array for the current time.
>
> On a side note, other than GetRange(), what else can be done with data
> from GetArray()?
>
> Best, Ryan
>
> On Apr 11, 2017, at 7:46 PM, Andy Bauer <andy.bauer at kitware.com> wrote:
>
> Hi,
>
> Besides Yoshimi's way, you should be able to do something like the
> following from pvpython, pvbatch or Python shell.
> yourfilter.PointData.GetArray(<arrayname>).GetRange() # or CellData
>
> For example, for a Python script for a Wavelet source you would do the
> following:
> w = Wavelet()
> w.UpdatePipeline() # needed to execute the pipeline to create the output
> w.PointData.GetArray("RTData").GetRange()
>
> This will work for the output of a filter that returns a regular VTK data
> set or a multiblock data set. If you want the range for only a single block
> of a multiblock I'd recommend using the Extract Block filter to get that
> block. It should be a shallow copy of the data set to do that so it should
> be very fast, even if you don't need the output of the Extract Block filter
> for anything else.
>
> Best,
> Andy
>
> On Tue, Apr 11, 2017 at 9:29 PM, kenichiro yoshimi <
> rccm.kyoshimi at gmail.com> wrote:
>
>> Hi,
>>
>> I also want to know if there is a simple way to do, since I only have
>> the somewhat redundant code:
>> ---
>> source = GetActiveSource()
>>
>> #options for component: -1, 0, 1 and 2 => Mag, X, Y, Z
>> component = -1
>>
>> cdi = source.GetDataInformation().GetCompositeDataInformation()
>>
>> for i in range(cdi.GetNumberOfChildren()):
>>   print 'Block Name: ', cdi.GetName(i)
>>
>>   data = cdi.GetDataInformation(i).GetCellDataInformation()
>>   for j in range(data.GetNumberOfArrays()):
>>     array = data.GetArrayInformation(j)
>>     arrayName = array.GetName()
>>     dataRange = array.GetComponentRange(component)
>>     print arrayName, dataRange
>> ---
>>
>> Thanks,
>> yoshimi
>>
>> 2017-04-12 6:10 GMT+09:00 Jamison, Ryan Dale <rdjamis at sandia.gov>:
>> > Hello Everyone,
>> >
>> > I’m wanting to gain more control over automation with my paraview python
>> > scripts. This time around, I’d like to be able to extract information
>> from
>> > the model and use it in my python script.
>> >
>> > For example, I’d like to extract the minimum and maximum values of a
>> cell
>> > variable from a specific block and use those values in the python
>> script.
>> > Once I extract this information, I’d use it for some additional
>> processing.
>> > Something like:
>> >
>> > minValue, maxValue = someCoolParaviewFunction(blockName, variableName)
>> >
>> > Is this possible? If so, any suggestions on how to do it?
>> >
>> > Thanks,
>> >
>> > Ryan
>> >
>> > _______________________________________________
>> > 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
>> >
>> > Search the list archives at: http://markmail.org/search/?q=ParaView
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://public.kitware.com/mailman/listinfo/paraview
>> >
>> _______________________________________________
>> 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
>>
>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170412/335c9284/attachment.html>


More information about the ParaView mailing list