comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: 2D Interpolation on Irregular Grids
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: 2D Interpolation on Irregular Grids [message #9378] Tue, 17 June 1997 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
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
************************************************************ *********
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Widgets and research
Next Topic: 2D Interpolation on Irregular Grids

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 11:28:22 PDT 2025

Total time taken to generate the page: 0.15974 seconds