<div dir="ltr">Note that LookupValue uses internal data structures to speed repeated queries (at the cost of more memory). If basically does a binary search in a sorted array using std::lower_bound()[1] after sorting the array on first call.<div><br></div><div>[1] <a href="http://www.sgi.com/tech/stl/lower_bound.html">http://www.sgi.com/tech/stl/lower_bound.html</a></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 8, 2015 at 8:08 AM Cory Quammen <<a href="mailto:cory.quammen@kitware.com">cory.quammen@kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Very nice, Jean.</div><div class="gmail_extra"></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 8, 2015 at 4:21 AM, Favre Jean <span dir="ltr"><<a href="mailto:jfavre@cscs.ch" target="_blank">jfavre@cscs.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">my preference goes towards using numpy for this type to query<br>
<br>
use the where() function.<br>
<br>
# example 1:<br>
<br>
import vtk<br>
from vtk.numpy_interface import dataset_adapter as dsa<br>
<br>
# assuming your mesh data is in the object 'vtkgrid'<br>
np_grid = dsa.WrapDataObject(vtkgrid)<br>
<br>
# assuming your scalar variable is called 'scalars'<br>
np_scalars = np_grid.PointData['scalars']<br>
<br>
# min and max are:<br>
print np.min(np_scalars), np.max(np_scalars)<br>
<br>
#Their position(s) in the array is(are):<br>
np.where(np_scalars == np.max(np_scalars))<br>
np.where(np_scalars == np.min(np_scalars))<br>
<br>
# example 2:<br>
<br>
a = np.array([0, 0, 1, 2, 8, 9, 10, 9, 0, 0, 0, 9, 10, 9, 8, 6, 4, 3, 0, 0])<br>
<br>
<div>In [51]: np.where(a == a.min())<br>
Out[51]: (array([ 0, 1, 8, 9, 10, 18, 19]),)<br>
<br>
In [52]: np.where(a == a.max())<br>
Out[52]: (array([ 6, 12]),)<br>
<br>
References:<br>
<br>
<a href="http://kitware.com/blog/home/post/714" target="_blank">http://kitware.com/blog/home/post/714</a><br>
<br>
<div><font size="2"><span style="font-size:10pt">
<div>-----------------<br>
Jean<br>
CSCS<br>
</div>
</span></font></div>
</div>
</div>
</div>
</blockquote></div><br><br clear="all"><div><br></div></div><div class="gmail_extra">-- <br><div>Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div>