pro get_ciret2_5min, ciret2_fname, ciret2_iwc5, $ ciret2_dge5, ciret2_error_frac 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') height_id=ncdf_varid(cdfid,'Height') ; 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 ncdf_varget, cdfid, N0s_id, N0s_in ncdf_varget, cdfid, mlambda_id, mlambda_in ;if max(radrat) gt 0.15 then iwc_in[where(radrat gt 0.1)]=-9999. ncdf_close, cdfid dge=fltarr(num_times,num_heights) dge[*,*]=-9999. ; following loops attempts to solve equation 2.3 of Fu 1996. count_it=0 fuck_flag=1 print, 'calculating dge' for jj=0,num_times-1 do begin for k=0,num_heights-1 do begin if N0s_in[k,jj] ne 0 and N0s_in[k,jj] gt -10000 and fuck_flag eq 1 then begin N0s=10.^((float(N0s_in[k,jj]))/1000.) & mlambda=10.^((float(mlambda_in[k,jj]))/1000.) ;aa=0.15775 & ba=-0.5371 ; coeffecients for aspect ratio with D in mm aa=0.35 & ba=-0.15 term1=aa*(gamma(4.+(2.*ba)))/((abs(mlambda))^(1.+(ba))) term2=gamma(3.+ba) term3=((sqrt(3.))/4.)*aa*(gamma(3.+(2.*ba)))/((abs(mlambda))^ba) dge[jj,k]=term1/(term2+term3) endif else begin if N0s_in[k,jj] ne 0 and N0s_in[k,jj] gt -10000 then begin dge[jj,k]=50. endif endelse endfor ;print, float(jj)/float(num_times) if count_it eq 100 then begin print, jj, num_times count_it=0 endif count_it=count_it+1 endfor print, 'done calculating dge' ; go through and calcuate dge ;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. for jjj=0,n_elements(time_index)-1 do begin for kkk=0,n_elements(z_index)-1 do begin if max(time_index) gt 0 and max(z_index) gt 0 then $ max_val=max([max_val,dge[time_index[jjj],z_index[kkk]]]) endfor endfor if max_val eq -9999. then z_index=where( (abs(height-height5[k])) le 200. ) max_val=-9999. for jjj=0,n_elements(time_index)-1 do begin for kkk=0,n_elements(z_index)-1 do begin if max(time_index) gt 0 and max(z_index) gt 0 then $ max_val=max([max_val,dge[time_index[jjj],z_index[kkk]]]) endfor endfor if max_val gt -1 then begin count=0. & mean_iwc=0. & mean_dge=0. for jjj=0,n_elements(time_index)-1 do begin for kkk=0,n_elements(z_index)-1 do begin if dge[time_index[jjj],z_index[kkk]] gt -9999. 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_dge=mean_dge+dge[time_index[jjj],z_index[kkk]] endif endfor endfor if count gt 0. then begin ciret2_iwc5[k,j]=mean_iwc/count & ciret2_error_frac[k,j]=0.4 ciret2_dge5[k,j]=(mean_dge/count)*(1.e-6) ;print, ciret2_dge5[k,j], mean_dge, count endif else begin ciret2_iwc5[k,j]=-9999. ciret2_dge5[k,j]=-9999. endelse endif else begin ciret2_iwc5[k,j]=-9999. ciret2_dge5[k,j]=-9999. endelse endfor endfor endfor return end