judy.karpen@nrl.navy.mil (Judy Karpen) writes:
> Hi,
>
> Sorry for posting if this is an easy question to answer, but so far
> I've combed the manuals and the netgroup archives without finding one.
> I don't use IDL all the time, so I am a perpetual beginner
> unfortunately.
>
> I am trying to visualize 3D magnetic field lines, by updating an IDL
> program written by a colleague that assumes uniformly gridded data. My
> "data" (simulation results, actually) are on a nonuniform cartesian
> grid (250x95x95), so my first step is to project the field components
> onto a uniform grid in all directions. I've found a number of routines
> that do the opposite --- that is, interpolate a regularly gridded
> function onto an irregular set of points -- but nothing appropriate.
> Perhaps I am misunderstanding something in the GRID3 documentation,
> but it says that the input arrays x,y,z, and f have to have the same
> number of elements, which rules out having different numbers of points
> in each direction.
Hi Judy--
I am not sure why the constraints of GRID3 are a problem. What it is
asking you to do is label each point with its X Y and Z coordinates.
Since you have NXxNYxNZ points, you will need the same number of X
values, Y values and Z values.
In the example below I make a 10x10x10 3D array with measurement
positions offset slightly by random displacements. I expand the 1D
arrays to 3D arrays using the standard REBIN/REFORM technique. I
compute a function of these values, a simple quadratic. Finally, I
reinterpolate onto a regular grid. The results are quite remarkably
good, and it's in full 3D.
Good luck,
Craig
x = findgen(10)+randomn(seed,10)*0.1 ;; Label X Y and Z axes
y = findgen(10)+randomn(seed,10)*0.1
z = findgen(10)+randomn(seed,10)*0.1
xxx = rebin(reform(x,10,1,1),10,10,10) ;; Convert to X Y & Z 3D arrays
yyy = rebin(reform(y,1,10,1),10,10,10)
zzz = rebin(reform(z,1,1,10),10,10,10)
;; Compute a function of X Y & Z -- a simple quadratic in this case
fff = xxx^2 + yyy^2 + zzz^2
;; Create new grid of regularly sampled points
xnew = findgen(10) & ynew = findgen(10) & znew = findgen(10)
ff2 = grid3(xxx, yyy, zzz, fff, xnew, ynew, znew, /grid)
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|