EAS Department / Remote Sensing Remote6-2c.doc (2 columns) Plot – Scatter (scatter.pro) Type in this information to create a graph IDL> array=[[1,5],[2,8]] IDL>print, array IDL> plot,array This is the output 1 5 2 8 This is the graph Type in this information to create a graph IDL> x=[1,5] IDL> y=[2,8] IDL> plot, x,y This is the graph: IDL>array=[[1,2],[5,8]] IDL>print, array IDL> plot,array This is the result ___________________________________ ____ These are the first 4 data rows from 589filter.txt 500.2 5.5 501.1 52.3225 502 52.28 502.9 49.95231 Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Type in this program pro newrsi device, decomposed=0 ;Look into various directories to load a file - looks for 'data1.txt' ;START 1------------FIND DATA FILE----------------filename = Dialog_Pickfile(Filter = '589.txt', /read) get_lun, v print, filename openr, v, filename ;END 1------------------------------------------------------;START 2---------COUNT # LINES IN FILE --------a=' ' K=0 L=0 while ~ EOF(v) do begin readf, v, a k=k+1 endwhile print, 'k=',k close, v free_lun, v ;END 2------------------------------------------------------;START 3----CREATE/PRINT DATA ARRAY ----GET_LUN, LUN OPENR, LUN, FILENAME array=fltarr(2,4) ;read a small fraction of the data file readf, lun, array PRINT, ARRAY ;print the whole array print,array (0,1) ;print the first entry in this format print,array (0,2) print,array (1,0) print, array(1,1) ;END 3------------------------------------------------------;plot, array ;END 6------------------------------------------------------end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx This is the output k= 662 500.200 5.50000 501.100 52.3225 502.000 52.2800 502.900 49.9523 501.100 502.000 5.50000 52.3225 so, the notation (0,1), (0,2) reads and prints the 2nd and 3rd entry in column 1 (e.g. 501.1, 502.0) – this is the reverse of typical mathematical notation Therefore, place the columns first and the rows second. In our case, we need a 2,4 matrix. We can extract the x-values into an x-array (in this case 500, 501, etc.) To extend the size of the array to include all the rows: ;START 3----CREATE AND PRINT DATA ARRAY FROM DATA 1------------------ >array=fltarr(2,k) Now, extract the x-column (really the second column): First, define 1-dimensional arrays (vectors) to hold the data points: >x=fltarr(k,1) >y=fltarr(k,1) Now fill these arrays accordingly >x=array[0,*] ;remember that (0,0) = 500.2 and (0,1) ; =501.1 so we are reading ;the ;mathematical column into an x-axis array. ; END 3 ---------------------------------------------------------; START 4 ------------REVISE X,Y INTO PROPER FORMAT---------------x=fltarr(k,1) y=fltarr(k,1) >y=array[1,*] Now, x and y are in the usual format, but IDL needs to be updated: >x=reform(x) >y=reform(y) Now, >plot, x, y GET_LUN, LUN OPENR, LUN, FILENAME array=fltarr(2,k) readf, lun, array PRINT, ARRAY print,array (0,1) print,array (0,2) print,array (1,0) print, array(1,1) ;produces x=array[0,*] y=array[1,*] x=reform(x) y=reform(y) ; END 4 ----------------------------------------------; START 5 --------------PLOT X,Y ----------------------------plot,x,y ; END 5 ------------------------------------------------------------- end This program should work: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX pro newrsi2 ;READS AND PLOTS A SET OF X,Y DATA - EXPECTS NO HEADERS -- device, decomposed=0 ;Look into various directories to load a file - looks for 'data1.txt' ;START 1------------FIND DATA FILE---------filename = Dialog_Pickfile(Filter = '589.txt', /read) get_lun, v print, filename openr, v, filename ;END 1------------------------------------------------------;START 2---------COUNT # LINES IN FILE AND NUMBER OF HEADER LINES-----a=' ' K=0 L=0 while ~ EOF(v) do begin readf, v, a k=k+1 endwhile print, 'k=',k close, v free_lun, v ;END 2------------------------------------------------------
© Copyright 2025 Paperzz