Supercomputing Institute Technical User Support

 

IDL: Plotting Irregularly-Gridded Data

  1. Creating a Dataset
  2. The TRIANGULATE Procedure
  3. Plotting the Results with TRIGRID

Creating a Dataset

Create a set of 32 irregularly-gridded data points in 3-D space that we can use as arguments to the TRIGRID and TRIANGULATE functions.
1. Open a window for viewing:
window
2. Set seed to the longword value 1. seed is used to generate random points.
seed=1l
3. Set the number of points to be randomly generated.
n=32
4. Create a set of x values for each of the 32 data points.
x=randomu(seed,n)
5. Create a set of y values for each of the 32 data points.
y=randomu(seed,n)
6. Create a set of z values for each of the 32 data points from the x and y values.
z=exp(-3*((x-0.5)^2+(y-0.5)^2))
7. Plot the XY positions of the random points.
plot,x,y,psym=1,title='Random XY Points'
8. Dismiss the graphics window:
wdelete

The TRIANGULATE Procedure

The TRIANGULATE procedure constructs a Delaunay triangulation of a planar set of points. After a triangulation has been found for a set of irregularly-gridded data points, the TRIGRID function can be used to interpolate surface values to a regular grid.
1. Open a window for viewing:
window
2. To return a triangulation in the variable tr, enter the command:
triangulate,x,y,tr
The variable TR now contains a three-element by 54-element longword array (you may see this by typing Help, TR at the IDL Command Line).

Note: This is not always a 54-element array, it may vary based on the number of points.

3. To produce a plot of the triangulation, shown below, enter the following commands:
plot,x,y,psym=1,title='Triangulation'
for i=0,n_elements(tr)/3 - 1 $
do begin & t=[tr[*, i],tr[0, i]] & plots,x[t],y[t] & endfor
4. Dismiss the graphics window
wdelete

Plotting the Results with TRIGRID

Now that we have the triangulation tr, the TRIGRID function can be used to return a regular grid of interpolated z values.
1. Display a surface plot of the gridded data by passing the result of the TRIGRID function to SURFACE, using the default interpolation technique and add a title to the plot, shown below, by entering:
surface,trigrid(x,y,z,tr)
xyouts,.5,.9,'Linear Interpolation',align=.5,/normal

The TRIGRID function can also return a smoothed interpolation. Set the QUINTIC keyword to use a quintic polynomial method when interpolating the grid.

2. Display the results of the quintic gridding method, shown below, by entering:
surface,trigrid(x,y,z,tr,/quintic)
xyouts, .5,.9,'Quintic Interpolation',align=.5,/normal


 
This information is available in alternative formats upon request by individuals with disabilities. Please send email to alt-format@msi.umn.edu or call 612-624-0528.

HOME | QUESTIONS | FEEDBACK
Employment | Events | Links | People | Publications | Support | Welcome
 


URL: http://www.msi.umn.edu/software/fast/tutorial/fast-starting.html
This page last modified on Friday, 03 November, 2000,  09:10:02 CDT  
Please direct questions or problems to help@msi.umn.edu  
Website related questions or problems should be dirrected to webmaster@msi.umn.edu