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:[email protected]]
Sent: Tuesday, April 14, 2015 7:02 AM
To: Carlson, Eric; [email protected]
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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to