[Paraview] numpy->ParaView for surface

Favre Jean jfavre at cscs.ch
Tue Apr 14 08:02:07 EDT 2015



The same example can be trivially done in ParaView using a ProgrammableSource


programmableSource1 = ProgrammableSource()
programmableSource1.OutputDataSetType = 'vtkImageData'
programmableSource1.Script = 'import numpy as np\nimport zipfile\n\nexecutive = self.GetExecutive()\noutInfo = executive.GetOutputInformation(0)\nexts = [executive.UPDATE_EXTENT().Get(outInfo, i) for i in xrange(6)]\n\noutput.SetExtent(exts)\n\ndata = np.fromstring(zipfile.ZipFile(\'N36W113.hgt.zip\').read(\'N36W113.hgt\'), \'>i2\')\ndata = data.astype(np.float32)\ndata[data == -32768] = data[data > 0].min()\n\noutput.PointData.append(data, "scalar")'
programmableSource1.ScriptRequestInformation = 'executive = self.GetExecutive ()\noutInfo = executive.GetOutputInformation(0)\n\ndims = [1201, 1201, 1]\noutInfo.Set(executive.WHOLE_EXTENT(), 0, dims[0]-1 , 0, dims[1]-1 , 0, dims[2]-1)\noutInfo.Set(vtk.vtkDataObject.SPACING(), 1, 1, 1)\noutInfo.Set(vtk.vtkDataObject.ORIGIN(), 0,0,0)\n'

Jean/CSCS

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150414/ebb7b1a2/attachment.html>


More information about the ParaView mailing list