<div dir="ltr"><div><div><div><span style="font-family:monospace,monospace">Hey all,<br><br></span></div><span style="font-family:monospace,monospace">I have a quick question about setting scalar values with the python macro inside paraview.<br><br></span></div><span style="font-family:monospace,monospace">So I have two images that I want to do scalar manipulation with.<br><br></span></div><span style="color:rgb(255,0,0)"><span style="font-family:monospace,monospace"><b>example code:</b></span></span><br><span style="font-family:monospace,monospace">

</span><pre style="margin:12px 0px 0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="font-weight:600;color:rgb(0,128,0)">from</span> <span style="font-weight:600;color:rgb(0,0,255)">paraview</span> <span style="font-weight:600;color:rgb(0,128,0)">import</span> simple</span></pre><span style="font-family:monospace,monospace">

</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="font-weight:600;color:rgb(0,128,0)">from</span> <span style="font-weight:600;color:rgb(0,0,255)">vtk.util</span> <span style="font-weight:600;color:rgb(0,128,0)">import</span> numpy_support <span style="font-weight:600;color:rgb(0,128,0)">as</span> npvtk</span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="font-weight:600;color:rgb(0,128,0)"></span><br><span style="font-weight:600;color:rgb(0,128,0)"><span style="font-weight:600;color:rgb(0,128,0)">import</span> <span style="font-weight:600;color:rgb(0,0,255)">vtk.numpy_interface.dataset_adapter</span> <span style="font-weight:600;color:rgb(0,128,0)">as</span> <span style="font-weight:600;color:rgb(0,0,255)">dsa<br></span>import</span> <span style="font-weight:600;color:rgb(0,0,255)">pandas</span> <span style="font-weight:600;color:rgb(0,128,0)">as</span> <span style="font-weight:600;color:rgb(0,0,255)">pd</span></span></pre><span style="font-family:monospace,monospace">
</span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="font-weight:600;color:rgb(0,128,0)">import</span> <span style="font-weight:600;color:rgb(0,0,255)">vtk</span></span></pre><span style="font-family:monospace,monospace"><br> 
</span><div>
<p style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">scaling_vti <span style="color:rgb(102,102,102)">=</span> simple<span style="color:rgb(102,102,102)">.</span>XMLImageDataReader(FileName<span style="color:rgb(102,102,102)">=</span>[scaling_filename])</span></p>

<pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">scaling_rawData <span style="color:rgb(102,102,102)">=</span> simple<span style="color:rgb(102,102,102)">.</span>servermanager<span style="color:rgb(102,102,102)">.</span>Fetch(scaling_vti)</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><span style="font-family:monospace,monospace">scaling_</span>data <span style="color:rgb(102,102,102)">=</span> dsa<span style="color:rgb(102,102,102)">.</span>WrapDataObject(</span><span style="font-family:monospace,monospace"><span style="font-family:monospace,monospace">scaling_</span>rawData)</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">scaling_array <span style="color:rgb(102,102,102)">=</span> pd<span style="color:rgb(102,102,102)">.</span>DataFrame(npvtk<span style="color:rgb(102,102,102)">.</span>vtk_to_numpy(data<span style="color:rgb(102,102,102)">.</span>GetPointData()<span style="color:rgb(102,102,102)">.</span>GetScalars()), columns<span style="color:rgb(102,102,102)">=</span><br>[<span style="color:rgb(186,33,33)">'scaling_error'</span>])<br>
</span></pre><p style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">humans_vti <span style="color:rgb(102,102,102)">=</span> simple<span style="color:rgb(102,102,102)">.</span>FindSource(humans_filename)</span></p>
<span style="font-family:monospace,monospace">humans_vti<span style="color:rgb(102,102,102)">.</span>PointArrayStatus <span style="color:rgb(102,102,102)">=</span> [<span style="color:rgb(186,33,33)">'Scattering Density'</span>]
<br></span>
<span style="font-family:monospace,monospace"><span style="font-family:monospace,monospace">humans_</span>rawData <span style="color:rgb(102,102,102)">=</span> simple<span style="color:rgb(102,102,102)">.</span>servermanager<span style="color:rgb(102,102,102)">.</span>Fetch(humans_vti)<br></span><span style="font-family:monospace,monospace"><span style="font-family:monospace,monospace">humans_</span>data <span style="color:rgb(102,102,102)">=</span> dsa<span style="color:rgb(102,102,102)">.</span>WrapDataObject(</span><span style="font-family:monospace,monospace"><span style="font-family:monospace,monospace">humans_</span>rawData)<br>humans_array <span style="color:rgb(102,102,102)">=</span> pd<span style="color:rgb(102,102,102)">.</span>DataFrame(npvtk<span style="color:rgb(102,102,102)">.</span>vtk_to_numpy(</span><span style="font-family:monospace,monospace"><span style="font-family:monospace,monospace">humans_</span>data<span style="color:rgb(102,102,102)">.</span>GetPointData()<span style="color:rgb(102,102,102)">.</span>GetScalars()), columns<span style="color:rgb(102,102,102)">=</span>[<span style="color:rgb(186,33,33)">'scalar_intensity'</span>])<br></span><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">
</span></pre><p style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">new_scalars <span style="color:rgb(102,102,102)">=</span> pd<span style="color:rgb(102,102,102)">.</span>DataFrame(humans_array<span style="color:rgb(102,102,102)">.</span>scalar_intensity <span style="color:rgb(102,102,102)">*</span> scaling_array<span style="color:rgb(102,102,102)">.</span>scaling_error)<br></span></p><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">
</span></pre><p style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">data<span style="color:rgb(102,102,102)">.</span>GetPointData()<span style="color:rgb(102,102,102)">.</span>SetScalars(npvtk<span style="color:rgb(102,102,102)">.</span>numpy_to_vtk(new_scalars))</span></p><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace"><br></span></pre><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">After I do this, I can bypass the pipeline (because I haven't figure out how to use it yet) by<br></span></pre><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">writing this image to a new file then load it again to render it.<br><br>Is there a way I can set the paraview image with the new scalar values and have it render without <br>having to write it to a file first?<br><br></span></pre><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">Or, is there a way to convert the vtk.numpy_interface.dataset_adapter.DataSetAttributes type back <br>to paraview.servermanager.FieldDataInformation?<br><br></span></pre><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">Thanks,<br><br></span></pre><pre style="margin:0px;text-indent:0px"><span style="font-family:monospace,monospace">Kevin E. Dean<br></span></pre></div></div>

<br>
<span><font color="#888888">This email and its contents are confidential. If you are not the 
intended recipient, please do not disclose or use the information within
 this email or its attachments. If you have received this email in 
error, please report the error to the sender by return email and 
delete this communication from your records.</font></span>