[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: xyz triplet array to a "flat" 2D array?
"Todd Bowers" <tbowers@nrlssc.navy.mil> writes:
> Does anybody have a quickie that'll convert data in xyz triplets
> to "flat" format? e.g.
>
> x y z to 89.5 89.6 89.7 89.8
> 89.7 20.1 00.1 20.1 00.1
> 89.6 20.3 00.2 20.2 00.3
> 89.8 20.2 00.3 20.3 00.4 00.2
> 89.5 20.3 00.4
>
> with x running across the top and y down the first column, blanks
> are NaN's or whatever. Like it's been interpolated, but without
> the interpolation ;).
How about:
dx = (x1-x0)/nx
dy = (y1-y0)/ny
flat = fltarr(nx,ny)
flat((x-x0)/dx, (y-y0)/dy)) = z
where [x0,x1] and [y0,y1] are the X and Y ranges of the data. Error
checking, and one-off questions are left as an exercise for the
reader. Creative uses of HISTOGRAM and REVERSE_INDICES can also be
used, if you are interested in extra credit.
Good luck,
Craig
--
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------