;**************************************************************************** ; Author : Josh Grant, COAPS ; ; Description : This program takes a divergence file which is in the format ; previously specified for this project and grids it based on ; the month of the swath. Each monthly value is then used to ; calculate the monthly average of each month in the NSCAT ; mission. ; ; **Warning** : Due to poor planning on my part and lack of time the bulk of ; this program is not commented like it should be. ;**************************************************************************** ;@/usr/people/whalley/lidl/jday2date.pro PRO WRITEMONTH, grid, totals, month, year, monthlyDirectory stringFormat = STRCOMPRESS( '(i' + STRING( 2 ) + '.' $ + STRING( 2 ) + ')', /REMOVE_ALL ) file_name = monthlyDirectory + STRTRIM( year, 1 ) + $ STRING( month + 1, format = stringFormat ) + ".monavg" FOR lon = 0, 359 DO BEGIN FOR lat = 0, 179 DO BEGIN IF ( totals( month, lon, lat ) NE 0 ) THEN BEGIN grid( month, lon, lat ) = grid( month, lon, lat ) / $ totals( month, lon, lat ) ENDIF ENDFOR ENDFOR OPENW, output, file_name, /GET_LUN FOR lat = 0, 179 DO BEGIN printf, output, FORMAT = '(360F10.3)', grid( month, *, lat ) ENDFOR FREE_LUN, output print, "Finished " + file_name END base = "/Net/NSCAT/people/grant/diverg_proj/" swathsDirectory = base + "div2grid/data/daily_swath/" monthlyDirectory = base + "div2grid/data/gridded/monthly/" tempFile = "temp.div" miss = 99999.0 time = LON64ARR( 18000 ) data = FLTARR( 3, 48, 18000 ) grid = FLTARR( 12, 360, 180 ) totals = FLTARR( 12, 360, 180 ) ny = 0 nx = 0 previousMonth = 9 grid( *, *, * ) = miss totals( *, *, * ) = 0.0 start = 336 endday = 366 FOR year = 1996, 1997 DO BEGIN IF ( year EQ 1997 ) THEN BEGIN start = 1 endday = 180 ENDIF FOR number = start, endday DO BEGIN stringFormat = STRCOMPRESS( '(i' + STRING( 3 ) + '.' $ + STRING( 3 ) + ')', /REMOVE_ALL ) file_name = swathsDirectory + STRTRIM( year, 1 ) + $ STRING( number, format = stringFormat ) + '.div.gz' READFILE, file_name, tempFile, data, time, ny, nx, error IF ( error EQ 0 ) THEN BEGIN check = 0 min2date, time( 0 ), ptyear, ptmonth1, ptday, pthour, ptmin min2date, time( ny - 1 ), ptyear, ptmonth2, ptday, pthour, ptmin IF ( ptmonth1 NE ptmonth2 ) THEN check = 1 ELSE ptmonth = ptmonth1 FOR col = 0, nx - 1 DO BEGIN FOR row = 0, ny - 1 DO BEGIN IF ( data( 2, col, row ) NE miss ) THEN BEGIN grid_lat = FIX( data( 0, col, row ) + 90.5 ) grid_lon = FIX( data( 1, col, row ) + 0.5 ) IF ( check EQ 1 ) THEN BEGIN min2date, time( row ), ptyear, ptmonth, ptday, pthour, ptmin ENDIF IF ( grid_lon GT 359 ) THEN grid_lon = 359 IF ( grid_lat GT 179 ) THEN grid_lat = 179 IF ( grid( ptmonth - 1, grid_lon, grid_lat ) EQ miss ) THEN BEGIN grid( ptmonth - 1, grid_lon, grid_lat ) = data( 2, col, row ) totals( ptmonth - 1, grid_lon, grid_lat ) = 1.0 ENDIF ELSE BEGIN grid( ptmonth - 1, grid_lon, grid_lat ) = $ grid( ptmonth - 1, grid_lon, grid_lat ) + data( 2, col, row ) totals( ptmonth - 1, grid_lon, grid_lat ) = $ totals( ptmonth - 1, grid_lon, grid_lat ) + 1.0 ENDELSE ENDIF ENDFOR ENDFOR print, "Finished " + file_name ENDIF IF ( number NE 259 AND number NE 180 ) THEN BEGIN JDAY2DATE, number, filemonth, fileday, year IF ( fileday EQ 3 ) THEN BEGIN ptyear = year IF ( filemonth EQ 1 ) THEN filemonth = 11 & ptyear = year - 1 $ ELSE filemonth = filemonth - 2 WRITEMONTH, grid, totals, filemonth, ptyear, monthlyDirectory ENDIF ENDIF ENDFOR ENDFOR WRITEMONTH, grid, totals, 5, 1997, monthlyDirectory END