[Paraview] Comparing datasets - taking a difference

Berk Geveci berk.geveci at kitware.com
Wed Jun 11 09:25:02 EDT 2008


Yes, there is a better way of doing this: using the python
programmable filter. What you will need:

1. cvs paraview or a development snapshot from here:
http://paraview.org/New/download.html

2. numpy

We are not distributing numpy with our binaries yet so your best bet
is to download python and numpy and then download the ParaView source
from cvs and compile against that. We will probably start distributing
numpy with our binaries in the future to avoid this.

Then, you write a scipt like the following:

from paraview import numpy_support
import numpy

# get the two inputs - note this requires connecting two inputs to the filter
input0 = self.GetInputDataObject(0, 0)
input1 = self.GetInputDataObject(0, 1)

# convert the input arrays to numpy arrays. substitute the right cell/point data
# and the right array names
ar0 = numpy_support.vtk_to_numpy(input0.GetPointData().GetArray("Elevation"))
ar1 = numpy_support.vtk_to_numpy(input1.GetPointData().GetArray("Result"))

# take the difference and convert to vtk array
out = numpy_support.numpy_to_vtk(ar1 - ar0, 1)
# give it a name
out.SetName("difference")

# add it to the output
self.GetOutputDataObject(0).GetPointData().AddArray(out)


In the future, this will be much simpler. My plan is that the above
will look like:

out = inputs[1].pointdata.Elevation - inputs[0].pointdata.Result
output.add_array(out, "difference")

I hope this helps.

-berk

On Tue, Jun 10, 2008 at 8:52 PM, amayt <tyamamayt at gmail.com> wrote:
> Hello,
>
> When comparing datasets, you can use the following procedures to
> integrate multiple data.  However, the resulting data contains
> multiple data arrays in addition to the original data, which increases
> the data size.  For example, the data 'h0' is a copy of 'h' in the
> following case, so it seems like that 'h' is no longer necessary.  Is
> it possible to remove such data arrays?
>
> Any other suggestions to decrease the data size would be appreciated.
>
>> 1) Use Calculator #0 to rename the variable from dataset #0
>>   (eg pick just 'h' with result array name 'h0')
>> 2) Use Calculator #1 to rename the variable from dataset #1
>>   (eg 'h' to 'h1')
>> 3) Use "Append Attributes" while having selected both Calculator #0
>>   and #1 to combine the output from 1) and 2). AppendAttributes1
>>   now contains 'h0', 'h1' as well as 'h' (which one?).
>> 4) Use Calculator #2 on AppendAttributes1 to take difference (eg h1-h0).
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview
>


More information about the ParaView mailing list