In this lecture we will learn how to display data that are a function of two variables. An example would be the height of the ground above sea level as a function of distance East and distance North. There are no figures in these notes - if you want to see what the plots look like, start IDL up and run the examples. We will construct an example data set using this short program:
nx=21 ; Number of points in x direction ny=31 ; Number of points in y direction xmin=-2 ; x axis goes from xmin ... xmax=2 ; ... to xmax ymin=-2 ; y axis goes from ymin ... ymax=2 ; ... to ymax ; make 1-d arrays containing x axis and y axis values x=xmin + findgen(nx)*(xmax-xmin)/(nx-1);distance east (m) y=ymin + findgen(ny)*(ymax-ymin)/(ny-1);distance north (m) ;Note: findgen/indgen create ; single-precision, floating-point/integer arrays with the specified ;dimensions. Each element of the array is set to the value of its ;one-dimensional subscript. ; z is a 2-d array which will contain the data values z=fltarr(nx,ny) ; x2d and y2d are arrays the same size as z. They contain the x values ; at each point and the y values at each point. This is done so that ; we can calculate z without using nested for loops. x2d=z y2d=z for j=0,nx-1 do y2d(j,*)=y for j=0,ny-1 do x2d(*,j)=x ; calculate z. (Height above mean sea level (m)) z=exp(-(x2d^2 +y2d^2)) + 0.6*exp(-((x2d+1.8)^2 +(y2d) ^2)) ; don't forget the 'end' statement end
If you type this program into a file called example2d.pro ( or, if you are looking at the HTML version of these notes with a web browser, cut and paste it) and then type:
IDL> .run example2d
you will be left with two 1-D arrays called x and y and a 2-d array called z. You can imagine that x is distance East, y is distance North and z is height above sea level. We will investigate several ways of displaying these data.