Hi David, <br><br>Many thanks for you suggestions. I was away for a while but had some time to look at this points this week again. The using the Python calculator brought me on the trail of using The Programmable Pythonscript filter. <br>
<br>My quest: I want to extrate the minimum value and its position for a time series of VTK files and write the data for all the time step to one single file. <br><br>With the advice so for, I now have the following construction. <br>
<br>First I read a series of VTK files representating the velocity over a cross section<br><br style="color: rgb(51, 51, 255);"><i style="color: rgb(51, 51, 255);">U_pxy_z0_600_t0 = LegacyVTKReader( FileNames=[ List of filename ])</i><br>
<br>Then I extract the U_z velocity component<br><br style="color: rgb(51, 51, 255);"><i><span style="color: rgb(51, 51, 255);">Calculator2 = Calculator()</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);">Calculator2.AttributeMode = 'point_data'</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">Calculator2.Function = 'U_Z'</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);">Calculator2.ResultArrayName = 'U_Z'<br><br><br></span></i>Then I create a Programmable Filter<br>
<br><span style="color: rgb(51, 51, 255);">ProgrammableFilter2 = ProgrammableFilter()</span><br style="color: rgb(51, 51, 255);"><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);">ProgrammableFilter2.RequestUpdateExtentScript = ''</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">ProgrammableFilter2.PythonPath = ''</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);">ProgrammableFilter2.RequestInformationScript = ''</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">ProgrammableFilter2.OutputDataSetType = 'vtkTable'</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);">ProgrammableFilter2.Script = 'blabla' <br>
<br><br></span>For the script of the Programmable filter, I am now doing the following<br><br>
<meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<table style="margin: 4px; color: rgb(51, 51, 255);">
<tbody><tr>
<td style="border: medium none ;">
<p style="margin: 0px; text-indent: 0px;">input=inputs[0]</p>
<p style="margin: 0px; text-indent: 0px;">Uzdata= input.PointData['U_Z']</p>
<p style="margin: 0px; text-indent: 0px;">numPoints = input.GetNumberOfPoints()</p>
<p style="margin: 0px; text-indent: 0px;">uzmin=Uzdata[0]</p>
<p style="margin: 0px; text-indent: 0px;">for i in range(numPoints):</p>
<p style="margin: 0px; text-indent: 0px;">        uz=Uzdata[i]</p>
<p style="margin: 0px; text-indent: 0px;">        if uz<uzmin:</p>
<p style="margin: 0px; text-indent: 0px;">                minpos=input.GetPoint(i)</p>
<p style="margin: 0px; text-indent: 0px;">                uzmin=uz</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">print "uzmin: ",uzmin,min(Uzdata)</p>
<p style="margin: 0px; text-indent: 0px;">print "minpos: ",minpos</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">output.RowData.append(uzmin, 'uzmin')</p></td></tr></tbody></table><br><i><br></i>At this point I am stuck. First of all, the minpos variable is a tuple, and I don't know how to apend this to the output.RowData, because it needs to be and vtkArray. What is the way to convert a tuple into a vtkArray?<br>
<br>Second of all: if I step over the time step and see correctly the minpos and uzmin value updated in the spreadsheet viewer. However, how can I collect all the values into one array and then write to a single file ? Or should I just write the data of each time step to a seperate file ?<br>
<br>Hopefully someone can give me some advice on how to approach this issue. <br><br>Many thanks in advance!<br><br>Regards, <br><br>Eelco <br><br><br><div class="gmail_quote">On Fri, Feb 11, 2011 at 10:28 PM, David E DeMarle <span dir="ltr"><<a href="mailto:dave.demarle@kitware.com">dave.demarle@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I suggest replacing the Calculator and DescriptiveStatistics filters<br>
with one python programmable filter (or python calculator if you are<br>
using 3.10). That way the data type isn't changed and Fetch will do<br>
what you expect it to - produce a standard vtkDataSet with 1<br>
point/cell.<br>
<br>
The python calculator expression to get an average x,y,and Z point location is:<br>
hstack([<br>
[global_mean(inputs[0].Points[:,0])],<br>
[global_mean(inputs[0].Points[:,1])],<br>
[global_mean(inputs[0].Points[:,2])]<br>
])<br>
<br>
If you then Fetch it's output and get the min (or equivalently max or<br>
just deliver the whole thing and just look at any of the points) you<br>
will get the average X Y and Z coordinates in a 3 component array<br>
names Result.<br>
<div class="im"><br>
David E DeMarle<br>
Kitware, Inc.<br>
R&D Engineer<br>
28 Corporate Drive<br>
Clifton Park, NY 12065-8662<br>
Phone: 518-371-3971 x109<br>
<br>
<br>
<br>
</div><div><div></div><div class="h5">On Fri, Feb 11, 2011 at 10:34 AM, Eelco van Vliet <<a href="mailto:eelcovv@gmail.com">eelcovv@gmail.com</a>> wrote:<br>
> Hi David,<br>
><br>
> Thanks for you suggestion, I got much closer to what I want, but not quite<br>
> yet. I have the feeling I need one slight extra hint :)<br>
><br>
> To obtain the position of a minimun value I now do the script below: I get<br>
> the mimimum value first with MinMax, then I Threshold the original data on a<br>
> range between min and 0.9*min (the minimum values are negative), then I use<br>
> the calculator to get the x and y position of this range, and then I use the<br>
> DescriptiveStatitics filter to get the average mean of the position. I can<br>
> even use Fetch again to obtain the data, but now the very last step: how to<br>
> I get the mean data itself ? Sorry, I just don't understand how that<br>
> data.objects exactly work, and there is not much assessible documentation on<br>
> it.<br>
><br>
> I hope you can give me one last hint<br>
><br>
> Regards<br>
><br>
> Eelco<br>
><br>
> mm=MinMax(Uzcomponent)<br>
> mm.Operation="MIN"<br>
> mindata=sm.Fetch(Uzcomponent,mm,mm)<br>
> mindata.GetPointData().GetNumberOfArrays()<br>
> a0 = mindata.GetPointData().GetArray(1)<br>
> uzname=a0.GetName()<br>
> uzmin=a0.GetTuple1(0)<br>
> print "minimum of %s found: %g\n "%(uzname,uzmin)<br>
><br>
> Threshold1 = Threshold(Uzcomponent)<br>
> Threshold1.Scalars=['POINTS',uzname]<br>
> Threshold1.ThresholdRange=[uzmin,0.9*uzmin]<br>
><br>
> CalcPos = Calculator()<br>
> CalcPos.AttributeMode = 'point_data'<br>
> CalcPos.Function = 'iHat*coordsX+jHat*coordsY+kHat*coordsZ'<br>
> CalcPos.ResultArrayName = 'MinPos'<br>
><br>
> DescriptiveStatistics1 = DescriptiveStatistics()<br>
> DescriptiveStatistics1.VariablesofInterest = ['MinPos']<br>
> statistics=sm.Fetch(DescriptiveStatistics1)<br>
><br>
><br>
><br>
><br>
> On Thu, Feb 10, 2011 at 7:00 PM, David E DeMarle <<a href="mailto:dave.demarle@kitware.com">dave.demarle@kitware.com</a>><br>
> wrote:<br>
>><br>
>> The min max filter unfortunately doesn't keep track of which tuple and<br>
>> processor it found the min in so you can't get back to the particular<br>
>> point or cell it came from.<br>
>><br>
>> Instead of using fetch and minmax, try using a values selection. Set<br>
>> the value to be that minimum value. Once you extract the selection and<br>
>> fetch it to the client, you get a copy of the actuall cell(s)/point(s)<br>
>> that have the minimum value and you can query them directly for their<br>
>> spatial location.<br>
>><br>
>> David E DeMarle<br>
>> Kitware, Inc.<br>
>> R&D Engineer<br>
>> 28 Corporate Drive<br>
>> Clifton Park, NY 12065-8662<br>
>> Phone: 518-371-3971 x109<br>
>><br>
>><br>
>><br>
>> On Thu, Feb 10, 2011 at 12:13 PM, Eelco van Vliet <<a href="mailto:eelcovv@gmail.com">eelcovv@gmail.com</a>><br>
>> wrote:<br>
>> > Dear Paraviewers,<br>
>> ><br>
>> > I would like to extract the location of a minimum value from a data set<br>
>> > in<br>
>> > pvbatch<br>
>> ><br>
>> > I were able to find the value of the minimum with<br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > mm=MinMax(Uzcomponent)<br>
>> > mm.Operation="MIN"<br>
>> > mindata=sm.Fetch(Uzcomponent,mm,mm)<br>
>> > mindata.GetPointData().GetNumberOfArrays()<br>
>> > a0 = mindata.GetPointData().GetArray(1)<br>
>> > a1 = mindata.GetScalar()<br>
>> > print "name 1: ", a0.GetName()<br>
>> > print "tuple1: ", a0.GetTuple1(0)<br>
>> ><br>
>> > Here, a0.GetTyple1 give me the value of the minimum<br>
>> ><br>
>> > However: How do I find the location of this value ?<br>
>> ><br>
>> > Any hint appriciate!<br>
>> ><br>
>> > Regards<br>
>> ><br>
>> > Eelco<br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> ><br>
>> > Visit other Kitware open-source projects at<br>
>> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>> ><br>
>> > Please keep messages on-topic and check the ParaView Wiki at:<br>
>> > <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
>> ><br>
>> > Follow this link to subscribe/unsubscribe:<br>
>> > <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br>