[vtkusers] 3D scatter plot

Paul Cochrane cochrane at esscc.uq.edu.au
Thu Apr 7 23:55:33 EDT 2005


Greg,

This is quite a naiive question but: is it possible at all to scale your
data so that it doesn't have to be of type Long?  

Just as a comment on your code, you could use the Numeric or numarray
modules for your arrays of data, and this *might* help with the typecasting
(possibly, I haven't tested the idea).  For instance,

> x=[0]*int(len(data)/4)
> y=[0]*int(len(data)/4)
> z=[0]*int(len(data)/4)

could be

from Numeric import *
x = zeros((1,int(len(data)/4))  # initialises the array as zeros
y = zeros((1,int(len(data)/4))
z = zeros((1,int(len(data)/4))

However, that's just a comment, you can take or leave that as you wish.

Hope I've been of some help.

Paul


* G P (telos888 at yahoo.com) [050407 12:47]:
> Ok part of the problem is the data set I am using is a
> combination of numbers that in some instances are type
> Long:
> 
> ValueError: expected int|float|non-empty sequence but
> got <type 'long'>
> 
> The project I am working on is a phase space analysis
> tool, I need to take a list of pseudo random numbers
> and plot them in a cube (delayed coordinates).
> 
> I am taking the delta from each group of four numbers,
> then using that to create the x, y, z coordinates to
> be plotted:
> 
> ----------
> file = open(sys.argv[1], 'r')
> data = file.readlines()
> file.close()
> pos=0
> x=[0]*int(len(data)/4)
> y=[0]*int(len(data)/4)
> z=[0]*int(len(data)/4)
> counter=0
> 
> while pos < (len(data))-(len(data)%4):
>    seq0=int(data[pos])
>    pos+=1
>    seq1=int(data[pos])
>    pos+=1
>    seq2=int(data[pos])
>    pos+=1
>    seq3=int(data[pos])
>    pos+=1
>    x[counter]=seq0-seq1
>    y[counter]=seq1-seq2
>    z[counter]=seq2-seq3
>    counter+=1
> ----------
> 
> Here is an example of the data:
> 
> ----------
> 4228201034
> 531187275
> 3584983232
> 2527365236
> 509780418
> 3321656294
> 2030555700
> 4218617818
> 1642741340
> 239947192
> 860006036
> 1218776231
> ----------
> 
> Which results in the following x, y, z coordinates:
> 
> ----------
> 3697013759 -3053795957 1057617996
> -2811875876 1291100594 -2188062118
> 1402794148 -620058844 -358770195
> ----------
> 
> Some of these are type Long, any ideas on a better way
> to calculate the delta between each group of 4 numbers
> and then plot that with a 3D scatter plot?
> 
> Thanks in advance
> 
> Greg
> 
> 
> 
> --- G P <telos888 at yahoo.com> wrote:
> > Greetings,
> > 
> > I am trying to plot a data set of about 200,000 x,
> > y,
> > z points with MayaVi and VTK, the Python program I
> > put
> > together works fine for small groups of numbers, but
> > anything over say 10,000 I get the following message
> > when I try to render the array with VTK:
> > 
> > ----------
> > Scalars.__init__._get_name.warning:
> >         Using name='Scalars0'
> > Scalars.__init__._get_lookup_table.warning:
> >         Using lookup_table='default'
> > Traceback (most recent call last):
> >   File "./testpoints.py", line 35, in ?
> >     vt.tofile('xyz.vtk')
> >   File
> >
> "/usr/lib/python2.3/site-packages/pyvtk/__init__.py",
> > line 195, in tofile
> >     f.write(self.to_string(format))
> >   File
> >
> "/usr/lib/python2.3/site-packages/pyvtk/__init__.py",
> > line 169, in to_string
> >     ret = ['# vtk DataFile Version 2.0',
> >   File
> >
> "/usr/lib/python2.3/site-packages/pyvtk/UnstructuredGrid.py",
> > line 87, in to_string
> >     t = self.get_datatype(self.points)
> >   File
> > "/usr/lib/python2.3/site-packages/pyvtk/common.py",
> > line 125, in get_datatype
> >     r = self.get_datatype(o)
> >   File
> > "/usr/lib/python2.3/site-packages/pyvtk/common.py",
> > line 125, in get_datatype
> >     r = self.get_datatype(o)
> >   File
> > "/usr/lib/python2.3/site-packages/pyvtk/common.py",
> > line 120, in get_datatype
> >     raise ValueError,'expected int|float|non-empty
> > sequence but got %s'%t
> > ValueError: expected int|float|non-empty sequence
> > but
> > got <type 'long'>
> > ----------
> > 
> > Here is an example set of coordinates that are in x,
> > y, and z:
> > 
> > ----------
> > -41374 -53971 -44975
> > -59587 -56972 -41923
> > -57626 -57237 -45579
> > -34283 -35894 -37457
> > -33144 -57130 -52502
> > -64898 -56998 -44598
> > -71716 -62588 -59465
> > -55663 -65333 -50883
> > -37412 -65414 -33598
> > -51713 -40285 -53948
> > -33686 -54479 -59341
> > -63665 -36130 -64861
> > -59285 -36807 -45051
> > -40494 -38004 -47581
> > -61516 -48195 -48235
> > -38270 -57041 -46794
> > -47016 -33707 -61578
> > -50955 -45559 -64038
> > ----------
> > 
> > And here is the transpose function from Numeric that
> > puts everything into an array called 'nodes':
> > 
> > ----------
> > nodes = transpose([x]+[y]+[z])
> > vt = VtkData(UnstructuredGrid(nodes,
> > vertex=range(len(x))), PointData(Scalars(z)), 'Point
> > Cloud')
> > vt.tofile('xyz.vtk')
> > ----------
> > 
> > Any ideas?  Where am I screwing up here?
> > 
> > Thanks in advance
> > 
> > Greg
> > 
> > 
> > _______________________________________________
> > This is the private VTK discussion list. 
> > Please keep messages on-topic. Check the FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> > 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-- 
Paul Cochrane
Computational Scientist/Software Developer
Earth Systems Science Computational Centre
Rm 703, SMI Building
University of Queensland
Brisbane
Queensland 4072
Australia

E: cochrane at esscc.uq.edu.au
P: +61 7 3346 4109
F: +61 7 3365 7347



More information about the vtkusers mailing list