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 = &#39;point_data&#39;</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">Calculator2.Function = &#39;U_Z&#39;</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);">Calculator2.ResultArrayName = &#39;U_Z&#39;<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 = &#39;&#39;</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">ProgrammableFilter2.PythonPath = &#39;&#39;</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);">ProgrammableFilter2.RequestInformationScript = &#39;&#39;</span><br style="color: rgb(51, 51, 255);">
<span style="color: rgb(51, 51, 255);">ProgrammableFilter2.OutputDataSetType = &#39;vtkTable&#39;</span><br style="color: rgb(51, 51, 255);"><span style="color: rgb(51, 51, 255);">ProgrammableFilter2.Script = &#39;blabla&#39; <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[&#39;U_Z&#39;]</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&lt;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 &quot;uzmin: &quot;,uzmin,min(Uzdata)</p>
<p style="margin: 0px; text-indent: 0px;">print &quot;minpos: &quot;,minpos</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">output.RowData.append(uzmin, &#39;uzmin&#39;)</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&#39;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">&lt;<a href="mailto:dave.demarle@kitware.com">dave.demarle@kitware.com</a>&gt;</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&#39;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&#39;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&amp;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 &lt;<a href="mailto:eelcovv@gmail.com">eelcovv@gmail.com</a>&gt; wrote:<br>
&gt; Hi David,<br>
&gt;<br>
&gt; Thanks for you suggestion, I got much closer to what I want, but not quite<br>
&gt; yet. I have the feeling I need one slight extra hint :)<br>
&gt;<br>
&gt; To obtain the position of a minimun value I now do the script below: I get<br>
&gt; the mimimum value first with MinMax, then I Threshold the original data on a<br>
&gt; range between min and 0.9*min (the minimum values are negative), then I use<br>
&gt; the calculator to get the x and y position of this range, and then I use the<br>
&gt; DescriptiveStatitics filter to get the average mean of the position. I can<br>
&gt; even use Fetch again to obtain the data, but now the very last step: how to<br>
&gt; I get the mean data itself ? Sorry, I just don&#39;t understand how that<br>
&gt; data.objects exactly work, and there is not much assessible documentation on<br>
&gt; it.<br>
&gt;<br>
&gt; I hope you can give me one last hint<br>
&gt;<br>
&gt; Regards<br>
&gt;<br>
&gt; Eelco<br>
&gt;<br>
&gt;       mm=MinMax(Uzcomponent)<br>
&gt;       mm.Operation=&quot;MIN&quot;<br>
&gt;       mindata=sm.Fetch(Uzcomponent,mm,mm)<br>
&gt;       mindata.GetPointData().GetNumberOfArrays()<br>
&gt;       a0 = mindata.GetPointData().GetArray(1)<br>
&gt;       uzname=a0.GetName()<br>
&gt;       uzmin=a0.GetTuple1(0)<br>
&gt;       print &quot;minimum of %s found: %g\n &quot;%(uzname,uzmin)<br>
&gt;<br>
&gt;       Threshold1 = Threshold(Uzcomponent)<br>
&gt;       Threshold1.Scalars=[&#39;POINTS&#39;,uzname]<br>
&gt;       Threshold1.ThresholdRange=[uzmin,0.9*uzmin]<br>
&gt;<br>
&gt;       CalcPos = Calculator()<br>
&gt;       CalcPos.AttributeMode = &#39;point_data&#39;<br>
&gt;       CalcPos.Function = &#39;iHat*coordsX+jHat*coordsY+kHat*coordsZ&#39;<br>
&gt;       CalcPos.ResultArrayName = &#39;MinPos&#39;<br>
&gt;<br>
&gt;       DescriptiveStatistics1 = DescriptiveStatistics()<br>
&gt;       DescriptiveStatistics1.VariablesofInterest = [&#39;MinPos&#39;]<br>
&gt;       statistics=sm.Fetch(DescriptiveStatistics1)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Feb 10, 2011 at 7:00 PM, David E DeMarle &lt;<a href="mailto:dave.demarle@kitware.com">dave.demarle@kitware.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; The min max filter unfortunately doesn&#39;t keep track of which tuple and<br>
&gt;&gt; processor it found the min in so you can&#39;t get back to the particular<br>
&gt;&gt; point or cell it came from.<br>
&gt;&gt;<br>
&gt;&gt; Instead of using fetch and minmax, try using a values selection. Set<br>
&gt;&gt; the value to be that minimum value. Once you extract the selection and<br>
&gt;&gt; fetch it to the client, you get a copy of the actuall cell(s)/point(s)<br>
&gt;&gt; that have the minimum value and you can query them directly for their<br>
&gt;&gt; spatial location.<br>
&gt;&gt;<br>
&gt;&gt; David E DeMarle<br>
&gt;&gt; Kitware, Inc.<br>
&gt;&gt; R&amp;D Engineer<br>
&gt;&gt; 28 Corporate Drive<br>
&gt;&gt; Clifton Park, NY 12065-8662<br>
&gt;&gt; Phone: 518-371-3971 x109<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Thu, Feb 10, 2011 at 12:13 PM, Eelco van Vliet &lt;<a href="mailto:eelcovv@gmail.com">eelcovv@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt; Dear Paraviewers,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I would like to extract the location of a minimum value from a data set<br>
&gt;&gt; &gt; in<br>
&gt;&gt; &gt; pvbatch<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I were able to find the value of the minimum with<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;        mm=MinMax(Uzcomponent)<br>
&gt;&gt; &gt;        mm.Operation=&quot;MIN&quot;<br>
&gt;&gt; &gt;        mindata=sm.Fetch(Uzcomponent,mm,mm)<br>
&gt;&gt; &gt;        mindata.GetPointData().GetNumberOfArrays()<br>
&gt;&gt; &gt;        a0 = mindata.GetPointData().GetArray(1)<br>
&gt;&gt; &gt;        a1 = mindata.GetScalar()<br>
&gt;&gt; &gt;        print &quot;name 1: &quot;, a0.GetName()<br>
&gt;&gt; &gt;        print &quot;tuple1: &quot;, a0.GetTuple1(0)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Here, a0.GetTyple1 give me the value of the minimum<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; However: How do I find the location of this value ?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Any hint appriciate!<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Regards<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Eelco<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Visit other Kitware open-source projects at<br>
&gt;&gt; &gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Please keep messages on-topic and check the ParaView Wiki at:<br>
&gt;&gt; &gt; <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt; &gt; <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>