[Paraview] ParaView numpy interface question

Dean, Kevin kevin.dean at decisionsciencescorp.com
Mon Apr 4 15:46:30 EDT 2016


Hey all,

I have a quick question about setting scalar values with the python macro
inside paraview.

So I have two images that I want to do scalar manipulation with.

*example code:*

from paraview import simple

from vtk.util import numpy_support as npvtk


import vtk.numpy_interface.dataset_adapter as dsa
import pandas as pd

import vtk


scaling_vti = simple.XMLImageDataReader(FileName=[scaling_filename])

scaling_rawData = simple.servermanager.Fetch(scaling_vti)

scaling_data = dsa.WrapDataObject(scaling_rawData)

scaling_array =
pd.DataFrame(npvtk.vtk_to_numpy(data.GetPointData().GetScalars()),
columns=
['scaling_error'])

humans_vti = simple.FindSource(humans_filename)
humans_vti.PointArrayStatus = ['Scattering Density']
humans_rawData = simple.servermanager.Fetch(humans_vti)
humans_data = dsa.WrapDataObject(humans_rawData)
humans_array = pd.DataFrame(npvtk.vtk_to_numpy(humans_data.GetPointData().GetScalars()),
columns=['scalar_intensity'])

new_scalars = pd.DataFrame(humans_array.scalar_intensity * scaling_array.
scaling_error)

data.GetPointData().SetScalars(npvtk.numpy_to_vtk(new_scalars))


After I do this, I can bypass the pipeline (because I haven't figure
out how to use it yet) by

writing this image to a new file then load it again to render it.

Is there a way I can set the paraview image with the new scalar values
and have it render without
having to write it to a file first?

Or, is there a way to convert the
vtk.numpy_interface.dataset_adapter.DataSetAttributes type back
to paraview.servermanager.FieldDataInformation?

Thanks,

Kevin E. Dean

-- 
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20160404/01d9c528/attachment.html>


More information about the ParaView mailing list