; ================================================================================== pro output_3d,file_unit_3d,def,in,ncv,rev0,date,rad_min,nlay_in,qf_in,ut_in, $ lat_in,lon_in,sza_in,alb_in,rad_in,iwc_in,alb_air_in,iwc_air_in, $ cp_in,fcv1,fcv2 ; ================================================================================== ; This routine strips out the Common Volume pixels and outputs results to the ; CV summary file for one orbit. ; ---------------------------------------------------------------------------------- ; Modifications/updates: ; ; April 2018 - Modified to output the AIR albedo and IWC values. ; -------------------------------------------------------------------------------- ; ------------------------------------------------------------------------ ; If there are no CV pixels in this orbit, dump summary line and get out. ; ------------------------------------------------------------------------ if(ncv eq 0) then begin printf,file_unit_3d,format=fcv1,rev0,date,0.,0.,ncv,0,0,0. return endif nlay=nlay_in[in] qf=qf_in[in] ut=ut_in[in] lat=lat_in[in] lon=lon_in[in] sza=sza_in[in] alb=alb_in[in] rad=rad_in[in] iwc=iwc_in[in] alb_air=alb_air_in[in] iwc_air=iwc_air_in[in] cp=cp_in[in] ; --------------------------------------------------------------------- ; Now calculate distance vector from SOFIE point. ; As a proxy for the sofie point use midpoint of CV pixels (lat0/lon0) ; --------------------------------------------------------------------- lat0=mean(lat,/nan) lon0=mean(lon,/nan) ; Check to see we're not crossing the Prime Meridian crossing=0 if(max(lon)-min(lon) gt 300) then begin ; go back and work in [-180,180] space crossing=1 west=where(lon gt 180) lon(west)-=360. lon0=mean(lon,/nan) endif dist=distance(lat0,lon0,lat,lon) close=where(dist le 100.) ; iterate once to get closer... lat0=mean(lat(close),/nan) lon0=mean(lon(close),/nan) dist=distance(lat0,lon0,lat,lon) ; put longitude grid back on [0,360] grid if crossed Prime Meridian if(crossing eq 1) then begin lon(west)+=360. endif ; --------------------------------------------- ; Calculate average UT and local time over CV ; --------------------------------------------- meanut=mean(ut,/nan) ltime=ut-(360.-lon)*24./360. x=where(ltime lt 0.,nx) if(nx gt 0) then ltime(x)+=24. ltime=mean(ltime,/nan) cld=where(cp eq 1,ncld) bad=where(cp eq 1 and rad lt rad_min,nbad) if(nbad gt 0) then begin rad[bad]=def iwc[bad]=def endif cld_frac=float(ncld)/float(ncv) if(ncld gt 0) then cld_presence=1 else cld_presence=0 ; -------------------- ; Write output to file ; -------------------- printf,file_unit_3d,format=fcv1,rev0,date,meanut,ltime,ncv,cld_presence,ncld,cld_frac for m=0,ncv-1 do begin printf,file_unit_3d,format=fcv2,lat[m],lon[m],sza[m],dist[m],rad[m],alb[m],iwc[m],alb_air[m],iwc_air[m],qf[m],cp[m] endfor return end