[Paraview] plotting integrated values of cutting plane at various offsets

Eric E. Monson emonson at cs.duke.edu
Thu Sep 30 12:48:54 EDT 2010


Was having trouble doing the sum using numpy instead of the python built-in sum(), but I figured it out. It's just slightly cleaner this way, but I don't know which is faster.

Of course, I still don't know if this does what you are looking for, but I thought I'd pass it along anyway... :)  (I had also been using "nice" values for my contours, so this version changes the original test for rt==val to be more robust to roundoff errors.)

rt = inputs[0].PointData['RTData']
rtg = inputs[0].PointData['RTGradMag']
rt_set = sorted(set(rt.reshape((-1,)).tolist()))

sums = vtk.vtkDoubleArray()
sums.SetName('SummedValues')
sums.SetNumberOfComponents(1)
conts = vtk.vtkDoubleArray()
conts.SetName('ContourValues')
conts.SetNumberOfComponents(1)

for val in rt_set:
	summed_val = numpy.sum(rtg[numpy.abs(rt-val)<0.0001], axis=1)
	conts.InsertNextValue(val)
	sums.InsertNextValue(summed_val[0])
	print val, summed_val[0]

pdo = self.GetTableOutput()
pdo.AddColumn(conts)
pdo.AddColumn(sums)

On Sep 30, 2010, at 12:11 PM, Eric E. Monson wrote:

> That's great.
> 
> This is very rough, but I was thinking of something like this after setting the programmable filter Output Data Set Type to vtkTable (to test I've created a Wavelet Source and run it through a Gradient filter, and then a Calculator which creates a new value called RTGradMag, which is the magnitude of the gradient vector, then the data is Contoured by RTData value with Compute Scalars checked ON):
> 
> rt = inputs[0].PointData['RTData']
> rtg = inputs[0].PointData['RTGradMag']
> rt_set = sorted(set(rt.reshape((-1,)).tolist()))
> 
> sums = vtk.vtkDoubleArray()
> sums.SetName('SummedValues')
> sums.SetNumberOfComponents(1)
> conts = vtk.vtkDoubleArray()
> conts.SetName('ContourValues')
> conts.SetNumberOfComponents(1)
> 
> for val in rt_set:
> 	summed_val = sum(rtg[rt==val].reshape((-1,)).tolist())
> 	conts.InsertNextValue(val)
> 	sums.InsertNextValue(summed_val)
> 	print val, summed_val
> 
> pdo = self.GetTableOutput()
> pdo.AddColumn(conts)
> pdo.AddColumn(sums)
> 
> On Sep 30, 2010, at 11:45 AM, Paul Edwards wrote:
> 
>> I've found out how to access the "Integrate Attributes"  - I can import it from vtkPVFiltersPython :)
>> 
>> On 30 September 2010 16:17, Paul Edwards <paul.m.edwards at gmail.com> wrote:
>> Hi Eric,
>> 
>> You are right - I would like one row of integrated values per contour.  I don't understand how I can do this without "Integrate Attributes" though.
>> 
>> Regards,
>> Paul
>> 
>> 
>> On 30 September 2010 15:30, Eric E. Monson <emonson at cs.duke.edu> wrote:
>> Could you be a bit more clear about what you're trying to do? It sounds like you're trying to take your contours and integrate some attributes over each of the contours separately so you get a table which contains as many rows as the number of contours (and maybe separate columns for each attribute)?
>> 
>> As I was playing around I had trouble creating a programmable filter which has a polygonal mesh as input, but a vtkTable as output... Does anyone know if this is possible? Or, does vtkDataObjectToTable filter exist for ParaView so the data could be run through that before the programmable filter?
>> 
>> If I'm understanding what you're trying to do, it seems like it should be possible to implement with a programmable filter if this piece can be accomplished, even without the Integrate Attributes filter.
>> 
>> -Eric
>> 
>> On Sep 30, 2010, at 10:20 AM, Paul Edwards wrote:
>> 
>>> Ah - thanks for the tip!
>>> 
>>> Does anyone know the way to call this in a programmable filter?  Or, is it even wrapped for python?
>>> 
>>> Thanks,
>>> Paul
>>> 
>>> On 30 September 2010 14:51, Eric E. Monson <emonson at cs.duke.edu> wrote:
>>> Hey Paul,
>>> 
>>> I don't have an answer to your problem, but just wanted to point out that vtkIntegrateAttributes is not part of VTK proper, but is listed on the ParaView docs pages:
>>> 
>>> http://www.paraview.org/ParaView3/Doc/Nightly/html/classvtkIntegrateAttributes.html
>>> 
>>> -Eric
>>> 
>>> ------------------------------------------------------
>>> Eric E Monson
>>> Duke Visualization Technology Group
>>> 
>>> 
>>> On Sep 30, 2010, at 6:00 AM, Paul Edwards wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I'm trying to create a table containing several rows of integrated values for different contours with a programmable filter but I can't see how to use the "Integrate Variables" filter.  In filters.xml it show as being called vtkIntegrateAttributes but I cannot create this in python.  Also, there is no webpage for this class on the nightly documentation site.
>>>> 
>>>> Any help is appreciated,
>>>> Paul
>>>> 
>>>> On 30 September 2010 08:57, Biddiscombe, John A. <biddisco at cscs.ch> wrote:
>>>> Sorry Paul. I must have clicked reply instead of replay-all. I intended to post to the list
>>>> 
>>>>  
>>>> JB
>>>> 
>>>>  
>>>>  
>>>> From: Paul Edwards [mailto:paul.m.edwards at gmail.com] 
>>>> Sent: 30 September 2010 09:48
>>>> To: Biddiscombe, John A.
>>>> Subject: Re: [Paraview] plotting integrated values of cutting plane at various offsets
>>>> 
>>>>  
>>>> Thanks John - I'll have a go with a python programmable filter today.
>>>> 
>>>>  
>>>> Regards,
>>>> 
>>>> Paul
>>>> 
>>>>  
>>>> On 30 September 2010 07:19, Biddiscombe, John A. <biddisco at cscs.ch> wrote:
>>>> 
>>>> Paul
>>>> 
>>>>  
>>>> I’d knock up a filter which stores the desired value each time it executes, and increments the list by one on each execution. This would build up a list (in a polydata or vtkTable for example) which could then be plotted on a graph. A reset button on a custom panel can be used to clear the values. I’ve done this a couple of times for time related filters when I wanted to plot something unusual over T.
>>>> 
>>>>  
>>>> JB
>>>> 
>>>>  
>>>> From: paraview-bounces at paraview.org [mailto:paraview-bounces at paraview.org] On Behalf Of Paul Edwards
>>>> Sent: 29 September 2010 15:53
>>>> To: paraview
>>>> Subject: [Paraview] plotting integrated values of cutting plane at various offsets
>>>> 
>>>>  
>>>> Hi,
>>>> 
>>>>  
>>>> I have created a contour and integrated the output to produce a single value.  Is there a way to plot this value as the contour changes?  I have created an animation for the isosurface but cannot see a filter that I could use to plot these values across the range.
>>>> 
>>>>  
>>>> Thanks in advance,
>>>> 
>>>> Paul
>>>> 
>>>>  
>>>> 
>>>> _______________________________________________
>>>> 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
>>> 
>>> 
>> 
>> 
>> 
> 
> _______________________________________________
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100930/94e09bbc/attachment-0001.htm>


More information about the ParaView mailing list