Sumanth Kaushik (skaushik@ll.mit.edu) writes:
> Hi, I have x,y,z data on an irregular grid, and I want
> to map the z values on the irregular grid to regular grid
> at (xi,yi). Matlab has such an interpolation routine. Does
> IDL have a similar routine? or is there a written routine
> that I someone can e-mail me?
>
Someday I will have 10 free minutes so I can add this
answer to my web page. :-)
This is easily done with the Triangulate and Trigrid
routines. Be sure to read the on-line help for these
two routines so you are familiar with their many options.
Here is a simple example of how to display randomly
distributed points in a 3D scatter plot, then grid them
into a 2D array so they can be displayed as a surface plot.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
IDL 5 Reports: http://www.dfanning.com/documents/anomaly5.html
************************************************************ *******
PRO Example
; Create the random data. Set the seed so you see what I see.
seed = 1L
x = RANDOMU(seed, 32)
y = RANDOMU(seed, 32)
z = EXP(-3 * ((x - 0.5)^2 + (y - 0.5)^2))
; Load a color table and create colors for the scatterplot.
LOADCT, 38, NCOLORS=!D.N_COLORS-2
TVLCT, [70,255], [70,255], [70,0], !D.N_COLORS-2
zcolors = BYTSCL(z, TOP=!D.N_COLORS-3)
; Set up side-by-side viewing.
WINDOW, /Free, XSize=700, YSize=450
!P.MULTI = [0,2,1]
; Draw the 3D coordinate space with axes.
SURFACE, DIST(5), /NODATA, /SAVE, XRANGE=[0,1], $
YRANGE=[0,1], ZRANGE=[0, 1], XSTYLE=1, $
YSTYLE=1, ZSTYLE=1, CHARSIZE=1.5, COLOR=!D.N_COLORS-1, $
BACKGROUND=!D.N_COLORS-2
; Plot the random points in 3D space with a diamond shape.
PLOTS, x, y, z, PSYM=4, COLOR=zcolors, SYMSIZE=2.5, /T3D
; Connect the data points to the XY plane of the plot.
FOR j=0,31 DO PLOTS, [x(j), x(j)], [y(j), y(j)], [0, z(j)], $
COLOR=zcolors(j), /T3D
; Now grid the data so you can display a surface of it.
Triangulate, x, y, triangles
thisSurface = TriGrid(x, y, z, triangles, /Smooth)
s = SIZE(thisSurface)
xx = Findgen(s(1))/(s(1)-1)
yy = Findgen(s(2))/(s(2)-1)
SURFACE, thisSurface, xx, yy, CHARSIZE=1.5, $
COLOR=!D.N_COLORS-1, ZRANGE=[0,1]
!P.MULTI = 0
END
************************************************************ *********
|