pro writeradaravg,arg,AVERAGETIME=averagetime ;---------------------------------------------------------------------- ;---------------------------------------------------------------------- ;Title: writeradaravg.pro ;Purpose: Creates netCDF output file of averaged radar data ; ;I/O format: writeradaravg,arg ; ;Inputs: arg: Date of retrieval argument, "YYYYMMDD" ; ; Keyword: Averagetime: the width of averaging for the radar data (seconds) ; ;Outputs: Convention: platform.date.starttime.cdf ; i.e.: nsammcr60secC1.c1.20000310.000000.cdf ; ;Note: Meaningless fields (i.e. no such retrieval was run) are filled with ; the no data flag of -999. ; ;Author: Matthew Shupe ;Date: 3/7/01 ;Last modified: 4/5/01 ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ;Declare common block variables ;------------------------------- common com_direct common com_platforms common com_radar avdir=radardir+'/averaged' ;Creating netCDF output filename ;------------------------------------------- nbeams=n_elements(time) nheights=n_elements(height) if time[0] lt 10 then shr='0'+strtrim(fix(time[0]),2) else shr=strtrim(fix(time[0]),2) if fix((time[0] mod 1)*60.) lt 10 then smi='0'+strtrim(fix((time[0] mod 1)*60.),2) else smi=strtrim(fix((time[0] mod 1)*60.),2) if fix((((time[0] mod 1)*60.) mod 1)*60.) lt 10 then sse='0'+ strtrim(fix((((time[0] mod 1)*60.) mod 1)*60.),2) else $ sse=strtrim(fix((((time[0] mod 1)*60.) mod 1)*60.),2) timestamp=shr+smi+sse platform=site+'mmcr60secC1.c1' outputfile=platform+'.'+arg+'.'+timestamp+'.cdf' cd, avdir,current=orig_dir print,'WRITING: ',outputfile outfid=NCDF_CREATE(outputfile,/clobber) ;----Define Dimensions---------------------- tdid=NCDF_DIMDEF(outfid,'time',nbeams) hdid=NCDF_DIMDEF(outfid,'height',nheights) ndid=NCDF_DIMDEF(outfid,'numlayers',10) ;----Define Variables----------------------- tid=NCDF_VARDEF(outfid,'time',[tdid],/float) hid=NCDF_VARDEF(outfid,'height',[hdid],/float) rid=NCDF_VARDEF(outfid,'reflectivity',[tdid,hdid],/float) vid=NCDF_VARDEF(outfid,'velocity',[tdid,hdid],/float) wid=NCDF_VARDEF(outfid,'spectralwidth',[tdid,hdid],/float) nid=NCDF_VARDEF(outfid,'signaltonoise',[tdid,hdid],/float) bid=NCDF_VARDEF(outfid,'baseheight',[tdid,ndid],/float) cid=NCDF_VARDEF(outfid,'topheight',[tdid,ndid],/float) ;Define Attributes for the output file ;-------------------------------------- NCDF_ATTPUT,outfid,tid,'long_name','Radar time axis' NCDF_ATTPUT,outfid,tid,'units','Decimal hours' NCDF_ATTPUT,outfid,tid,'comment','May have lower data rate than input radar files due to averaging' NCDF_ATTPUT,outfid,hid,'long_name','Radar 45-m range gate heights' NCDF_ATTPUT,outfid,hid,'units','km' NCDF_ATTPUT,outfid,rid,'long_name','Radar Reflectivity' NCDF_ATTPUT,outfid,rid,'units','dBZ' NCDF_ATTPUT,outfid,rid,'comment','Averaged to # of seconds in global variable: RadarAverageTime' NCDF_ATTPUT,outfid,vid,'long_name','Mean Doppler Velocity' NCDF_ATTPUT,outfid,vid,'units','m/s' NCDF_ATTPUT,outfid,vid,'comment','Averaged to # of seconds in global variable: RadarAverageTime' NCDF_ATTPUT,outfid,wid,'long_name','Spectral Width' NCDF_ATTPUT,outfid,wid,'units','m/s' NCDF_ATTPUT,outfid,wid,'comment','Averaged to # of seconds in global variable: RadarAverageTime' NCDF_ATTPUT,outfid,nid,'long_name','Signal to noise ratio' NCDF_ATTPUT,outfid,nid,'units','dBZ' NCDF_ATTPUT,outfid,nid,'comment','Averaged to # of seconds in global variable: RadarAverageTime' NCDF_ATTPUT,outfid,bid,'long_name','Cloud Base Heights' NCDF_ATTPUT,outfid,bid,'units','km' NCDF_ATTPUT,outfid,bid,'comment','Consistent with the measured radar fields contained in this file' NCDF_ATTPUT,outfid,cid,'long_name','Cloud Top Heights' NCDF_ATTPUT,outfid,cid,'units','km' NCDF_ATTPUT,outfid,cid,'comment','Consistent with the measured radar fields contained in this file' ;Global attributes if not(keyword_set(averagetime)) then averagetime='none' else averagetime=strtrim(averagetime,2) NCDF_ATTPUT,outfid,/global,'Date',systime(0) NCDF_ATTPUT,outfid,/global,'Version','MCRS_1.1' NCDF_ATTPUT,outfid,/global,'Input_Platforms',radarplat NCDF_ATTPUT,outfid,/global,'Retrieval_Platform',platform NCDF_ATTPUT,outfid,/global,'Julian Day',strtrim(fix(jtime[0]),2) NCDF_ATTPUT,outfid,/global,'RadarAverageTime',strtrim(averagetime,2) NCDF_ATTPUT,outfid,/global,'Comment1','When no data are available, corresponding fields are filled with -999.0.' NCDF_ATTPUT,outfid,/global,'Comment2','Time axis is averaged according to user-defined width.' ;----Fill all variables with dummy values------ ;----Close define mode and enter data mode----- NCDF_CONTROL,outfid,/fill NCDF_CONTROL,outfid,/endef ;----Assign data to variables------------------ NCDF_VARPUT,outfid,tid,time NCDF_VARPUT,outfid,hid,height NCDF_VARPUT,outfid,rid,dbz NCDF_VARPUT,outfid,vid,dopp NCDF_VARPUT,outfid,wid,spwd NCDF_VARPUT,outfid,nid,stn NCDF_VARPUT,outfid,bid,bheight NCDF_VARPUT,outfid,cid,theight ;----Close the netCDF file------------------- NCDF_CLOSE,outfid spawn,'chgrp artic *.cdf',junk spawn,'chmod 664 *.cdf',junk cd,orig_dir end