pro raman_lidar_file_write, time, year, month, day, height, bscat_copol, bscat_crosspol, bscat_raman, calibration, copol_nd_filter_correction, crosspol_nd_filter_correction ; estimate cloud base common colors,r_orig,g_orig,b_orig,r_curr,g_curr,b_curr dumb=where(time[1:*] eq 0.0, count) if count gt 0 then begin num_times=min(where(time[1:*] eq 0.0))-1 endif else begin num_times=n_elements(time) endelse cloud_base_index=lonarr(num_times) loadct, 11 ; This is the stern color scheme r_curr[250:255]=255 & r_orig=r_curr g_curr[250:255]=255 & g_orig=g_curr b_curr[250:255]=255 & b_orig=b_curr for j=0,num_times-1 do begin if max(bscat_copol[j,*]) gt 0. then begin max_co_diff=0. & max_co_diff_index=0 max_cr_diff=0. & max_cr_diff_index=0 max_index=where(bscat_copol[j,*] eq max(bscat_copol[j,*])) if max_index lt n_elements(height)-10 then begin mean_bscat=mean(bscat_copol[j,max_index+10:n_elements(height)-1]) bscat_max_ratio=bscat_copol[j,max_index]/mean_bscat endif base_flag=0 & k=10 ;for k=11,n_elements(height)-12 do begin while base_flag eq 0 and k lt n_elements(height)-10 do begin lower_mean_copol=mean(bscat_copol[j,k-5:k])/(2.*(mean(height[k-5:k])^2)) upper_mean_copol=mean(bscat_copol[j,k:k+5])/(2.*(mean(height[k-5:k])^2)) lower_mean_crpol=mean(bscat_crosspol[j,k-5:k])/(2.*(mean(height[k-5:k])^2)) upper_mean_crpol=mean(bscat_crosspol[j,k:k+5])/(2.*(mean(height[k-5:k])^2)) if upper_mean_copol/lower_mean_copol gt 5. and upper_mean_crpol/lower_mean_crpol gt 3. and $ upper_mean_copol gt 0. and lower_mean_copol gt 0. and upper_mean_crpol gt 0. and lower_mean_crpol gt 0. and min(bscat_copol[j,k-5:k+5]) gt 0. then begin prev_co_rat=upper_mean_copol/lower_mean_copol & prev_cr_rat=upper_mean_crpol/lower_mean_crpol k=k+1 lower_mean_copol=mean(bscat_copol[j,k-5:k])/(2.*(mean(height[k-5:k])^2)) upper_mean_copol=mean(bscat_copol[j,k:k+5])/(2.*(mean(height[k-5:k])^2)) lower_mean_crpol=mean(bscat_crosspol[j,k-5:k])/(2.*(mean(height[k-5:k])^2)) upper_mean_crpol=mean(bscat_crosspol[j,k:k+5])/(2.*(mean(height[k-5:k])^2)) while upper_mean_copol/lower_mean_copol gt prev_co_rat or upper_mean_crpol/lower_mean_crpol gt prev_cr_rat and k lt n_elements(height)-10 and $ upper_mean_copol gt 0. and lower_mean_copol gt 0. and upper_mean_crpol gt 0. and lower_mean_crpol gt 0. do begin prev_co_rat=upper_mean_copol/lower_mean_copol & prev_cr_rat=upper_mean_crpol/lower_mean_crpol k=k+1 lower_mean_copol=mean(bscat_copol[j,k-5:k])/(2.*(mean(height[k-5:k])^2)) upper_mean_copol=mean(bscat_copol[j,k:k+5])/(2.*(mean(height[k-5:k])^2)) lower_mean_crpol=mean(bscat_crosspol[j,k-5:k])/(2.*(mean(height[k-5:k])^2)) upper_mean_crpol=mean(bscat_crosspol[j,k:k+5])/(2.*(mean(height[k-5:k])^2)) endwhile if upper_mean_copol gt 0. and lower_mean_copol gt 0. and upper_mean_crpol gt 0. and lower_mean_crpol gt 0. then begin cloud_base_index[j]=k base_flag=1 ;if k gt 150 then stop endif endif k=k+1 endwhile if bscat_max_ratio gt 10 and abs(cloud_base_index[j]-max_index) gt 5 then cloud_base_index[j]=max_index ;gamma_ct, 1.0 ;set_plot, 'Z' ;device, set_resolution=[3000,2000] ;!p.charsize=3. ;!p.font=-1 ;!p.background=!d.n_colors-2 ;!p.thick=3. ; ;bscatco=bscat_copol[j,*] ;bscatcr=bscat_crosspol[j,*] ; ; plot, bscatco[where(height lt 3.)], height[where(height lt 3.)], psym=-2, color=0 ; oplot, bscatcr[where(height lt 3.)], height[where(height lt 3.)], psym=-3, color=200 ; oplot, [-1.e6, 1.e6], [height[cloud_base_index[j]],height[cloud_base_index[j]]], psym=-3, color=0 ; oplot, [-1.e6, 1.e6], [height[cloud_base_index[j]],height[cloud_base_index[j]]], psym=-3, linestyle=2, color=0 ; write_gif, '/Users/u0029340/Documents/data/Capricorn/Lidar/test_profile.gif', tvrd() ; endif ; bscat_copol[j,*] endfor set_plot, 'Z' device, set_resolution=[3000,2000] !p.charsize=3. !p.font=-1 !p.background=!d.n_colors-2 !p.thick=3. ;bscatco=bscat_copol[j,*] ;bscatcr=bscat_crosspol[j,*] plot, time, height[cloud_base_index], psym=-2, color=0 ;oplot, bscatcr[where(height lt 3.)], height[where(height lt 3.)], psym=-3, color=200 ;oplot, [-1.e6, 1.e6], [height[cloud_base_index[j]],height[cloud_base_index[j]]], psym=-3, color=0 ;oplot, [-1.e6, 1.e6], [height[cloud_base_index[j]],height[cloud_base_index[j]]], psym=-3, linestyle=2, color=0 write_gif, '/Users/u0029340/Documents/data/Capricorn/Lidar/test_profile.gif', tvrd() output_path='/Users/u0029340/Documents/data/Capricorn/Lidar/' ; create a base_time and time_offset ; t=float(fix(time)) frac_hr=time-t min_t=frac_hr*60. sec_t=(min_t-float(fix(min_t)))*60. julian_day=julday(float(month),float(day),float(year),float(fix(frac_hr[0:num_times-1])),float(fix(min_t[0:num_times-1])),float(fix(sec_t[0:num_times-1]))) base_time=julian_day[0] time_offset=julian_day-julian_day[0] output_fname=output_path+'Capricorn_Lidar_'+year+month+day+'.cdf cdfid=ncdf_create(output_fname,/clobber) time_did=ncdf_dimdef(cdfid,'time_offset',n_elements(time_offset)) heights_did=ncdf_dimdef(cdfid,'heights',n_elements(height)) basetime_id=ncdf_vardef(cdfid, 'base_time', /long) time_offset_id=ncdf_vardef(cdfid, 'time_offset', /double) year_id=ncdf_vardef(cdfid, 'year', /long) month_id=ncdf_vardef(cdfid, 'month', /long) day_id=ncdf_vardef(cdfid, 'day', /long) hrfrac_id=ncdf_vardef(cdfid, 'fractional_hour',[time_did], /float) height_id=ncdf_vardef(cdfid, 'heights', [heights_did], /float) bscat_copol_id=ncdf_vardef(cdfid, 'bscat_copol', [time_did, heights_did], /float) bscat_crosspol_id=ncdf_vardef(cdfid, 'bscat_crosspol', [time_did, heights_did], /float) bscat_raman_id=ncdf_vardef(cdfid, 'bscat_raman', [time_did, heights_did], /float) calibration_id=ncdf_vardef(cdfid, 'calibration', /float) copol_nd_filter_correction_id=ncdf_vardef(cdfid, 'copol_nd_filter_correction', /float) crosspol_nd_filter_correction_id=ncdf_vardef(cdfid, 'crosspol_nd_filter_correction', /float) cloud_base_height_index_id=ncdf_vardef(cdfid, 'cloud_base_height_index',[time_did], /long) ncdf_control, cdfid, /endef ncdf_varput, cdfid, basetime_id, long(base_time) ncdf_varput, cdfid, time_offset_id, time_offset ncdf_varput, cdfid, year_id, year ncdf_varput, cdfid, month_id, month ncdf_varput, cdfid, day_id, day ncdf_varput, cdfid, hrfrac_id, time[0:num_times-1] ncdf_varput, cdfid, height_id, height ncdf_varput, cdfid, bscat_copol_id, bscat_copol[0:num_times-1,*] ncdf_varput, cdfid, bscat_crosspol_id, bscat_crosspol[0:num_times-1,*] ncdf_varput, cdfid, bscat_raman_id, bscat_raman[0:num_times-1,*] ncdf_varput, cdfid, calibration_id, calibration ncdf_varput, cdfid, copol_nd_filter_correction_id, copol_nd_filter_correction ncdf_varput, cdfid, crosspol_nd_filter_correction_id, crosspol_nd_filter_correction ncdf_varput, cdfid, cloud_base_height_index_id, cloud_base_index[0:num_times-1] ncdf_close, cdfid return end