;**************************************************************************** ; Author : Josh Grant, COAPS ; ; Description : This program takes the NSCAT dataset grids it and finds the ; monthly averge based on ; the month of each swath. Some of the data files contain ; swaths that are in one month and other swaths in the next ; month. All these exceptions are checked when finding the ; monthly average. Once a month is completed it is output to ; file. ; ; **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 @read_NSCAT_winds.pro PRO WRITENSCATMONTH, grid_u, grid_v, totals, month, year, $ monthlyDirectory, miss 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 ) GT 0 ) THEN BEGIN grid_u( month, lon, lat ) = grid_u( month, lon, lat ) / $ totals( month, lon, lat ) grid_v( month, lon, lat ) = grid_v( month, lon, lat ) / $ totals( month, lon, lat ) ENDIF ELSE BEGIN grid_u( month, lon, lat ) = miss grid_v( month, lon, lat ) = miss ENDELSE ENDFOR ENDFOR OPENW, output, file_name, /GET_LUN FOR lat = 0, 179 DO BEGIN printf, output, FORMAT = '(360F10.3)', grid_u( month, *, lat ) ENDFOR FOR lat = 0, 179 DO BEGIN printf, output, FORMAT = '(360F10.3)', grid_v( month, *, lat ) ENDFOR FREE_LUN, output print, "Finished " + file_name END nscatDirectory = "/Net/NSCAT/nscat/data/nc_W25/" monthlyDirectory = "/Net/NSCAT/people/grant/diverg_proj/grid2div/" + $ "data/winds/monthly/" tempFile = "temp.div" miss = 99999.0 time = LONG(miss) lat = miss lon = miss dir = miss spd = miss grid_u = FLTARR( 12, 360, 180 ) grid_v = FLTARR( 12, 360, 180 ) totals = FLTARR( 12, 360, 180 ) ny = 0 nx = 0 grid_u( *, *, * ) = 0.0 grid_v( *, *, * ) = 0.0 totals( *, *, * ) = 0.0 previousMonth = 9 start = 259 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 = nscatDirectory + "NSCAT." + STRTRIM( year, 1 ) + $ STRING( number, format = stringFormat ) + ".nc" error = read_NSCAT_winds( file_name, miss, time, lat, lon, $ dir, spd, nx, ny ) 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 ( spd( col, row ) NE miss AND $ dir( col, row ) NE miss ) THEN BEGIN grid_lat = FIX( lat( col, row ) + 90.5 ) grid_lon = FIX( lon( 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 rad = ( ACOS( -1 ) ) / 180.0 u = COS( ( 270.0 - dir( col, row ) ) * rad ) * spd( col, row ) v = SIN( ( 270.0 - dir( col, row ) ) * rad ) * spd( col, row ) grid_u( ptmonth - 1, grid_lon, grid_lat ) = $ grid_u( ptmonth - 1, grid_lon, grid_lat ) + u grid_v( ptmonth - 1, grid_lon, grid_lat ) = $ grid_v( ptmonth - 1, grid_lon, grid_lat ) + v totals( ptmonth - 1, grid_lon, grid_lat ) = $ totals( ptmonth - 1, grid_lon, grid_lat ) + 1.0 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 BEGIN filemonth = 11 & ptyear = year - 1 ENDIF ELSE BEGIN filemonth = filemonth - 2 ENDELSE WRITENSCATMONTH, grid_u, grid_v, totals, filemonth, $ ptyear, monthlyDirectory, miss ENDIF ENDIF ENDFOR ENDFOR WRITENSCATMONTH, grid_u, grid_v, totals, 5, 1997, monthlyDirectory, miss END