Hey Dave,

If you want to retrieve the attribute data to make the calculations then you 
can call

servermanager.Fetch()

to pull from the server to the client. You can see examples on:

http://www.cmake.org/Wiki/ParaView/Python_Scripting

If your data is very large, though, it might be tough to do this. If you look 
at the above page it talks about passing algorithms as the optional arguments, 
like vtkMinMax, which will process the data on the server and send a result to 
the client. I'm not sure all of what would be involved (probably making a 
plugin that you can load with your custom class), but you may be able to make a 
quantile filter in place of vtkMinMax and pass that to Fetch(). 

Another thing I've done is to use a Python Programmable Filter (PPF) to do 
something similar to what vtkMinMax is doing: Calculate statistics on my data 
set and output a single point which has the calculated attributes (such as mean 
of all input attributes). Maybe you could just output a two-point polydata from 
your PPF in which each point contains the 5 and 95 percentiles for every 
attribute, and then Fetch that data to set the LUT ranges?

Hope this helps,
-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Apr 13, 2010, at 1:00 AM, David Pont wrote:

> I am developing a python script to visualise point data (unstructured grid) 
> with a large number of scalar values for each point.
> My problem is some of the scalar data is a bit noisy, i.e. a histogram of the 
> values has a long tail at one or both ends, which effectively reduces the 
> useful range of color in the visualisation. I would like to determine the 5 
> and 95 percentiles for each data array and use these as the range for the 
> LUT. And I would like to do this from my python script. I can't figure out 
> how to get at the underlying point data, as it would then be very easily to 
> calculate a restricted range.
> See my current script below.
>  
> Thanks in advance for any help, Dave
>  
>  
> ####################################################
> from paraview.simple import *
>  
> sm = servermanager
> sm.Connect()
>  
> INPUTFILES = ("Esk all trees v2.txt_1.vtk", "Esk all trees v2.txt_2.vtk", 
> "Esk all trees v2.txt_3.vtk")
>  
> # create reader for legacy VTK files
> reader = LegacyVTKReader(FileNames=INPUTFILES[2])
>  
> #create and configure view window
> Show()
> view = GetActiveView()
> #set the background color
> #view.Background = [1,1,1]  #white
> #set window size
> view.ViewSize = [800, 600]
> view.UseOffscreenRenderingForScreenshots = True
>  
> # set basic display properties
> dp = GetDisplayProperties()
> #set representation
> dp.Representation = "Points"
> #dp.Representation = "Surface"
> #set point size
> dp.PointSize = 2
> dp.MapScalars = True
> dp.InterpolateScalarsBeforeMapping = True
>  
> # create a legend
> bar = 
> servermanager.rendering.ScalarBarWidgetRepresentation(registrationGroup='scalar_bars',
>  registrationName="ScalarBarWidgetRepresentation1")
> #bar.LabelColor = [1.0, 1.0, 1.0]
> #bar.TitleColor = [1.0, 1.0, 1.0]
> bar.TitleFontSize = 10
> bar.LabelFontSize = 10
> view.Representations.append(bar)
>  
> # render and save image for each scalar array in the point data
> for a in reader.PointData :
>                 print a.GetName()
>                 r = a.GetRange()
>                 dp.LookupTable = MakeBlueToRedLT(r[0], r[1])
>                 dp.ColorAttributeType = 'POINT_DATA'
>                 dp.ColorArrayName = a.GetName()
>                 bar.Title = a.GetName()
>                 bar.LookupTable = dp.LookupTable
>                 Render()
>                 #save screenshot
>                 WriteImage( "v%s.jpg" % (a.GetName()) )
> 
> Disclaimer: This e-mail and any attachments may contain information which is 
> confidential or subject to copyright. If you receive this e-mail in error, 
> please delete it.
> Scion does not accept responsibility for anything in this e-mail which is not 
> provided in the course of Scion’s usual business or for any computer virus, 
> data corruption, interference or delay arising from this e-mail.
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects 
> athttp://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ParaView Wiki 
> at:http://paraview.org/Wiki/ParaView
> 
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview

_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to