[Paraview] extract location of minimum

David E DeMarle dave.demarle at kitware.com
Fri Feb 11 16:28:36 EST 2011


I suggest replacing the Calculator and DescriptiveStatistics filters
with one python programmable filter (or python calculator if you are
using 3.10). That way the data type isn't changed and Fetch will do
what you expect it to - produce a standard vtkDataSet with 1
point/cell.

The python calculator expression to get an average x,y,and Z point location is:
hstack([
[global_mean(inputs[0].Points[:,0])],
[global_mean(inputs[0].Points[:,1])],
[global_mean(inputs[0].Points[:,2])]
])

If you then Fetch it's output and get the min (or equivalently max or
just deliver the whole thing and just look at any of the points) you
will get the average X Y and Z coordinates in a 3 component array
names Result.

David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109



On Fri, Feb 11, 2011 at 10:34 AM, Eelco van Vliet <eelcovv at gmail.com> wrote:
> Hi David,
>
> Thanks for you suggestion, I got much closer to what I want, but not quite
> yet. I have the feeling I need one slight extra hint :)
>
> To obtain the position of a minimun value I now do the script below: I get
> the mimimum value first with MinMax, then I Threshold the original data on a
> range between min and 0.9*min (the minimum values are negative), then I use
> the calculator to get the x and y position of this range, and then I use the
> DescriptiveStatitics filter to get the average mean of the position. I can
> even use Fetch again to obtain the data, but now the very last step: how to
> I get the mean data itself ? Sorry, I just don't understand how that
> data.objects exactly work, and there is not much assessible documentation on
> it.
>
> I hope you can give me one last hint
>
> Regards
>
> Eelco
>
>       mm=MinMax(Uzcomponent)
>       mm.Operation="MIN"
>       mindata=sm.Fetch(Uzcomponent,mm,mm)
>       mindata.GetPointData().GetNumberOfArrays()
>       a0 = mindata.GetPointData().GetArray(1)
>       uzname=a0.GetName()
>       uzmin=a0.GetTuple1(0)
>       print "minimum of %s found: %g\n "%(uzname,uzmin)
>
>       Threshold1 = Threshold(Uzcomponent)
>       Threshold1.Scalars=['POINTS',uzname]
>       Threshold1.ThresholdRange=[uzmin,0.9*uzmin]
>
>       CalcPos = Calculator()
>       CalcPos.AttributeMode = 'point_data'
>       CalcPos.Function = 'iHat*coordsX+jHat*coordsY+kHat*coordsZ'
>       CalcPos.ResultArrayName = 'MinPos'
>
>       DescriptiveStatistics1 = DescriptiveStatistics()
>       DescriptiveStatistics1.VariablesofInterest = ['MinPos']
>       statistics=sm.Fetch(DescriptiveStatistics1)
>
>
>
>
> On Thu, Feb 10, 2011 at 7:00 PM, David E DeMarle <dave.demarle at kitware.com>
> wrote:
>>
>> The min max filter unfortunately doesn't keep track of which tuple and
>> processor it found the min in so you can't get back to the particular
>> point or cell it came from.
>>
>> Instead of using fetch and minmax, try using a values selection. Set
>> the value to be that minimum value. Once you extract the selection and
>> fetch it to the client, you get a copy of the actuall cell(s)/point(s)
>> that have the minimum value and you can query them directly for their
>> spatial location.
>>
>> David E DeMarle
>> Kitware, Inc.
>> R&D Engineer
>> 28 Corporate Drive
>> Clifton Park, NY 12065-8662
>> Phone: 518-371-3971 x109
>>
>>
>>
>> On Thu, Feb 10, 2011 at 12:13 PM, Eelco van Vliet <eelcovv at gmail.com>
>> wrote:
>> > Dear Paraviewers,
>> >
>> > I would like to extract the location of a minimum value from a data set
>> > in
>> > pvbatch
>> >
>> > I were able to find the value of the minimum with
>> >
>> >
>> >
>> >
>> >        mm=MinMax(Uzcomponent)
>> >        mm.Operation="MIN"
>> >        mindata=sm.Fetch(Uzcomponent,mm,mm)
>> >        mindata.GetPointData().GetNumberOfArrays()
>> >        a0 = mindata.GetPointData().GetArray(1)
>> >        a1 = mindata.GetScalar()
>> >        print "name 1: ", a0.GetName()
>> >        print "tuple1: ", a0.GetTuple1(0)
>> >
>> > Here, a0.GetTyple1 give me the value of the minimum
>> >
>> > However: How do I find the location of this value ?
>> >
>> > Any hint appriciate!
>> >
>> > Regards
>> >
>> > Eelco
>> >
>> >
>> > _______________________________________________
>> > 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
>> >
>> >
>
>


More information about the ParaView mailing list