; ; Put the daily averaged files together in one monthly file ; pro put_together, site, year_month ; ; Common containing the data ; common month_data,base_time,time_offset,height,combined_cluttermode,combined_cluttermax,$ combined_cluttermin,combined_clutterall,$ combined_cluttercloudy,combined_cbase,$ combined_cbasepos,combined_cbaseuse,combined_cbasemode,$ combined_cbasemax,combined_cbasemin,combined_ctop,$ combined_ctoppos,combined_ctopuse,combined_ctopmode,$ combined_ctopmax,combined_ctopmin,$ combined_reflectivity,combined_reflectp,$ combined_reflectc,combined_velocity,combined_spectrum,$ combined_sfcpress,combined_temp,$ combined_pressure,combined_numlayers,$ combined_bhl1,combined_bhl2,combined_bhl3,combined_bhl4,combined_bhl5,$ combined_btl1,combined_btl2,combined_btl3,combined_btl4,combined_btl5,$ combined_thl1,combined_thl2,combined_thl3,combined_thl4,combined_thl5,$ combined_ttl1,combined_ttl2,combined_ttl3,combined_ttl4,combined_ttl5,$ combined_bpl1,combined_bpl2,combined_bpl3,combined_bpl4,combined_bpl5,$ combined_tpl1,combined_tpl2,combined_tpl3,combined_tpl4,combined_tpl5,$ combined_liq,combined_vap,combined_down_short,combined_up_short,$ combined_down_long,combined_up_long,combined_twsflux,combined_zenith,$ combined_solarratio,combined_surfacealbedo,combined_first_cbh,$ combined_column_cfrac ; ; Remove white spaces around command line inputs ; site=strcompress(site,/remove_all) year_month=strcompress(string(year_month),/remove_all) ; ; Get the files matching the site, year, month ; filedir='/home/sbenson/Average/Daily/' filename=filedir+site+'.average.1hr.'+year_month+'*cdf' files=findfile(filename,count=numfiles) ; ; Loop through all the files ; for i=0,numfiles-1 do begin ; ; extract the date from the name of the file ; print,files[i] parts=strsplit(files[i],'.',/extract) date=parts[3] year=fix(strmid(date,0,4)) month=fix(strmid(date,4,2)) day=fix(strmid(date,6,2)) print,year,month,day ; ; Open the netcdf file ; cdf_id=ncdf_open(files[i]) ; ; Get the dimension id's ; time_did=ncdf_dimid(cdf_id,'time') height_did=ncdf_dimid(cdf_id,'height') ; ; Get the dimensions ; if time_did ne -1 then ncdf_diminq,cdf_id,time_did,charstring,ntimes $ else ntimes=24. if height_did ne -1 then ncdf_diminq,cdf_id,height_did,charstring,nheights $ else if site eq 'twpc1' then nheights=226.0 $ else if site eq 'twpc2' then nheights=226.0 $ else if site eq 'nsa' then nheights=149.0 ; ; Create array for nodata value ; dummy1d=make_array(ntimes,/float,value=-9999) dummy2d=make_array(ntimes,nheights,/float,value=-9999) ; ; Get the variable id's ; basetime_id=ncdf_varid(cdf_id, 'base_time') timeoffset_id=ncdf_varid(cdf_id, 'time_offset') height_id=ncdf_varid(cdf_id, 'height') cluttermode_id=ncdf_varid(cdf_id,'qc_ReflectivityClutterFlagMode') cluttermax_id=ncdf_varid(cdf_id,'qc_ReflectivityClutterFlagMaxExtreme') cluttermin_id=ncdf_varid(cdf_id,'qc_ReflectivityClutterFlagMinExtreme') clutterall_id=ncdf_varid(cdf_id,'qc_ReflectivityClutterFlagAllPoints') cluttercloudy_id=ncdf_varid(cdf_id,'qc_ReflectivityClutterFlagCloudyPoints') cbase_id=ncdf_varid(cdf_id,'CloudBaseBestEstimate') cbasepos_id=ncdf_varid(cdf_id,'CloudBaseBestEstimatePossiblePoints') cbaseuse_id=ncdf_varid(cdf_id,'CloudBaseBestEstimateUseablePoints') cbasemode_id=ncdf_varid(cdf_id,'CloudBaseBestEstimateMode') cbasemax_id=ncdf_varid(cdf_id,'CloudBaseBestEstimateMaxExtreme') cbasemin_id=ncdf_varid(cdf_id,'CloudBaseBestEstimateMinExtreme') ctop_id=ncdf_varid(cdf_id,'RadarFirstTop') ctoppos_id=ncdf_varid(cdf_id,'RadarFirstTopPossiblePoints') ctopuse_id=ncdf_varid(cdf_id,'RadarFirstTopUseablePoints') ctopmode_id=ncdf_varid(cdf_id,'RadarFirstTopMode') ctopmax_id=ncdf_varid(cdf_id,'RadarFirstTopMaxExtreme') ctopmin_id=ncdf_varid(cdf_id,'RadarFirstTopMinExtreme') reflectivity_id=ncdf_varid(cdf_id, 'ReflectivityBestEstimate') reflectp_id=ncdf_varid(cdf_id,'ReflectivityPossiblePoints') reflectc_id=ncdf_varid(cdf_id,'ReflectivityCloudyPoints') velocity_id=ncdf_varid(cdf_id,'MeanDopplerVelocity') spectrum_id=ncdf_varid(cdf_id,'SpectralWidth') sfcpress_id=ncdf_varid(cdf_id,'sfc_pressure') temp_id=ncdf_varid(cdf_id,'temp') pressure_id=ncdf_varid(cdf_id,'pressure') numlayers_id=ncdf_varid(cdf_id,'number_of_layers') bhl1_id=ncdf_varid(cdf_id,'base_height_layer_1') bhl2_id=ncdf_varid(cdf_id,'base_height_layer_2') bhl3_id=ncdf_varid(cdf_id,'base_height_layer_3') bhl4_id=ncdf_varid(cdf_id,'base_height_layer_4') bhl5_id=ncdf_varid(cdf_id,'base_height_layer_5') btl1_id=ncdf_varid(cdf_id,'base_temp_layer_1') btl2_id=ncdf_varid(cdf_id,'base_temp_layer_2') btl3_id=ncdf_varid(cdf_id,'base_temp_layer_3') btl4_id=ncdf_varid(cdf_id,'base_temp_layer_4') btl5_id=ncdf_varid(cdf_id,'base_temp_layer_5') thl1_id=ncdf_varid(cdf_id,'top_height_layer_1') thl2_id=ncdf_varid(cdf_id,'top_height_layer_2') thl3_id=ncdf_varid(cdf_id,'top_height_layer_3') thl4_id=ncdf_varid(cdf_id,'top_height_layer_4') thl5_id=ncdf_varid(cdf_id,'top_height_layer_5') ttl1_id=ncdf_varid(cdf_id,'top_temp_layer_1') ttl2_id=ncdf_varid(cdf_id,'top_temp_layer_2') ttl3_id=ncdf_varid(cdf_id,'top_temp_layer_3') ttl4_id=ncdf_varid(cdf_id,'top_temp_layer_4') ttl5_id=ncdf_varid(cdf_id,'top_temp_layer_5') bpl1_id=ncdf_varid(cdf_id,'base_press_layer_1') bpl2_id=ncdf_varid(cdf_id,'base_press_layer_2') bpl3_id=ncdf_varid(cdf_id,'base_press_layer_3') bpl4_id=ncdf_varid(cdf_id,'base_press_layer_4') bpl5_id=ncdf_varid(cdf_id,'base_press_layer_5') tpl1_id=ncdf_varid(cdf_id,'top_press_layer_1') tpl2_id=ncdf_varid(cdf_id,'top_press_layer_2') tpl3_id=ncdf_varid(cdf_id,'top_press_layer_3') tpl4_id=ncdf_varid(cdf_id,'top_press_layer_4') tpl5_id=ncdf_varid(cdf_id,'top_press_layer_5') liq_id=ncdf_varid(cdf_id,'liq') vap_id=ncdf_varid(cdf_id,'vap') down_short_id=ncdf_varid(cdf_id,'down_short') up_short_id=ncdf_varid(cdf_id,'up_short') down_long_id=ncdf_varid(cdf_id,'down_long') up_long_id=ncdf_varid(cdf_id,'up_long') twsflux_id=ncdf_varid(cdf_id, 'twsflux_clearskyfit') zenith_id=ncdf_varid(cdf_id,'solar_zenith_angle') solarratio_id=ncdf_varid(cdf_id,'SolarRatio') surfacealbedo_id=ncdf_varid(cdf_id,'SurfaceAlbedo') first_cbh_id=ncdf_varid(cdf_id,'first_cbh') column_cfrac_id=ncdf_varid(cdf_id,'column_cfrac') ; ; Get the variables ; if basetime_id ne -1 then ncdf_varget,cdf_id,basetime_id,base_time $ else begin base_time=num_sec_ep(year,month,day,0,0,0) ;stop endelse if timeoffset_id ne -1 then ncdf_varget,cdf_id,timeoffset_id,time_offset $ else begin time_offset=[ 0, 3600, 7200, 10800, 14400, 18000, 21600, 25200, 28800, $ 32400, 36000, 39600, 43200, 46800, 50400, 54000, 57600, 61200, 64800, $ 68400, 72000, 75600, 79200, 82800 ] ;stop endelse if height_id ne -1 then ncdf_varget,cdf_id,height_id,height $ else begin heightspacing=90.0 startheight=105.0 if site eq 'sgp' then numheights=167 else $ if site eq 'twpc1' then numheights=226 else $ if site eq 'twpc2' then numheights=226 else $ if site eq 'nsa' then numheights=149 k=findgen(numheights) height=startheight+heightspacing*k endelse if cluttermode_id ne -1 then begin ncdf_varget,cdf_id,cluttermode_id,cluttermode cluttermode=transpose(cluttermode) endif else cluttermode=dummy2d if cluttermax_id ne -1 then begin ncdf_varget,cdf_id,cluttermax_id,cluttermax cluttermax=transpose(cluttermax) endif else cluttermax=dummy2d if cluttermin_id ne -1 then begin ncdf_varget,cdf_id,cluttermin_id,cluttermin cluttermin=transpose(cluttermin) endif else cluttermin=dummy2d if clutterall_id ne -1 then begin ncdf_varget,cdf_id,clutterall_id,clutterall clutterall=transpose(clutterall) endif else clutterall=dummy2d if cluttercloudy_id ne -1 then begin ncdf_varget,cdf_id,cluttercloudy_id,cluttercloudy cluttercloudy=transpose(cluttercloudy) endif else cluttercloudy=dummy2d if cbase_id ne -1 then ncdf_varget,cdf_id,cbase_id,cbase $ else cbase=dummy1d if cbasepos_id ne -1 then ncdf_varget,cdf_id,cbasepos_id,cbasepos $ else cbasepos=dummy1d if cbaseuse_id ne -1 then ncdf_varget,cdf_id,cbaseuse_id,cbaseuse $ else cbaseuse=dummy1d if cbasemode_id ne -1 then ncdf_varget,cdf_id,cbasemode_id,cbasemode $ else cbasemode=dummy1d if cbasemax_id ne -1 then ncdf_varget,cdf_id,cbasemax_id,cbasemax $ else cbasemax=dummy1d if cbasemin_id ne -1 then ncdf_varget,cdf_id,cbasemin_id,cbasemin $ else cbasemin=dummy1d if ctop_id ne -1 then ncdf_varget,cdf_id,ctop_id,ctop $ else ctop=dummy1d if ctoppos_id ne -1 then ncdf_varget,cdf_id,ctoppos_id,ctoppos $ else ctoppos=dummy1d if ctopuse_id ne -1 then ncdf_varget,cdf_id,ctopuse_id,ctopuse $ else ctopuse=dummy1d if ctopmode_id ne -1 then ncdf_varget,cdf_id,ctopmode_id,ctopmode $ else ctopmode=dummy1d if ctopmax_id ne -1 then ncdf_varget,cdf_id,ctopmax_id,ctopmax $ else ctopmax=dummy1d if ctopmin_id ne -1 then ncdf_varget,cdf_id,ctopmin_id,ctopmin $ else ctopmin=dummy1d if reflectivity_id ne -1 then begin ncdf_varget,cdf_id,reflectivity_id,reflectivity reflectivity=transpose(reflectivity) endif else reflectivity=dummy2d if reflectp_id ne -1 then begin ncdf_varget,cdf_id,reflectp_id,reflectp reflectp=transpose(reflectp) endif else reflectp=dummy2d if reflectc_id ne -1 then begin ncdf_varget,cdf_id,reflectc_id,reflectc reflectc=transpose(reflectc) endif else reflectc=dummy2d if velocity_id ne -1 then begin ncdf_varget,cdf_id,velocity_id,velocity velocity=transpose(velocity) endif else velocity=dummy2d if spectrum_id ne -1 then begin ncdf_varget,cdf_id,spectrum_id,spectrum spectrum=transpose(spectrum) endif else spectrum=dummy2d if sfcpress_id ne -1 then ncdf_varget,cdf_id,sfcpress_id,sfcpress $ else sfcpress=dummy1d if temp_id ne -1 then begin ncdf_varget,cdf_id,temp_id,temp temp=transpose(temp) endif else temp=dummy2d if pressure_id ne -1 then begin ncdf_varget,cdf_id,pressure_id,pressure pressure=transpose(pressure) endif else pressure=dummy2d if numlayers_id ne -1 then ncdf_varget,cdf_id,numlayers_id,numlayers $ else numlayers=dummy1d if bhl1_id ne -1 then ncdf_varget,cdf_id,bhl1_id,bhl1 else bhl1=dummy1d if bhl2_id ne -1 then ncdf_varget,cdf_id,bhl2_id,bhl2 else bhl2=dummy1d if bhl3_id ne -1 then ncdf_varget,cdf_id,bhl3_id,bhl3 else bhl3=dummy1d if bhl4_id ne -1 then ncdf_varget,cdf_id,bhl4_id,bhl4 else bhl4=dummy1d if bhl5_id ne -1 then ncdf_varget,cdf_id,bhl5_id,bhl5 else bhl5=dummy1d if btl1_id ne -1 then ncdf_varget,cdf_id,btl1_id,btl1 else btl1=dummy1d if btl2_id ne -1 then ncdf_varget,cdf_id,btl2_id,btl2 else btl2=dummy1d if btl3_id ne -1 then ncdf_varget,cdf_id,btl3_id,btl3 else btl3=dummy1d if btl4_id ne -1 then ncdf_varget,cdf_id,btl4_id,btl4 else btl4=dummy1d if btl5_id ne -1 then ncdf_varget,cdf_id,btl5_id,btl5 else btl5=dummy1d if thl1_id ne -1 then ncdf_varget,cdf_id,thl1_id,thl1 else thl1=dummy1d if thl2_id ne -1 then ncdf_varget,cdf_id,thl2_id,thl2 else thl2=dummy1d if thl3_id ne -1 then ncdf_varget,cdf_id,thl3_id,thl3 else thl3=dummy1d if thl4_id ne -1 then ncdf_varget,cdf_id,thl4_id,thl4 else thl4=dummy1d if thl5_id ne -1 then ncdf_varget,cdf_id,thl5_id,thl5 else thl5=dummy1d if ttl1_id ne -1 then ncdf_varget,cdf_id,ttl1_id,ttl1 else ttl1=dummy1d if ttl2_id ne -1 then ncdf_varget,cdf_id,ttl2_id,ttl2 else ttl2=dummy1d if ttl3_id ne -1 then ncdf_varget,cdf_id,ttl3_id,ttl3 else ttl3=dummy1d if ttl4_id ne -1 then ncdf_varget,cdf_id,ttl4_id,ttl4 else ttl4=dummy1d if ttl5_id ne -1 then ncdf_varget,cdf_id,ttl5_id,ttl5 else ttl5=dummy1d if bpl1_id ne -1 then ncdf_varget,cdf_id,bpl1_id,bpl1 else bpl1=dummy1d if bpl2_id ne -1 then ncdf_varget,cdf_id,bpl2_id,bpl2 else bpl2=dummy1d if bpl3_id ne -1 then ncdf_varget,cdf_id,bpl3_id,bpl3 else bpl3=dummy1d if bpl4_id ne -1 then ncdf_varget,cdf_id,bpl4_id,bpl4 else bpl4=dummy1d if bpl5_id ne -1 then ncdf_varget,cdf_id,bpl5_id,bpl5 else bpl5=dummy1d if tpl1_id ne -1 then ncdf_varget,cdf_id,tpl1_id,tpl1 else tpl1=dummy1d if tpl2_id ne -1 then ncdf_varget,cdf_id,tpl2_id,tpl2 else tpl2=dummy1d if tpl3_id ne -1 then ncdf_varget,cdf_id,tpl3_id,tpl3 else tpl3=dummy1d if tpl4_id ne -1 then ncdf_varget,cdf_id,tpl4_id,tpl4 else tpl4=dummy1d if tpl5_id ne -1 then ncdf_varget,cdf_id,tpl5_id,tpl5 else tpl5=dummy1d if liq_id ne -1 then ncdf_varget,cdf_id,liq_id,liq else liq=dummy1d if vap_id ne -1 then ncdf_varget,cdf_id,vap_id,vap else vap=dummy1d if down_short_id ne -1 then ncdf_varget,cdf_id,down_short_id,down_short $ else down_short=dummy1d if up_short_id ne -1 then ncdf_varget,cdf_id,up_short_id,up_short $ else up_short=dummy1d if down_long_id ne -1 then ncdf_varget,cdf_id,down_long_id,down_long $ else down_long=dummy1d if up_long_id ne -1 then ncdf_varget,cdf_id,up_long_id,up_long $ else up_long=dummy1d if twsflux_id ne -1 then ncdf_varget,cdf_id,twsflux_id,twsflux $ else twsflux=dummy1d if zenith_id ne -1 then ncdf_varget,cdf_id,zenith_id,zenith $ else zenith=dummy1d if solarratio_id ne -1 then ncdf_varget,cdf_id,solarratio_id,solarratio $ else solarratio=dummy1d if surfacealbedo_id ne -1 then ncdf_varget,cdf_id,surfacealbedo_id,surfacealbedo $ else surfacealbedo=dummy1d if first_cbh_id ne -1 then ncdf_varget,cdf_id,first_cbh_id,first_cbh $ else first_cbh=dummy1d if column_cfrac_id ne -1 then ncdf_varget,cdf_id,column_cfrac_id,column_cfrac $ else column_cfrac=dummy1d ; ; Close the netcdf file ; ncdf_close,cdf_id ; ; Combine the arrays ; if i eq 0 then begin combined_btto=long(base_time)+long(time_offset) combined_cluttermode=cluttermode combined_cluttermax=cluttermax combined_cluttermin=cluttermin combined_clutterall=clutterall combined_cluttercloudy=cluttercloudy combined_cbase=cbase combined_cbasepos=cbasepos combined_cbaseuse=cbaseuse combined_cbasemode=cbasemode combined_cbasemax=cbasemax combined_cbasemin=cbasemin combined_ctop=ctop combined_ctoppos=ctoppos combined_ctopuse=ctopuse combined_ctopmode=ctopmode combined_ctopmax=ctopmax combined_ctopmin=ctopmin combined_reflectivity=reflectivity combined_reflectp=reflectp combined_reflectc=reflectc combined_velocity=velocity combined_spectrum=spectrum combined_sfcpress=sfcpress combined_temp=temp combined_pressure=pressure combined_numlayers=numlayers combined_bhl1=bhl1 combined_bhl2=bhl2 combined_bhl3=bhl3 combined_bhl4=bhl4 combined_bhl5=bhl5 combined_btl1=btl1 combined_btl2=btl2 combined_btl3=btl3 combined_btl4=btl4 combined_btl5=btl5 combined_thl1=thl1 combined_thl2=thl2 combined_thl3=thl3 combined_thl4=thl4 combined_thl5=thl5 combined_ttl1=ttl1 combined_ttl2=ttl2 combined_ttl3=ttl3 combined_ttl4=ttl4 combined_ttl5=ttl5 combined_bpl1=bpl1 combined_bpl2=bpl2 combined_bpl3=bpl3 combined_bpl4=bpl4 combined_bpl5=bpl5 combined_tpl1=tpl1 combined_tpl2=tpl2 combined_tpl3=tpl3 combined_tpl4=tpl4 combined_tpl5=tpl5 combined_liq=liq combined_vap=vap combined_down_short=down_short combined_up_short=up_short combined_down_long=down_long combined_up_long=up_long combined_twsflux=twsflux combined_zenith=zenith combined_solarratio=solarratio combined_surfacealbedo=surfacealbedo combined_first_cbh=first_cbh combined_column_cfrac=column_cfrac endif else begin combined_btto=[long(combined_btto),long(base_time)+long(time_offset)] combined_cluttermode=[combined_cluttermode,cluttermode] combined_cluttermax=[combined_cluttermax,cluttermax] combined_cluttermin=[combined_cluttermin,cluttermin] combined_clutterall=[combined_clutterall,clutterall] combined_cluttercloudy=[combined_cluttercloudy,cluttercloudy] combined_cbase=[combined_cbase,cbase] combined_cbasepos=[combined_cbasepos,cbasepos] combined_cbaseuse=[combined_cbaseuse,cbaseuse] combined_cbasemode=[combined_cbasemode,cbasemode] combined_cbasemax=[combined_cbasemax,cbasemax] combined_cbasemin=[combined_cbasemin,cbasemin] combined_ctop=[combined_ctop,ctop] combined_ctoppos=[combined_ctoppos,ctoppos] combined_ctopuse=[combined_ctopuse,ctopuse] combined_ctopmode=[combined_ctopmode,ctopmode] combined_ctopmax=[combined_ctopmax,ctopmax] combined_ctopmin=[combined_ctopmin,ctopmin] combined_reflectivity=[combined_reflectivity,reflectivity] combined_reflectp=[combined_reflectp,reflectp] combined_reflectc=[combined_reflectc,reflectc] combined_velocity=[combined_velocity,velocity] combined_spectrum=[combined_spectrum,spectrum] combined_sfcpress=[combined_sfcpress,sfcpress] combined_temp=[combined_temp,temp] combined_pressure=[combined_pressure,pressure] combined_numlayers=[combined_numlayers,numlayers] combined_bhl1=[combined_bhl1,bhl1] combined_bhl2=[combined_bhl2,bhl2] combined_bhl3=[combined_bhl3,bhl3] combined_bhl4=[combined_bhl4,bhl4] combined_bhl5=[combined_bhl5,bhl5] combined_btl1=[combined_btl1,btl1] combined_btl2=[combined_btl2,btl2] combined_btl3=[combined_btl3,btl3] combined_btl4=[combined_btl4,btl4] combined_btl5=[combined_btl5,btl5] combined_thl1=[combined_thl1,thl1] combined_thl2=[combined_thl2,thl2] combined_thl3=[combined_thl3,thl3] combined_thl4=[combined_thl4,thl4] combined_thl5=[combined_thl5,thl5] combined_ttl1=[combined_ttl1,ttl1] combined_ttl2=[combined_ttl2,ttl2] combined_ttl3=[combined_ttl3,ttl3] combined_ttl4=[combined_ttl4,ttl4] combined_ttl5=[combined_ttl5,ttl5] combined_bpl1=[combined_bpl1,bpl1] combined_bpl2=[combined_bpl2,bpl2] combined_bpl3=[combined_bpl3,bpl3] combined_bpl4=[combined_bpl4,bpl4] combined_bpl5=[combined_bpl5,bpl5] combined_tpl1=[combined_tpl1,tpl1] combined_tpl2=[combined_tpl2,tpl2] combined_tpl3=[combined_tpl3,tpl3] combined_tpl4=[combined_tpl4,tpl4] combined_tpl5=[combined_tpl5,tpl5] combined_liq=[combined_liq,liq] combined_vap=[combined_vap,vap] combined_down_short=[combined_down_short,down_short] combined_up_short=[combined_up_short,up_short] combined_down_long=[combined_down_long,down_long] combined_up_long=[combined_up_long,up_long] combined_twsflux=[combined_twsflux,twsflux] combined_zenith=[combined_zenith,zenith] combined_solarratio=[combined_solarratio,solarratio] combined_surfacealbedo=[combined_surfacealbedo,surfacealbedo] combined_first_cbh=[combined_first_cbh,first_cbh] combined_column_cfrac=[combined_column_cfrac,column_cfrac] endelse endfor ; ; create the new data arrays ; base_time=long(combined_btto[0]) ;base time time_offset=long(combined_btto)-long(base_time) ;time offset array ntimes=n_elements(time_offset) ;number of datapoints nheights=n_elements(height) ;number of heights ;************************************ ; Put the data into one monthly file ;************************************ ; ; Create the monthly file and put in define mode ; filedir='/home/sbenson/Average/Hourly/' monthfile=filedir+site+'.average.1hr.'+year_month+'.cdf' month_id=ncdf_create(monthfile,/clobber) ; ; Put the netcdf file into define mode ; ;ncdf_control,month_id,/redef ; ; Define dimensions ; time_id=ncdf_dimdef(month_id,'time',/unlimited) height_id=ncdf_dimdef(month_id,'height',nheights) ; ; Create array of dimensions for 2d variables ; datadim=intarr(2) datadim[1]=time_id datadim[0]=height_id ; ; Define variables and attributes ; dataname=['base_time','time_offset','height','qc_ReflectivityClutterFlagMode',$ 'qc_ReflectivityClutterFlagMaxExtreme','qc_ReflectivityClutterFlagMinExtreme',$ 'qc_ReflectivityClutterFlagAllPoints','qc_ReflectivityClutterFlagCloudyPoints',$ 'CloudBaseBestEstimate','CloudBaseBestEstimatePossiblePoints',$ 'CloudBaseBestEstimateUseablePoints','CloudBaseBestEstimateMode',$ 'CloudBaseBestEstimateMaxExtreme','CloudBaseBestEstimateMinExtreme',$ 'RadarFirstTop','RadarFirstTopPossiblePoints','RadarFirstTopUseablePoints',$ 'RadarFirstTopMode','RadarFirstTopMaxExtreme','RadarFirstTopMinExtreme',$ 'ReflectivityBestEstimate','ReflectivityPossiblePoints',$ 'ReflectivityCloudyPoints','MeanDopplerVelocity','SpectralWidth','sfc_pressure',$ 'temp','pressure','number_of_layers','base_height_layer_1','base_height_layer_2',$ 'base_height_layer_3','base_height_layer_4','base_height_layer_5',$ 'base_temp_layer_1','base_temp_layer_2','base_temp_layer_3','base_temp_layer_4',$ 'base_temp_layer_5','top_height_layer_1','top_height_layer_2','top_height_layer_3',$ 'top_height_layer_4','top_height_layer_5','top_temp_layer_1','top_temp_layer_2',$ 'top_temp_layer_3','top_temp_layer_4','top_temp_layer_5','base_press_layer_1',$ 'base_press_layer_2','base_press_layer_3','base_press_layer_4',$ 'base_press_layer_5','top_press_layer_1','top_press_layer_2','top_press_layer_3',$ 'top_press_layer_4','top_press_layer_5','liq','vap','down_short','up_short',$ 'down_long','up_long','twsflux_clearskyfit','solar_zenith_angle','SolarRatio',$ 'SurfaceAlbedo','first_cbh','column_cfrac'] datadims =['time_id','time_id','height_id','datadim','datadim','datadim','datadim','datadim',$ 'time_id','time_id','time_id','time_id','time_id','time_id','time_id','time_id',$ 'time_id','time_id','time_id','time_id','datadim','datadim','datadim','datadim',$ 'datadim','time_id','datadim','datadim','time_id','time_id','time_id','time_id',$ 'time_id','time_id','time_id','time_id','time_id','time_id','time_id','time_id',$ 'time_id','time_id','time_id','time_id','time_id','time_id','time_id','time_id',$ 'time_id','time_id','time_id','time_id','time_id','time_id','time_id','time_id',$ 'time_id','time_id','time_id','time_id','time_id','time_id','time_id','time_id',$ 'time_id','time_id','time_id','time_id','time_id','time_id','time_id'] datatype=['long','double','float','short','short','short','short','short','float','short','short',$ 'float','float','float','float','short','short','float','float','float','float','short',$ 'float','float','float','float','float','float','short','float','float','float','float',$ 'float','float','float','float','float','float','float','float','float','float','float',$ 'float','float','float','float','float','float','float','float','float','float','float',$ 'float','float','float','float','float','float','float','float','float','float','float',$ 'float','float','float','float','float'] for j=0,n_elements(dataname)-1 do begin print,dataname[j] if j eq 0 then begin data_month_id=ncdf_vardef(month_id,dataname[j],/long) endif else if datatype[j] eq 'long' then begin if datadims[j] eq 'time_id' then data_month_id=ncdf_vardef(month_id,dataname[j],time_id,/long) $ else if datadims[j] eq 'datadim' then data_month_id=ncdf_vardef(month_id,dataname[j],datadim,/long) $ else if datadims[j] eq 'height_id' then data_month_id=ncdf_vardef(month_id,dataname[j],height_id,/long) endif else if datatype[j] eq 'double' then begin if datadims[j] eq 'time_id' then data_month_id=ncdf_vardef(month_id,dataname[j],time_id,/double) $ else if datadims[j] eq 'datadim' then data_month_id=ncdf_vardef(month_id,dataname[j],datadim,/double) $ else if datadims[j] eq 'height_id' then data_month_id=ncdf_vardef(month_id,dataname[j],height_id,/double) endif else if datatype[j] eq 'float' then begin if datadims[j] eq 'time_id' then data_month_id=ncdf_vardef(month_id,dataname[j],time_id,/float) $ else if datadims[j] eq 'datadim' then data_month_id=ncdf_vardef(month_id,dataname[j],datadim,/float) $ else if datadims[j] eq 'height_id' then data_month_id=ncdf_vardef(month_id,dataname[j],height_id,/float) endif else if datatype[j] eq 'short' then begin if datadims[j] eq 'time_id' then data_month_id=ncdf_vardef(month_id,dataname[j],time_id,/short) $ else if datadims[j] eq 'datadim' then data_month_id=ncdf_vardef(month_id,dataname[j],datadim,/short) $ else if datadims[j] eq 'height_id' then data_month_id=ncdf_vardef(month_id,dataname[j],height_id,/short) endif for i=0,numfiles-1 do begin cdf_id=ncdf_open(files[i]) data_id=ncdf_varid(cdf_id,dataname[j]) if data_id ne -1 then goto, found_var ncdf_close,cdf_id endfor if data_id eq -1 then goto, no_atts found_var: ;skip out of loop because we found one datainfo=ncdf_varinq(cdf_id,data_id) numatts=datainfo.natts for k=0,numatts-1 do begin attname=ncdf_attname(cdf_id,data_id,k) mytry=ncdf_attcopy(cdf_id,data_id,attname,month_id,data_month_id) endfor ncdf_close,cdf_id no_atts: ;skip to here if there is no variable to provide attributes ncdf_control,month_id,/endef get_data_array,j,data if datadims[j] eq 'datadim' then data=transpose(data) ncdf_varput,month_id,data_month_id,data ncdf_control,month_id,/redef endfor ; ; Close the netcdf file ; ncdf_close,month_id end ;**************************************** ; Suboutine to pick out the data array ;**************************************** pro get_data_array,j,data common month_data,base_time,time_offset,height,combined_cluttermode,combined_cluttermax,$ combined_cluttermin,combined_clutterall,$ combined_cluttercloudy,combined_cbase,$ combined_cbasepos,combined_cbaseuse,combined_cbasemode,$ combined_cbasemax,combined_cbasemin,combined_ctop,$ combined_ctoppos,combined_ctopuse,combined_ctopmode,$ combined_ctopmax,combined_ctopmin,$ combined_reflectivity,combined_reflectp,$ combined_reflectc,combined_velocity,combined_spectrum,$ combined_sfcpress,combined_temp,$ combined_pressure,combined_numlayers,$ combined_bhl1,combined_bhl2,combined_bhl3,combined_bhl4,combined_bhl5,$ combined_btl1,combined_btl2,combined_btl3,combined_btl4,combined_btl5,$ combined_thl1,combined_thl2,combined_thl3,combined_thl4,combined_thl5,$ combined_ttl1,combined_ttl2,combined_ttl3,combined_ttl4,combined_ttl5,$ combined_bpl1,combined_bpl2,combined_bpl3,combined_bpl4,combined_bpl5,$ combined_tpl1,combined_tpl2,combined_tpl3,combined_tpl4,combined_tpl5,$ combined_liq,combined_vap,combined_down_short,combined_up_short,$ combined_down_long,combined_up_long,combined_twsflux,combined_zenith,$ combined_solarratio,combined_surfacealbedo,combined_first_cbh,$ combined_column_cfrac if j eq 0 then data=base_time $ else if j eq 1 then data=time_offset $ else if j eq 2 then data=height $ else if j eq 3 then data=combined_cluttermode $ else if j eq 4 then data=combined_cluttermax $ else if j eq 5 then data=combined_cluttermin $ else if j eq 6 then data=combined_clutterall $ else if j eq 7 then data=combined_cluttercloudy $ else if j eq 8 then data=combined_cbase $ else if j eq 9 then data=combined_cbasepos $ else if j eq 10 then data=combined_cbaseuse $ else if j eq 11 then data=combined_cbasemode $ else if j eq 12 then data=combined_cbasemax $ else if j eq 13 then data=combined_cbasemin $ else if j eq 14 then data=combined_ctop $ else if j eq 15 then data=combined_ctoppos $ else if j eq 16 then data=combined_ctopuse $ else if j eq 17 then data=combined_ctopmode $ else if j eq 18 then data=combined_ctopmax $ else if j eq 19 then data=combined_ctopmin $ else if j eq 20 then data=combined_reflectivity $ else if j eq 21 then data=combined_reflectp $ else if j eq 22 then data=combined_reflectc $ else if j eq 23 then data=combined_velocity $ else if j eq 24 then data=combined_spectrum $ else if j eq 25 then data=combined_sfcpress $ else if j eq 26 then data=combined_temp $ else if j eq 27 then data=combined_pressure $ else if j eq 28 then data=combined_numlayers $ else if j eq 29 then data=combined_bhl1 $ else if j eq 30 then data=combined_bhl2 $ else if j eq 31 then data=combined_bhl3 $ else if j eq 32 then data=combined_bhl4 $ else if j eq 33 then data=combined_bhl5 $ else if j eq 34 then data=combined_btl1 $ else if j eq 35 then data=combined_btl2 $ else if j eq 36 then data=combined_btl3 $ else if j eq 37 then data=combined_btl4 $ else if j eq 38 then data=combined_btl5 $ else if j eq 39 then data=combined_thl1 $ else if j eq 40 then data=combined_thl2 $ else if j eq 41 then data=combined_thl3 $ else if j eq 42 then data=combined_thl4 $ else if j eq 43 then data=combined_thl5 $ else if j eq 44 then data=combined_ttl1 $ else if j eq 45 then data=combined_ttl2 $ else if j eq 46 then data=combined_ttl3 $ else if j eq 47 then data=combined_ttl4 $ else if j eq 48 then data=combined_ttl5 $ else if j eq 49 then data=combined_bpl1 $ else if j eq 50 then data=combined_bpl2 $ else if j eq 51 then data=combined_bpl3 $ else if j eq 52 then data=combined_bpl4 $ else if j eq 53 then data=combined_bpl5 $ else if j eq 54 then data=combined_tpl1 $ else if j eq 55 then data=combined_tpl2 $ else if j eq 56 then data=combined_tpl3 $ else if j eq 57 then data=combined_tpl4 $ else if j eq 58 then data=combined_tpl5 $ else if j eq 59 then data=combined_liq $ else if j eq 60 then data=combined_vap $ else if j eq 61 then data=combined_down_short $ else if j eq 62 then data=combined_up_short $ else if j eq 63 then data=combined_down_long $ else if j eq 64 then data=combined_up_long $ else if j eq 65 then data=combined_twsflux $ else if j eq 66 then data=combined_zenith $ else if j eq 67 then data=combined_solarratio $ else if j eq 68 then data=combined_surfacealbedo $ else if j eq 69 then data=combined_first_cbh $ else if j eq 70 then data=combined_column_cfrac return end