<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Try this:</div>
<div><br>
</div>
<div>
<div>------------</div>
<div>try: paraview.simple</div>
<div>except: from paraview.simple import *</div>
<div>paraview.simple._DisableFirstRenderCameraReset()</div>
<div><br>
</div>
<div>count=1</div>
<div><br>
</div>
<div>filename='/home/andy/Desktop/L2-1 Dicom/data8/rho_180x180x180_frame%04d_subs01_total.raw' % (count)</div>
<div>rho_180x180x180_frame0010_subs01_total_raw = ImageReader( FilePrefix=filename )</div>
<div><br>
</div>
<div>rho_180x180x180_frame0010_subs01_total_raw.DataExtent = [0, 179, 0, 179, 0, 179]</div>
<div>rho_180x180x180_frame0010_subs01_total_raw.DataScalarType = 'unsigned char'</div>
<div><br>
</div>
<div>RenderView1 = GetRenderView()</div>
<div>a1_ImageFile_PVLookupTable = GetLookupTableForArray( "ImageFile", 1, NanColor=[0.25, 0.0, 0.0], RGBPoints=[0.0, 0.23, 0.299, 0.754, 255.0, 0.706, 0.016, 0.15], VectorMode='Magnitude', ColorSpace='Diverging', ScalarRangeInitialized=1.0 )</div>
<div><br>
</div>
<div>a1_ImageFile_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 255.0, 1.0, 0.5, 0.0] )</div>
<div><br>
</div>
<div>DataRepresentation1 = Show()</div>
<div>DataRepresentation1.EdgeColor = [0.0, 0.0, 0.5000076295109483]</div>
<div>DataRepresentation1.SelectionPointFieldDataArrayName = 'ImageFile'</div>
<div>DataRepresentation1.ScalarOpacityFunction = a1_ImageFile_PiecewiseFunction</div>
<div>DataRepresentation1.ColorArrayName = 'ImageFile'</div>
<div>DataRepresentation1.ScalarOpacityUnitDistance = 1.7320508075688779</div>
<div>DataRepresentation1.LookupTable = a1_ImageFile_PVLookupTable</div>
<div>DataRepresentation1.Representation = 'Volume'</div>
<div>DataRepresentation1.ScaleFactor = 17.900000000000002</div>
<div><br>
</div>
<div>RenderView1.CameraViewUp = [-0.24428917240633777, 0.2192776215931415, 0.9445846308899386]</div>
<div>RenderView1.CameraPosition = [495.4123489395223, -304.665940440324, 285.97976015645276]</div>
<div>RenderView1.CameraClippingRange = [296.6155313125564, 980.96172641737]</div>
<div>RenderView1.CameraFocalPoint = [89.5, 89.50000000000001, 89.5]</div>
<div>RenderView1.CameraParallelScale = 155.0185472774145</div>
<div>RenderView1.CenterOfRotation = [89.5, 89.5, 89.5]</div>
<div><br>
</div>
<div>filename_out='/home/andy/Desktop/L2-1 Dicom/data8/frame_%04d.bmp' % (count)</div>
<div>WriteImage(filename_out)</div>
</div>
<div><br>
</div>
<div>for count in range(2,204):</div>
<div> filename='/home/andy/Desktop/L2-1 Dicom/data8/rho_180x180x180_frame%04d_subs01_total.raw' % (count)</div>
<div>
<div> rho_180x180x180_frame0010_subs01_total_raw = ImageReader( FilePrefix=filename )</div>
</div>
<div><br>
</div>
<div>
<div> filename_out='/home/andy/Desktop/L2-1 Dicom/data8/frame_%04d.bmp' % (count)</div>
<div> WriteImage(filename_out)</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Andrew Pearson <<a href="mailto:andrew.j.pearson@gmail.com">andrew.j.pearson@gmail.com</a>><br>
<span style="font-weight:bold">Date: </span>Tue, 12 Jun 2012 13:03:52 -0400<br>
<span style="font-weight:bold">To: </span><<a href="mailto:paraview@paraview.org">paraview@paraview.org</a>><br>
<span style="font-weight:bold">Subject: </span>[EXTERNAL] [Paraview] Simple script severe slowdown in loop<br>
</div>
<div><br>
</div>
Hi all. I'm a newbie to both ParaView and Python scripting. I have a large number of *.raw files that I wish to load, visualize and save via a screenshot. To do this, I used the start/stop trace feature to produce a python script for one instance, edited
the python script by adding a for loop, then ran it with pvbatch. The script produces the correct output, but it takes progressively longer on each iteration. To give you an idea, I started a batch of 200 files yesterday afternoon -- the first one took 10
seconds, but right now it's only on 180! I know that in Matlab, allocating and re-allocating progressively larger memory chunks in a loop can cause this behavior, but I don't see this happening here. Below is my script -- I appreciate any help anyone can
give.
<div><br>
</div>
<div>
<div>for count in range(1,204):</div>
<div> try: paraview.simple</div>
<div> except: from paraview.simple import *</div>
<div> paraview.simple._DisableFirstRenderCameraReset() </div>
<div><br>
</div>
<div> filename='/home/andy/Desktop/L2-1 Dicom/data8/rho_180x180x180_frame%04d_subs01_total.raw' % (count)</div>
<div> rho_180x180x180_frame0010_subs01_total_raw = ImageReader( FilePrefix=filename )</div>
<div><br>
</div>
<div> rho_180x180x180_frame0010_subs01_total_raw.DataExtent = [0, 179, 0, 179, 0, 179]</div>
<div> rho_180x180x180_frame0010_subs01_total_raw.DataScalarType = 'unsigned char'</div>
<div><br>
</div>
<div> RenderView1 = GetRenderView()</div>
<div> a1_ImageFile_PVLookupTable = GetLookupTableForArray( "ImageFile", 1, NanColor=[0.25, 0.0, 0.0], RGBPoints=[0.0, 0.23, 0.299, 0.754, 255.0, 0.706, 0.016, 0.15], VectorMode='Magnitude', ColorSpace='Diverging', ScalarRangeInitialized=1.0 )</div>
<div><br>
</div>
<div> a1_ImageFile_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 255.0, 1.0, 0.5, 0.0] )</div>
<div><br>
</div>
<div> DataRepresentation1 = Show()</div>
<div> DataRepresentation1.EdgeColor = [0.0, 0.0, 0.5000076295109483]</div>
<div> DataRepresentation1.SelectionPointFieldDataArrayName = 'ImageFile'</div>
<div> DataRepresentation1.ScalarOpacityFunction = a1_ImageFile_PiecewiseFunction</div>
<div> DataRepresentation1.ColorArrayName = 'ImageFile'</div>
<div> DataRepresentation1.ScalarOpacityUnitDistance = 1.7320508075688779</div>
<div> DataRepresentation1.LookupTable = a1_ImageFile_PVLookupTable</div>
<div> DataRepresentation1.Representation = 'Volume'</div>
<div> DataRepresentation1.ScaleFactor = 17.900000000000002</div>
<div><br>
</div>
<div> RenderView1.CameraViewUp = [-0.24428917240633777, 0.2192776215931415, 0.9445846308899386]</div>
<div> RenderView1.CameraPosition = [495.4123489395223, -304.665940440324, 285.97976015645276]</div>
<div> RenderView1.CameraClippingRange = [296.6155313125564, 980.96172641737]</div>
<div> RenderView1.CameraFocalPoint = [89.5, 89.50000000000001, 89.5]</div>
<div> RenderView1.CameraParallelScale = 155.0185472774145</div>
<div> RenderView1.CenterOfRotation = [89.5, 89.5, 89.5]</div>
<div><br>
</div>
<div> filename_out='/home/andy/Desktop/L2-1 Dicom/data8/frame_%04d.bmp' % (count)</div>
<div> WriteImage(filename_out)</div>
</div>
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at
<a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a> Please keep messages on-topic and check the ParaView Wiki at:
<a href="http://paraview.org/Wiki/ParaView">http://paraview.org/Wiki/ParaView</a> Follow this link to subscribe/unsubscribe:
<a href="http://www.paraview.org/mailman/listinfo/paraview">http://www.paraview.org/mailman/listinfo/paraview</a>
</span>
</body>
</html>