pro get_ciret2_avg_5min_dge, ciret2_fname, ciret2_iwc5, $ ciret2_dge5, ciret2_error_frac, ciret2_extinct5 common five_min_data_input2, hrfrac5,jday5,height5,dbz5,nppts5,npts5,cbase5,ctop5, $ vel5, width5,temp5, pressure5, n_layers5,bzl15,tzl15,btl15,ttl15,bzl25,tzl25,btl25,ttl25, $ bzl35,tzl35,btl35,ttl35,bzl45,tzl45,btl45,ttl45,fluxclear5,solrat5,lwp5,vceil5,vap5 ; puts the iwc and re onto the time-height grid. print, ciret2_fname print, n_elements(ciret2_fname) for jjjkkk=0,n_elements(ciret2_fname)-1 do begin cdfid=ncdf_open(ciret2_fname[jjjkkk]) ; open the netcdf file print, 'opened ',ciret2_fname[jjjkkk] time_did=ncdf_dimid(cdfid,'Time') height_did=ncdf_dimid(cdfid,'Height') ncdf_diminq, cdfid, time_did, char_strng, num_times ncdf_diminq, cdfid, height_did, char_strng, num_heights ; get the id's of the variables to be read num_sec_id=ncdf_varid(cdfid,'base_time') time_offset_id=ncdf_varid(cdfid,'time_offset') N0s_id=ncdf_varid(cdfid,'N0s') mlambda_id=ncdf_varid(cdfid,'mlambda') iwc_id=ncdf_varid(cdfid,'Ice_Water_Content') iwc_err_id=ncdf_varid(cdfid,'Ice_Water_Content_err') height_id=ncdf_varid(cdfid,'Height') ;dvel_correl_id=ncdf_varid(cdfid,'dvel_correl') Dge_id=ncdf_varid(cdfid,'Dge') Dge_err_id=ncdf_varid(cdfid,'Dge_err') ext_coeff_doppler_id=ncdf_varid(cdfid,'ext_coeff_doppler') ; get the data ncdf_varget, cdfid, num_sec_id, num_sec ncdf_varget, cdfid, time_offset_id, time_offset ncdf_varget, cdfid, height_id, height ijday_ihrfrac_fm_numsec, num_sec, time_offset, hrfrac, jday, yy, mm, dd, hh, mi, ss ncdf_varget, cdfid, iwc_id, iwc_in & iwc_in=rotate(iwc_in, 4) ncdf_varget, cdfid, iwc_err_id, iwc_err_in & iwc_err_in=rotate(iwc_err_in,4) ncdf_varget, cdfid, N0s_id, N0s_in & N0s_in=rotate(N0s_in,4) ncdf_varget, cdfid, mlambda_id, mlambda_in & mlambda_in=rotate(mlambda_in,4) ;ncdf_varget, cdfid, dvel_correl_id, dvel_correl ncdf_varget, cdfid, Dge_id, Dge_int & Dge_int=rotate(Dge_int, 4) ncdf_varget, cdfid, Dge_err_id, Dge_err_int & Dge_err_int=rotate(Dge_err_int,4) ncdf_varget, cdfid, ext_coeff_doppler_id, ext_coeff_doppler_int & ext_coeff_doppler_int=rotate(ext_coeff_doppler_int,4) ncdf_close, cdfid ;help, iwc_in ;help, Dge_int ;help, ext_coeff_doppler_int ;help, time_offset ;help, height ;break ;ijday_ihrfrac_fm_numsec, num_sec, time_offset, hrfrac, jday, yy, mm, dd, hh, mi, ss ;print, jday ;print, 'shit!' ;print, jday5 ; loop through the observations, match times, then go through heights for j=0,n_elements(hrfrac5)-1 do begin for k=0,n_elements(height5)-1 do begin time_index=where( (abs(jday-jday5[j])) le 0.0035 ) z_index=where( (abs(height-height5[k])) lt 90. ) max_val=-9999. if max(time_index) gt -1 and max(z_index) gt -1 then begin for jjj=0,n_elements(time_index)-1 do begin for kkk=0,n_elements(z_index)-1 do begin ; print, z_index[kkk],time_index[jjj],jjj,kkk ; help, dge_int ; help, jday if dge_int[z_index[kkk],time_index[jjj]] ne 0 and dge_int[z_index[kkk],time_index[jjj]] ne 1 and max(time_index) gt 0 and max(z_index) gt 0 then $ max_val=max([max_val,10.^(float(dge_int[z_index[kkk],time_index[jjj]])/1000.)]) endfor endfor endif ;if max_val eq -9999. then z_index=where( (abs(height-height5[k])) le 200. ) ; max_val=-9999. ; ;help, dge_int ; if max(time_index) gt -1 and max(z_index) gt -1 then begin ;for jjj=0,n_elements(time_index)-1 do begin ;for kkk=0,n_elements(z_index)-1 do begin ; ;print, jjj,kkk,time_index[jjj], z_index[kkk] ; if dge_int[z_index[kkk],time_index[jjj]] ne 0 and dge_int[z_index[kkk],time_index[jjj]] ne 1 and max(time_index) gt 0 and max(z_index) gt 0 then $ ; max_val=max([max_val,10.^(float(dge_int[z_index[kkk],time_index[jjj]])/1000.)]) ;endfor ;endfor ; endif if max_val gt -1 then begin count=0. & mean_iwc=0. & mean_dge=0. & mean_extinct=0. & mean_iwc_err=0. & mean_dge_err=0. for jjj=0,n_elements(time_index)-1 do begin for kkk=0,n_elements(z_index)-1 do begin if dge_int[z_index[kkk],time_index[jjj]] ne 0 and dge_int[z_index[kkk],time_index[jjj]] ne 1 then begin count=count+1. ;print, hrfrac[time_index[jjj]],height[z_index[kkk]],' in ',hrfrac5[j],height5[k] mean_iwc=mean_iwc+(10.^((float(iwc_in[z_index[kkk],time_index[jjj]]))/1000.)) mean_iwc_err=mean_iwc_err+((10.^((float(iwc_err_in[z_index[kkk],time_index[jjj]]))/1000.))/(10.^((float(iwc_in[z_index[kkk],time_index[jjj]]))/1000.))) mean_dge=mean_dge+(10.^((float(dge_int[z_index[kkk],time_index[jjj]]))/1000.)) ;mean_dge_err=mean_dge_err+((10.^((float(dge_err_int[z_index[kkk],time_index[jjj]]))/1000.))/(10.^((float(dge_int[z_index[kkk],time_index[jjj]]))/1000.))) mean_extinct=mean_extinct+(10.^((float(ext_coeff_doppler_int[z_index[kkk],time_index[jjj]]))/1000.)) endif endfor endfor if count gt 0. then begin ciret2_iwc5[k,j]=mean_iwc/count ciret2_dge5[k,j]=(mean_dge/count)*(1.e-6) ciret2_dge5[k,j]=ciret2_dge5[k,j]-(0.15*ciret2_dge5[k,j]) ciret2_extinct5[k,j]=(mean_extinct/count) ciret2_error_frac[k,j]=mean_iwc_err/count ;if dvel_correl[0]/dvel_correl[1] le 1.2 then begin ; ciret2_error_frac[k,j]=10. ;endif else begin ; ciret2_error_frac[k,j]=0.4 ;endelse endif else begin ciret2_iwc5[k,j]=-9999. ciret2_dge5[k,j]=-9999. ciret2_extinct5[k,j]=-9999. endelse endif else begin ;ciret2_extinct5=ciret2_dge5 if ciret2_iwc5[k,j] le 0. then ciret2_iwc5[k,j]=-9999. if ciret2_iwc5[k,j] le 0. then ciret2_dge5[k,j]=-9999. if ciret2_iwc5[k,j] le 0. then ciret2_extinct5[k,j]=-9999. endelse endfor endfor endfor return end