; idl program: 'read_data_spreadsheet.pro' ; ; TASK: ; To read long-term averaged monthly AVHRR aerosol optical thickness data ; in a binary file (e.g., 'aot_ltmave_002_patmosx.bin' and output in a ; spreadsheet file (e.g., 'aot_ltmave_002_patmosx_out.dat'). ; ; INPUT DATA DESCRIPTION: ; 1)The input monthly averaged data is averaged for 29-years (1981-2009) for ; each month. For example, averaged January value is obtained by averaging ; 29 January values. First data record is January, 2nd is February, and last ; is December. ; 2)Each monthly data record is on a 2-dimensional 0.1 degree grid ; with dimension (3601x1801). The center of the first grid box is ; (-180.0E,90.0S) with grid indices increasing eastwards and northwards. ; 3)Both input and output long-term monthly averaged files are in binary ; format and they can be plotted by either GRADS or IDL. ; 4)The valid data value is between 0.0 and 99.0 and the missing data is ; filled with -999.0 ; ; COMPILE: .r read_data_spreadsheet ; ; EXECUTION: read_data_spreadsheet pro read_data_spreadsheet ;define dimensions ;X dimension of data nx=3601 ;Y dimension of data ny=1801 ;Z dimension of data (12 months) nz=12 ;filled value undef=-999.0 data=fltarr(nx,ny,nz) mx=nx-1 my=ny-1 ; iys,iye = starting and ending year (4-digit); not used now. iys=1981 iye=2009 ; inputdir_noyr: input directory without the year information (include machine) ; outdir: output directory (include machine) inputdir_noyr='/net/eyewall/san2/xpz/pchan/aero_cdr2/monthly/ltmave/' outdir='/net/eyewall/san2/xpz/pchan/aero_cdr2/monthly/ltmave/' ; casenum= case number, e.g., '001', '002',..... casenum='002' ; fnhead = front part of filename of input binary files before the case number fnhead='aot_ltmave_' ; fnmiddle = middle part of filename of input binary files between the case number and year fnmiddle='_patmosx' ; fntail = end part of filename of input binary files fntail='.bin' ;Input file fnin= inputdir_noyr + '/' + fnhead + casenum + fnmiddle + fntail ;Check if input file is existing iexist = file_test(fnin) if (iexist eq 1) then begin print, 'fnin= ', fnin ; Read input data openr, 4, fnin readu, 4, data close, 4 endif else begin print, "No input file exist, Check!!" endelse ;Define output file fname_output = outdir + '/' + fnhead + casenum + fnmiddle + '_out.dat' ;Sampling the "data" from lonitude index 600 to 609, latitude index ;from 900 to 904, and month 3 (April-arry index start from 0 in IDL) ;to form a "subdata". "data" is in 3-dimension: 3601x1601x12 while ;"subdata" is in 2-dimension: 10x5 subdata = data [600:609, 900:904, 3] help, subdata ;Ouput "subdata" in spreadsheet format openw, lun, fname_output, /Get_lun dataformat='(5(1X,F8.2))' printF, lun, subdata(*,*,*), format=dataformat Free_lun, lun end