[Paraview] numpy->ParaView for surface
Carlson, Eric
Ecarlson at eng.ua.edu
Tue Apr 14 09:31:07 EDT 2015
Many thanks! I can honestly say it may have taken years to figure that out on my own. It was helpful to add at the end:
programmableSource1.UpdatePipeline()
Also, the dimensions need to be perfect, so for anyone attempting this, the dimensions for this STRM elevation file are (3601,3601,1) and not (1201,1201,1)
Cheers, Eric
From: Favre Jean [mailto:jfavre at cscs.ch]
Sent: Tuesday, April 14, 2015 7:02 AM
To: Carlson, Eric; paraview at paraview.org
Subject: RE: numpy->ParaView for surface
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/f109ea83/attachment.html>
More information about the ParaView
mailing list