;-------------------------------------------------------------------------------------- ;Title: readtbir.pro ; ;Purpose: Read the AERI netCDF files. ; ;Input: arg - a string filename argument for the desired file to read. ; ;Output: atime - time [decimal hours] ; tbirc - IR brightness temperature [C] ; tsurf - Ambient surface temperature [C] ;Keyword: ajtime - optional variable containing time in decimal Julian day. ; no_nan - if set then bad data is not set to NaN, but instead left as is. ; file - set to an exact filename if only one file is to be read. ; platform - string variable set to the platform (i.e. nsaaerich1C1.a1) ; ;Note: RULE: if hatch NOT OPEN then tbirc=NaN ; if tsurf < 100K then NaN ; ;I/O format: readtbir,farg,atime,tbirc,tsurf,AJTIME=ajtime ; ;Author: Matthew Shupe ;Date: 3/07/00 ;-------------------------------------------------------------------------------------- function bright,nu,rad ;Function to calculate the brightness temperature [in C] ; at the given frequency [in cm-1] and measured ; radiance [in mW / m2 sr cm-1]. ;------------------------------------------------------- h=6.62e-34 c=2.9979e+8 bz=1.383e-23 T=(h*c*nu*100)/(bz*alog((2*h*c^2*nu^3*1e11/rad)+1))-273.16 return,T end ;func pro readtbir,arg,atime,tbirc,tsurf,AJTIME=ajtime,NO_NAN=no_nan,FILE=file,PLATFORM=platform ;Get the file(s) for the given "arg" date ;----------------------------------------- if not(keyword_set(FILE)) then begin farg='*aeri*'+arg+'*.cdf*' file=findfile(farg,count=nfil) endif else nfil=1 if nfil eq 0 then begin atime=-1 platform='' return endif ;Read in all data for "arg" ;--------------------------- platform=strmid(file[0],0,strpos(file[0],'.'+arg)) 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,'Time') ne -1 then ncdf_varget,fid,ncdf_varid(fid,'Time'),at else ncdf_varget,fid,ncdf_varid(fid,'Time_UTC_hours'),at ncdf_varget,fid,ncdf_varid(fid,'JulianDay'),ajt ncdf_varget,fid,ncdf_varid(fid,'outsideAirTemp'),ts ncdf_varget,fid,ncdf_varid(fid,'wnum'),wnum ncdf_varget,fid,ncdf_varid(fid,'mean_rad'),mean_rad ncdf_varget,fid,ncdf_varid(fid,'hatchOpen'),ha ncdf_close,fid ;Calculate the brightness temperature from a 25cm-1 window surrounding 900cm-1 ;------------------------------------------------------------------------------ if n_elements(size(wnum,/dim)) eq 2 then restore,'wnum.dat' nel=n_elements(at) tb=fltarr(nel) iwh=where(wnum gt 887.5 and wnum le 912.5) for j=0,nel-1 do tb[j]=bright(900.169,mean(mean_rad[iwh,j])) if i eq 0 then begin atime=at ajtime=ajt tsurf=ts hatch=ha tbirc=tb endif else begin atime=[atime,at] ajtime=[ajtime,ajt] tsurf=[tsurf,ts] hatch=[hatch,ha] tbirc=[tbirc,tb] endelse endfor ;Flag any bad data with -999 or NaN ; Consider bad data as when "hatch" ne 1 or -3 ;----------------------------------------------------- iwh=where(hatch ne 1 and hatch ne -3) if keyword_set(NO_NAN) then begin if iwh[0] ne -1 then tbirc[iwh]=-999. endif else begin if iwh[0] ne -1 then tbirc[iwh]=!values.f_nan iwh=where(tsurf lt 100) if iwh[0] ne -1 then tsurf[iwh]=!values.f_nan endelse tsurf=tsurf-273.16 end