In article <e920fce6.0405241309.637e4067@posting.google.com>, "elias"
<heoa@hotmail.com> wrote:
> Dear experts,
> I have a file with 6 columns and 5,000 records. Each of these records
> contain spatial coordinates (x,y,z) and vector components (vx,vy,vz).
> The coordinates are from a Cubic space, however, not all the points
> inside this cube are in the array. How can I build the arrays so that
> they can have the same size? I thought about inserting zeros in between.
> Cube space
> x=50
> y=50
> z=50
> the program that I wrote looks like this: I think the second line is
> not good!
> thank you and best regards,
> elias
> file=DIALOG_PICKFILE(FILTER=['*.dat'])
> array=fltarr(6,50*50L*50L)
> Openr,1,file
> readF,1,array
> x=array[2,*]
> y=array[1,*]
> z=array[0,*]
> u=array[3,*]
> v=array[4,*]
> w=array[5,*]
> close,1
> end
Aha, reading the newsgroup backward is...interesting.
The second line is not good because your reading in 50*50*50 groups of 6
values, which is 125000, not 5000.
What you probably want is
file=DIALOG_PICKFILE(FILTER=['*.dat'])
array=fltarr(6,5000L)
Openr,1,file
readF,1,array
x=array[2,*]
y=array[1,*]
z=array[0,*]
u=array[3,*]
v=array[4,*]
w=array[5,*]
close,1
amp=sqrt(u^2+v^2+w^2)
amp=reform(amp) ;for luck :)
x=reform(x)
y=reform(y)
z=reform(z)
data_3d=grid3(x,y,z,amp,ngrid=50)
end
now you have a 3d data set. Check the keywords for GRID3 for anything you
need, NGRID=50 makes the 3d dataset 50x50x50, as requested, you might
also want START=[x0,y0,z0] and DELTA=[dx,dy,dz] to determine the ranges
in x,y and z (range is delta*ngrid+start I guess)
Chris.
|