; ; NAME: read_grid_cs ; ; PURPOSE: Function that reads the Pathfinder grid files created by script ; HIRS_GRID_CS and returns data array. ; ; INPUTS: ; satnum -> Satellite number (string) ; year -> two digit year (string) ; ttype -> Time type string (ex. 'M10','P54','D005') ; stype -> Statistic type string ('MN','SD','CT') ; res -> Resolution of grid (ex. 1.0,2.0,2.5) ; ; INPUT KEYWORDS: ; dpath -> Specify data path of grid data ; ver2 -> Set for version 2 grid data ; OUTPUTS: ; Returns 3 dimensional float array (nlon,nlat,nchn) ; Returns -1 if file does not exist. ; RESTRICTIONS: ; Not specifying ver2 assumes reading ver1 pathfinder grid data. ; These data span 70N-70S and latitude array size fits this domain. ; Ver2 data span all latitudes. ; ; HISTORY: ; Darren Jackson ETL/NOAA March 2002 ;------------------------------------------------------------------------------ ; FUNCTION read_grid_cs, satnum, year, ttype, stype, res, dpath=dpath, ver2=ver2 ; ; Character string for resolution type ; cres = strtrim(string(fix(res*10)),2) ; ; Construct data path ; t1type=strmid(ttype,0,1) IF(not KEYWORD_SET(dpath)) THEN BEGIN IF(KEYWORD_SET(ver2)) THEN BEGIN CASE t1type OF 'D' : d1path = '/data/dlj/tovs1b/pathfinder2/hirs_grid/daily/' 'P' : d1path = '/data/dlj/tovs1b/pathfinder2/hirs_grid/pentad/' 'M' : d1path = '/data/dlj/tovs1b/pathfinder2/hirs_grid/month/' ENDCASE ENDIF ELSE BEGIN CASE t1type OF 'D' : d1path = '/data/dlj/tovs1b/pathfinder/hirs_grid/daily/' 'P' : d1path = '/data/dlj/tovs1b/pathfinder/hirs_grid/pentad/' 'M' : d1path = '/data/dlj/tovs1b/pathfinder/hirs_grid/month/' ENDCASE ENDELSE ENDIF IF(KEYWORD_SET(ver2)) THEN fname = 'HIRS.N'+satnum+'.Y'+year+'.'+ttype+'.R'+cres+'.CS.'+stype $ ELSE fname = 'HIRS.N'+satnum+'.Y'+year+'.'+ttype+'.R'+cres+'.'+stype IF(KEYWORD_SET(dpath)) THEN BEGIN fpath = dpath+fname ENDIF ELSE BEGIN CASE stype OF 'MN' : fpath = d1path+'mean/'+fname 'SD' : fpath = d1path+'std/'+fname 'CT' : fpath = d1path+'count/'+fname ENDCASE ENDELSE ; ; Establish array size of grid file ; nlon = 360/res nchn = 20 IF(KEYWORD_SET(ver2)) THEN nlat = 180/res ELSE nlat= 140/res a=intarr(nlon,nlat,nchn) ; ; Open and read grid file ; result = FILE_TEST(fpath,/read) IF(result eq 1) THEN BEGIN OPENR,inlun,fpath,/get_lun READU,inlun,a FREE_LUN,inlun ENDIF ELSE BEGIN grid = -1 RETURN, grid ENDELSE ; ; Convert to float values ; grid=fltarr(nlon,nlat,nchn) CASE stype OF 'MN' : grid = a / 100. + 100. 'SD' : grid = a / 100. 'CT' : grid = a * 1. ENDCASE RETURN, grid END