[Paraview] How does one rescale CSVReader data via pvpython?
Greg Schussman
schussman at slac.stanford.edu
Thu Sep 15 19:00:50 EDT 2011
Hi, Jean.
Thank you for helping. On your suggestion, I tried removing the Fetch,
but then I was getting empty objects. From googling around a bit, I
realized that I needed to call wake_out.UpdatePipeline() before moving on.
Because this is pretty ad-hoc, I'd prefer to avoid creating a filter,
and just keep the macro self-contained. I'm having difficulty finding
how to connect inputs and outputs. I've spent a lot of time with
google, and with the dir() command, but still don't see how to get at
the data.
Thanks for your contiuned help. Below is what I currently have.
Greg
##########################
# this part seems good
filename = '/raid/schussma/work2/ace3p/paraview/macros/wakeplot/wake.out'
wake_out = CSVReader(FileName=filename,
FieldDelimiterCharacters = ' ',
HaveHeaders = 0)
wake_out.UpdatePipeline() # this is necessary! blank objects otherwise...
##########################
# here is the mystery
di = wake_out.GetDataInformation()
ri = di.GetRowDataInformation()
scale = 1.0/ri.GetArrayInformation(2).GetComponentRange(0)[1]
input = ??? # what goes here?
import vtk
newcol0 = vtk.vtkDoubleArray()
newcol0.DeepCopy(input.GetColumn(1))
for i in range(newcol0.GetNumberOfTuples()):
newcol0.SetValue(i, scale * newcol0.GetValue(i)) # rescale
output = ???.GetOutputDataObject(0)
output.AddColumn(newcol0)
##########################
# this was good without the scaling
pd = PlotData(???) # is no longer wake_out, correct?
dr = Show(pd,
XArrayName = 'Field 0',
AttributeType = 'Row Data',
SeriesVisibility = ['vtkOriginalIndices', '0'])
Render()
On 09/15/2011 02:05 AM, Favre Jean wrote:
> Greg,
>
> I would not use Fetch to do what you need. Here is something that should work:
>
> # reuse your wake_out proxy
>
> di = wake_out.GetDataInformation()
> rowInfo = di.GetRowDataInformation()
>
> # get largest magnitude value from column 2
>
> rowInfo.GetArrayInformation(1).GetComponentRange(0)[1]
>
> #You then use a programmable filter with the following copy op.
> #one deepcopy to get your initial array, and then you scale it the way you want
> # you may discard the old array later
>
>
> import vtk
>
> input = self.GetInput()
>
> newcol0 = vtk.vtkDoubleArray()
>
> newcol0.DeepCopy(input.GetColumn(0))
>
> for i in range(newcol0.GetNumberOfTuples()):
>
> newcol0.SetValue(i, 2.0 * newcol0.GetValue(i)) # rescale by a factor of 2
>
>
> output = self.GetOutputDataObject(0)
>
> output.AddColumn(newcol0)
>
> print output.GetNumberOfColumns()
>
> -----------------
> Jean M. Favre
> Swiss National Supercomputing Center
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20110915/9a08265d/attachment.htm>
More information about the ParaView
mailing list