You now know how to make a line plot of some data. In most cases you will have far too much data to want to type it in. Typically the data will be in a file and you will want IDL to read it in and then make a plot of it. As an example, we will use some numbers generated by the MODTRAN radiative transfer package. You have a file containing 14 columns of numbers, like this:
14000. 0.714 7.97E-31 1.56E-26 2.10E-07 4.12E-03 4.11E-08 1.18E-07 2.32E-03 2.94E-08 3.29E-07 6.44E-03 1.64E-05 0.3950 14100. 0.709 4.95E-31 9.84E-27 2.13E-07 4.24E-03 4.15E-08 1.18E-07 2.35E-03 2.90E-08 3.31E-07 6.59E-03 4.96E-05 0.3940 14200. 0.704 3.05E-31 6.15E-27 2.11E-07 4.25E-03 4.17E-08 1.15E-07 2.32E-03 2.81E-08 3.26E-07 6.58E-03 8.22E-05 0.3887 14300. 0.699 1.84E-31 3.77E-27 1.90E-07 3.90E-03 4.06E-08 1.03E-07 2.11E-03 2.56E-08 2.93E-07 6.00E-03 1.12E-04 0.3734 14400. 0.694 1.13E-31 2.35E-27 1.87E-07 3.88E-03 4.05E-08 9.90E-08 2.05E-03 2.46E-08 2.86E-07 5.93E-03 1.40E-04 0.3664 14500. 0.690 6.53E-32 1.37E-27 1.60E-07 3.36E-03 3.74E-08 8.57E-08 1.80E-03 2.17E-08 2.46E-07 5.17E-03 1.65E-04 0.3446 . . . 33800. 0.296 0.00E+00 0.00E+00 2.64E-10 3.01E-05 2.62E-10 2.91E-18 3.33E-13 1.99E-20 2.64E-10 3.01E-05 3.27E-03 0.0001 33900. 0.295 0.00E+00 0.00E+00 1.68E-10 1.93E-05 1.67E-10 1.52E-19 1.75E-14 1.05E-21 1.68E-10 1.93E-05 3.27E-03 0.0000 34000. 0.294 0.00E+00 0.00E+00 1.82E-10 2.10E-05 1.80E-10 1.83E-20 2.11E-15 1.26E-22 1.82E-10 2.10E-05 3.27E-03 0.0000The columns are 201 rows long. Let us suppose that we want to plot the 12th column (which is total radiance) against the 2nd column (which is wavelength). Here is a short IDL program which will do this (as you can tell I didn't get the full data file off Hugh, so the plot is rather meaningless).
pro read_plot_modtran ;+ ;Reads and plots modtran data from a particular file pldat.dat ;Hugh Pumphrey (a long time ago) modified by John Marsham (11/04/2005) ;- ;;;;;; Set up array to contain the data ;;;;;;;;;;;;;;; modtrandata=fltarr(14,201) ;;;;;; Open the file, attach it to unit no. 1 ;;;;;;;;; openr,1,'/nfs/env-fs-04_u35/jmarsham/public_html/Teaching/IDL_course/pldat.dat' ;;;;;; read the data from the file attached to unit 1 ;;;;;;; ;;;;;; into the array modtrandata readf,1,modtrandata ;;;;IF THE DATA WAS BINARY YOU'D USE READU;;;;; ;;;;;; Close the file ;;;;;; close,1 ;;;;;; Now make the plot ;;;;;; plot,modtrandata(1,*),modtrandata(11,*), $ xtitle='Wavelength (microns)',$ ytitle='Radiance (Watts/(cm!U2!N Steradian Micron))' ;;;;;; Don't forget the 'end' statement ;;;;;; end
Note that we have to know in advance how many rows and columns there are in the file. We'll look at how to get around this later in the course.
Note also that for an IDL array with n elements, the individual elements are numbered from 0 to n-1 , just as in C or Java. They are not numbered from 1 to n as in Fortran.
Also note that the data has 201 rows and 14 columns and we defined our array using modtrandata=fltarr(14,201) .