Simon, Use the following for your main body. Also note, for AMR datasets, the scalars are available cell data, not point data.
----------------------------------------------------------------------------------- if input.IsA("vtkUniformGridAMR"): # This initializes AMR properly. It will share the dataset instances # but we will clone those later. output.ShallowCopy(input) iter = input.NewIterator() iter.UnRegister(None) iter.InitTraversal() while not iter.IsDoneWithTraversal(): curInput = iter.GetCurrentDataObject() curOutput = curInput.NewInstance() calculateSum(curInput, curOutput) output.SetDataSet(iter, curOutput) curOutput.UnRegister(None) iter.GoToNextItem(); else: calculateSum(input, output) ----------------------------------------------------------------------------------- On Tue, Jul 1, 2014 at 8:40 AM, Su, Simon M CTR USARMY ARL (US) <simon.m.su....@mail.mil> wrote: > > Hello, > > I am trying to simply add up all the values of a variable in the CTH dataset > using programmable filter with the python code at the end of this email.. > > The code seems to be working for the other dataset that I worked in the > past. But for CTH dataset, it is giving me an error with GetCellData > > Traceback (most recent call last): > > File "<string>", line 22, in <module> > > File "<string>", line 43, in RequestData > > File "<string>", line 8, in calculateSum > > AttributeError: GetCellData > > > When I printed the output for CTH dataset it is giving me > > vtkNonOverlappingAMR (0x7f96ca7675c0) > > Debug: Off > > Modified Time: 860345754 > > Reference Count: 2 > > Registered Events: (none) > > Information: 0x7f96ca767040 > > Data Released: False > > Global Release Data: Off > > UpdateTime: 856914636 > > Field Data: > > Debug: Off > > Modified Time: 855459763 > > Reference Count: 1 > > Registered Events: (none) > > Number Of Arrays: 4 > > Array 0 name = GlobalBounds > > Array 1 name = GlobalBoxSize > > Array 2 name = MinLevel > > Array 3 name = MinLevelSpacing > > Number Of Components: 4 > > Number Of Tuples: 6 > > > Any help is in adding a variable in a CTH dataset is much appreciated. > > thank you > -simon > > p/s: sorry for the other unfinished email sent.... > > > > ========================================= > def calculateSum(input, output): > # Copy the cells etc. > output.ShallowCopy(input) > > # Get the array to calculate the coefficient > toSum = output.GetPointData().GetArray("MOMENT_X") > > # for each of the elements, calculate the three roots and store the real > and imaginary output in separate arrays > numPoints = toSum.GetSize() > > # create the output arrays > sum = vtk.vtkDoubleArray() > sum.SetNumberOfValues(numPoints) > sum.SetName("sum") > tsum = 0 > > for i in range(0, numPoints): > tsum = tsum + toSum.GetValue(i) > > for j in range(0, numPoints): > sum.SetValue(j, tsum) > > output.GetPointData().AddArray(sum) > > input = self.GetInputDataObject(0, 0) > output = self.GetOutputDataObject(0) > > if input.IsA("vtkMultiBlockDataSet"): > output.CopyStructure(input) > iter = input.NewIterator() > iter.UnRegister(None) > iter.InitTraversal() > while not iter.IsDoneWithTraversal(): > curInput = iter.GetCurrentDataObject() > curOutput = curInput.NewInstance() > curOutput.UnRegister(None) > output.SetDataSet(iter, curOutput) > calculateSum(curInput, curOutput) > iter.GoToNextItem(); > else: > calculateSum(input, output) > > _______________________________________________ > 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://public.kitware.com/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://public.kitware.com/mailman/listinfo/paraview