pro readgndrad,arg,gtime,swu,lwu,GJTIME=gjtime,NO_NAN=no_nan,FILE=file,PLATFORM=platform,TIRS=tirs ;---------------------------------------------------------------------- ;Title: readgndrad.pro ; ;Purpose: Read the NSA ground radiation (gndrad) netCDF files. ; ;Input: arg: a string filename argument for the desired file to read. ; ;Output: gtime: time [decimal hours] ; swu: upwelling SW hemispheric irradiance [W/m2] ; lwu: upwelling LW hemispheric irradiance [W/m2] ;Keywords: gjtime: optional variable for outputed decimal Julian day time ; nonan: if set then instead of filling bad data with NaN, the data are left as is. ; file: set to an exact filename if only one file is to be read. ; platform: string variable containing the platform (i.e. nsagndrad60sC1.b1) ; tirs: surface IR temperature [C] ; ;Note: RULES: if swu < -20 W/m2 then NaN ; if lwu < -20 W/m2 then NaN ; if tirs < -100 C then NaN ; ;I/O format: readgndrad,farg,gtime,swu,lwu,GJTIME=gjtime,TIRS=tirs ; ;Author: Matthew Shupe ;Date: 5/29/00 ;Modified: 5/29/00 ;---------------------------------------------------------------------- base_date=julday(1,1,1970,0,0,0) base=jul_to_dt(base_date) !dt_base=base if not(keyword_set(FILE)) then begin farg='nsagndrad*b1.'+arg+'*.cdf' file=findfile(farg,count=nfil) if nfil eq 0 then begin farg='nsagndrad*a1.'+arg+'*.cdf' file=findfile(farg,count=nfil) endif endif else nfil=1 if nfil eq 0 then begin gtime=-1 platform='' return endif platform=strmid(file[0],0,strpos(file[0],'.2')) for i=0,nfil-1 do begin fid=ncdf_open(file[i]) ncdf_varget,fid,ncdf_varid(fid,'base_time'),base_time ncdf_varget,fid,ncdf_varid(fid,'time_offset'),time_offset if ncdf_varid(fid,'up_short_hemisp') ne -1 then begin ncdf_varget,fid,ncdf_varid(fid,'up_short_hemisp'),su ncdf_varget,fid,ncdf_varid(fid,'up_long_hemisp'),lu ncdf_varget,fid,ncdf_varid(fid,'sfc_ir_temp'),irt endif else begin ncdf_varget,fid,ncdf_varid(fid,'psp1_mean'),su ncdf_varget,fid,ncdf_varid(fid,'pir1_mean'),lu ncdf_varget,fid,ncdf_varid(fid,'irt1_mean'),irt endelse ncdf_close,fid ;Create the time axis starttime=sec_to_dt(base_time) ggt=float(starttime.hour+(starttime.minute + (starttime.second+time_offset)/60.)/60.) gjt=float(floor(starttime.julian-julday(1,1,starttime.year,0,0,0)+1))+ggt/24. if n_elements(where(ggt gt 24.0)) gt n_elements(ggt)/2 then ggt=ggt-24. if gjt[0] ge 365 and fix(strmid(arg,4,2)) eq 1 then gjt=gjt-fix(gjt[0])+1.0 if i eq 0 then begin swu=su lwu=lu tirs=irt gtime=ggt gjtime=gjt endif else begin swu=[swu,su] lwu=[lwu,lu] tirs=[tirs,irt] gtime=[gtime,ggt] gjtime=[gjtime,gjt] endelse endfor ;Set all "Missing" or obviously bad data to NaN (swu<0,lwu<0,tirs<-100C) if not(keyword_set(NO_NAN)) then begin iwh=where(swu lt -20) if iwh[0] ne -1 then swu[iwh]=!values.f_nan iwh=where(swu lt 0 and swu ge -20) if iwh[0] ne -1 then swu[iwh]=0 iwh=where(lwu lt -20) if iwh[0] ne -1 then lwu[iwh]=!values.f_nan iwh=where(lwu lt 0 and lwu ge -20) if iwh[0] ne -1 then lwu[iwh]=0 iwh=where(tirs lt -100) if iwh[0] ne -1 then tirs[iwh]=!values.f_nan endif end