; ; This program processes a two dimensional variable. Uses the averaged ; temperature, clutterflag, and reflectivity to determine the cloud layers for ; the averaged time interval ; Pro two_dimensional_derived2_generic,layers,var_name common ncdf_file, oldcdfname,twoD,time_dim_name,height_dim_name,$ height_var_name,avgfilename,curdate common old_grid, num_times,num_heights,base_time,time_offset,$ height,site;,files,num_files,num_days common new_grid, numtimes,newtimes, numheights,newheights,$ timespacing,heightspacing common bracket, startbst common data, avg_data ; ; Open the averaged netcdf file ; avg_id=ncdf_open(avgfilename) ; ; Get the variable id ; var_id=ncdf_varid(avg_id,var_name) base_height_layer_1_id=ncdf_varid(avg_id,'base_height_layer_1') base_height_layer_2_id=ncdf_varid(avg_id,'base_height_layer_2') base_height_layer_3_id=ncdf_varid(avg_id,'base_height_layer_3') base_height_layer_4_id=ncdf_varid(avg_id,'base_height_layer_4') base_height_layer_5_id=ncdf_varid(avg_id,'base_height_layer_5') top_height_layer_1_id=ncdf_varid(avg_id,'top_height_layer_1') top_height_layer_2_id=ncdf_varid(avg_id,'top_height_layer_2') top_height_layer_3_id=ncdf_varid(avg_id,'top_height_layer_3') top_height_layer_4_id=ncdf_varid(avg_id,'top_height_layer_4') top_height_layer_5_id=ncdf_varid(avg_id,'top_height_layer_5') if var_id ne -1 and base_height_layer_1_id ne -1 and $ top_height_layer_1_id ne -1 then begin print,'Processing 2-D ',layers,' for ',var_name ; ; Get the variable ; ncdf_varget, avg_id, var_id, var ncdf_varget, avg_id, base_height_layer_1_id, bh1 ncdf_varget, avg_id, base_height_layer_2_id, bh2 ncdf_varget, avg_id, base_height_layer_3_id, bh3 ncdf_varget, avg_id, base_height_layer_4_id, bh4 ncdf_varget, avg_id, base_height_layer_5_id, bh5 ncdf_varget, avg_id, top_height_layer_1_id, th1 ncdf_varget, avg_id, top_height_layer_2_id, th2 ncdf_varget, avg_id, top_height_layer_3_id, th3 ncdf_varget, avg_id, top_height_layer_4_id, th4 ncdf_varget, avg_id, top_height_layer_5_id, th5 var=transpose(var) ; ; Close the netcdf file ; ncdf_close, avg_id ; ; Scan through the reflectivity profile to find the clouds ; bp1=make_array(numtimes,/float,value=-9999) bp2=make_array(numtimes,/float,value=-9999) bp3=make_array(numtimes,/float,value=-9999) bp4=make_array(numtimes,/float,value=-9999) bp5=make_array(numtimes,/float,value=-9999) tp1=make_array(numtimes,/float,value=-9999) tp2=make_array(numtimes,/float,value=-9999) tp3=make_array(numtimes,/float,value=-9999) tp4=make_array(numtimes,/float,value=-9999) tp5=make_array(numtimes,/float,value=-9999) for t=0,numtimes-1 do begin var_profile=var[t,*] result=where(newheights eq bh1[t],count) if count ne 0 and n_elements(result) eq 1 then bp1[t]=var_profile[result] result=where(newheights eq bh2[t],count) if count ne 0 and n_elements(result) eq 1 then bp2[t]=var_profile[result] result=where(newheights eq bh3[t],count) if count ne 0 and n_elements(result) eq 1 then bp3[t]=var_profile[result] result=where(newheights eq bh4[t],count) if count ne 0 and n_elements(result) eq 1 then bp4[t]=var_profile[result] result=where(newheights eq bh5[t],count) if count ne 0 and n_elements(result) eq 1 then bp5[t]=var_profile[result] result=where(newheights eq th1[t],count) if count ne 0 and n_elements(result) eq 1 then tp1[t]=var_profile[result] result=where(newheights eq th2[t],count) if count ne 0 and n_elements(result) eq 1 then tp2[t]=var_profile[result] result=where(newheights eq th3[t],count) if count ne 0 and n_elements(result) eq 1 then tp3[t]=var_profile[result] result=where(newheights eq th4[t],count) if count ne 0 and n_elements(result) eq 1 then tp4[t]=var_profile[result] result=where(newheights eq th5[t],count) if count ne 0 and n_elements(result) eq 1 then tp5[t]=var_profile[result] endfor ;end of loop through pressure profiles ; ; Open the netcdf file ; avg_id=ncdf_open(avgfilename, /write) ; ; Get the variable dimensions ; time_id=ncdf_dimid(avg_id,'time') ; ; Put the netcdf file into define mode ; ncdf_control, avg_id, /redef ; ; Define variable ; base_press_layer_1_id=ncdf_vardef(avg_id,'base_press_layer_1', time_id) base_press_layer_2_id=ncdf_vardef(avg_id,'base_press_layer_2', time_id) base_press_layer_3_id=ncdf_vardef(avg_id,'base_press_layer_3', time_id) base_press_layer_4_id=ncdf_vardef(avg_id,'base_press_layer_4', time_id) base_press_layer_5_id=ncdf_vardef(avg_id,'base_press_layer_5', time_id) top_press_layer_1_id=ncdf_vardef(avg_id,'top_press_layer_1', time_id) top_press_layer_2_id=ncdf_vardef(avg_id,'top_press_layer_2', time_id) top_press_layer_3_id=ncdf_vardef(avg_id,'top_press_layer_3', time_id) top_press_layer_4_id=ncdf_vardef(avg_id,'top_press_layer_4', time_id) top_press_layer_5_id=ncdf_vardef(avg_id,'top_press_layer_5', time_id) ; ; Define attributes ; for i=1,5 do begin num=string(i) dataname='base_press_layer_'+num dataname=strcompress(dataname,/remove_all) longname='base pressure of radar layer'+num longname=strcompress(longname) theunits='pascals' ncdf_attput, avg_id, dataname, 'long_name', longname ncdf_attput, avg_id, dataname, 'units', theunits endfor for i=1,5 do begin num=string(i) dataname='top_press_layer_'+num dataname=strcompress(dataname,/remove_all) longname='top pressure of radar layer'+num longname=strcompress(longname) theunits='pascals' ncdf_attput, avg_id, dataname, 'long_name', longname ncdf_attput, avg_id, dataname, 'units', theunits endfor ; ; Change from define mode to data mode ; ncdf_control, avg_id, /endef ; ; Write variable ; ncdf_varput, avg_id, base_press_layer_1_id, bp1 ncdf_varput, avg_id, base_press_layer_2_id, bp2 ncdf_varput, avg_id, base_press_layer_3_id, bp3 ncdf_varput, avg_id, base_press_layer_4_id, bp4 ncdf_varput, avg_id, base_press_layer_5_id, bp5 ncdf_varput, avg_id, top_press_layer_1_id, tp1 ncdf_varput, avg_id, top_press_layer_2_id, tp2 ncdf_varput, avg_id, top_press_layer_3_id, tp3 ncdf_varput, avg_id, top_press_layer_4_id, tp4 ncdf_varput, avg_id, top_press_layer_5_id, tp5 ; ; Close the netcdf file ; ncdf_close, avg_id endif ;variable does exist in the file return end