; ; Plot a monthly summary ; pro plot_average_1d,site,searchdate,avg_int ;site='sgp' ;searchdate='200003' ;avg_int='1hr' ; ; common containing the monthly averaged data ; common monthly_averaged_data, base_time,time_offset,height,reflectivity,$ reflectp, reflectc, cbase, ctop, velocity, clutter,maxclutter,spectrum,$ lwp,vceil,numtimes,numheights,allclutter,goodclutter,temp,press,$ vap,dir,dsol,sfpres,numlayers,twsflux,zenith,solarratio,sfcalbedo,$ column_cfrac ; ; Read in the monthly averaged data ; get_average_data,site,searchdate,avg_int ; ; Convert height from meters to km ; height=height/1000. ;convert from meters to km ; ; Select which data to plot ; dataname=strarr(9) dataname=['Laser Cloud Base Radar First Cloud Top',$ 'PWV (cm) LWP (mm/10)',$ 'Ceilometer',$ 'Downwelling IR',$ 'Surface Pressure',$ 'Number of Cloud Layers',$ 'Estimated Total Down Clear ShortwaveDownwelling Solar',$ 'Solar Ratio','Surface Albedo'] datatag=strarr(9) datatag=[ 'cbase.ctop',$ 'lwp.pwv',$ 'vceil',$ 'dir',$ 'sfpres',$ 'numlayers',$ 'twsflux.dsol',$ 'solarratio',$ 'albedo'] cb_title=strarr(9) cb_title=['KM (AGL)',$ 'cm or mm/10',$ 'KM (AGL)',$ 'W/m!E2',$ 'millibars',$ 'number of layers',$ 'W/m!E2',$ '',''] ; ; Loop through the variables in the file ; for datanum=0,8 do begin ;loop through the different variables ;for datanum=6,6 do begin print, datatag[datanum] if datanum eq 0 then begin data=cbase data2=ctop endif if datanum eq 1 then begin data=lwp ; convert liq to mm/10 result=where(data ne -9999,count) if count ne 0 then data[result]=data[result]*100. data2=vap endif if datanum eq 2 then begin if n_elements(vceil) ne 0 then begin data=vceil result=where(data ne -9999,count) if count ne 0 then data[result]=data[result]/1000. endif else goto,nodata endif if datanum eq 3 then data=dir if datanum eq 4 then begin data=sfpres result=where(data ne -9999,count) ; convert pressure from pascals to millibars if count ne 0 then data[result]=data[result]/100. endif if datanum eq 5 then data=numlayers if datanum eq 6 then begin data=twsflux data2=dsol endif if datanum eq 7 then data=solarratio if datanum eq 8 then begin data=sfcalbedo result=where(data lt 0 or data gt 1,count) if count ne 0 then data[result]=-9999 endif ; ; Convert LWP to log ; ;if datanum eq 1 then begin ; result=where(data gt 0,count) ; if count ne 0 then data[result]=alog10(data[result]) ;endif ; ; Find the max and min data values ; if datanum eq 1 then begin dmax=max([data2,data]) result=where(data2 eq -9999,count) if count gt 0 then data2[result]=1e6 result=where(data eq -9999,count) if count gt 0 then data[result]=1e6 dmin=min([data2,data]) dmax=min([dmax,10.]) dmin=max([0.,dmin]) endif else begin if datanum eq 8 then dmax=max(data) else dmax=ceil(max(data)) result=where(data le -9999, count) if count ne 0 then data[result]=1e6 dmin=floor(min(data)) if datanum eq 8 then dmin=0 endelse print, 'dmax',dmax,'dmin',dmin ; ; Calculate the file starting and ending date and time ; standard_date_time,base_time+time_offset(0),syear,smonth,sday,shour,smin,ssec print,'file start',syear,smonth,sday,shour,smin,ssec standard_date_time,base_time+time_offset(numtimes-1),eyear,emonth,eday,ehour,emin,esec print,'file end',eyear,emonth,eday,ehour,emin,esec ; ; Calculate the standard date arrays ; ijday_ihrfrac_fm_numsec,base_time,time_offset,hrfrac,jday,yy,mm,dd,hh,mi,ss ; ; Calculate IDL Julian day for plotting ; julian_day=make_array(n_elements(jday),/double,value=-9999) julian_day=julday(mm,dd,yy,hh,mi,ss) ; ; Convert time offset to seconds since 1970 ; ;time_offset=long(base_time)+long(time_offset) ; ; Set up the plot ; loadct,39 ;load the color table !y.omargin=[2,5] ;set aside some room at the top of the page for the title !x.margin=[8,15] ;change to accomodate the colorbar !y.margin=[2,2] ;change to move the images closer together !p.multi=[0,1,5] ;put 5 plots on a page !p.charsize=2 ;increase the character size !p.background=!d.n_colors-1 ;make the background white !x.ticklen=-0.02 xwin=800 ;xsize of the plot window ywin=800 ;ysize of the plot window window,0,xsize=xwin,ysize=ywin,title='average',/pixmap dummy=label_date(date_format=[' %D %M !C %H:%I ']) ; ; Plot 1 ; plot1='yes' if plot1 eq 'yes' then begin ;week1=num_sec_ep(1999,07,1,0,0,0) week1=num_sec_ep(syear,smonth,sday,shour,smin,ssec) result=where(base_time+time_offset eq week1,count) if count eq 1 then week1=result[0] else stop ;week2=num_sec_ep(1999,07,8,0,0,0) week2=num_sec_ep(syear,smonth,sday+7,shour,smin,ssec) result=where(base_time+time_offset eq week2,count) if count eq 1 then week2=result[0] else stop week=data[week1:week2-1] weektime=julian_day[week1:week2-1] plot,weektime,week,color=0,$ xstyle=1,ystyle=1,$ yrange=[dmin,dmax],ytitle=cb_title[datanum],psym=4,symsize=0.5,$ xtickunits='time',xtickformat='label_date' if datanum eq 0 or datanum eq 1 or datanum eq 6 then begin week=data2[week1:week2-1] oplot,weektime,week,color=250,psym=4,symsize=0.5 endif endif ;do week1 ; ; Plot 2 ; plot2='yes' if plot2 eq 'yes' then begin ;week1=num_sec_ep(1999,07,8,0,0,0) week1=num_sec_ep(syear,smonth,sday+7,shour,smin,ssec) result=where(base_time+time_offset eq week1,count) if count eq 1 then week1=result[0] else stop ;week2=num_sec_ep(1999,07,15,0,0,0) week2=num_sec_ep(syear,smonth,sday+14,shour,smin,ssec) result=where(base_time+time_offset eq week2,count) if count eq 1 then week2=result[0] else stop week=data[week1:week2-1] weektime=julian_day[week1:week2-1] plot,weektime,week,color=0,$ xstyle=1,ystyle=1,$ yrange=[dmin,dmax],ytitle=cb_title[datanum],psym=4,symsize=0.5,$ xtickunits='time',xtickformat='label_date' if datanum eq 0 or datanum eq 1 or datanum eq 6 then begin week=data2[week1:week2-1] oplot,weektime,week,color=250,psym=4,symsize=0.5 endif endif ; ; Plot 3 ; plot3='yes' if plot3 eq 'yes' then begin ;week1=num_sec_ep(1999,07,15,0,0,0) week1=num_sec_ep(syear,smonth,sday+14,shour,smin,ssec) result=where(base_time+time_offset eq week1,count) if count eq 1 then week1=result[0] else stop ;week2=num_sec_ep(1999,07,22,0,0,0) week2=num_sec_ep(syear,smonth,sday+21,shour,smin,ssec) result=where(base_time+time_offset eq week2,count) if count eq 1 then week2=result[0] else stop week=data[week1:week2-1] weektime=julian_day[week1:week2-1] plot,weektime,week,color=0,$ xstyle=1,ystyle=1,$ yrange=[dmin,dmax],ytitle=cb_title[datanum],psym=4,symsize=0.5,$ xtickunits='time',xtickformat='label_date' if datanum eq 0 or datanum eq 1 or datanum eq 6 then begin week=data2[week1:week2-1] oplot,weektime,week,color=250,psym=4,symsize=0.5 endif endif ; ; Plot 4 ; plot4='yes' if plot4 eq 'yes' then begin ;week1=num_sec_ep(1999,07,22,0,0,0) week1=num_sec_ep(syear,smonth,sday+21,shour,smin,ssec) result=where(base_time+time_offset eq week1,count) if count eq 1 then week1=result[0] else stop ;week2=num_sec_ep(1999,07,29,0,0,0) week2=num_sec_ep(syear,smonth,sday+28,shour,smin,ssec) result=where(base_time+time_offset eq week2,count) if count eq 1 then begin week2=result[0] endif else begin week2=numtimes-1 ;for February endelse week=data[week1:week2-1] weektime=julian_day[week1:week2-1] plot,weektime,week,color=0,$ xstyle=1,ystyle=1,$ yrange=[dmin,dmax],ytitle=cb_title[datanum],psym=4,symsize=0.5,$ xtickunits='time',xtickformat='label_date' if datanum eq 0 or datanum eq 1 or datanum eq 6 then begin week=data2[week1:week2-1] oplot,weektime,week,color=250,psym=4,symsize=0.5 endif endif ; ; Plot 5 ; plot5='yes' if plot5 eq 'yes' and smonth ne 2 then begin ;don't plot this last bit for February ;week1=num_sec_ep(1999,07,29,0,0,0) week1=num_sec_ep(syear,smonth,sday+28,shour,smin,ssec) result=where(base_time+time_offset eq week1,count) if count eq 1 then week1=result[0] else stop ;week2=num_sec_ep(1999,07,31,23,0,0) week2=num_sec_ep(syear,smonth,eday,ehour,emin,esec) result=where(base_time+time_offset eq week2,count) if count eq 1 then week2=result[0] else stop week=data[week1:week2-1] weektime=julian_day[week1:week2-1] if (eday-sday-28) eq 2 then begin ;determine if 30 or 31 days adjust=3./7. ;31 days endif else begin adjust=2./7. ;30 days endelse plot,weektime,week,/nodata ;plot to get size of device ; Get position of the plot window in device pixels px=!x.window*!d.x_vsize py=!y.window*!d.y_vsize ; Sixe of the plot window in pixels sx=px[1]-px[0]+1 sy=py[1]-py[0]+1 ; cut the size of the plot window down according to adjust variable sx=sx*adjust plot,weektime,week,color=0,$ xstyle=1,ystyle=1,$ yrange=[dmin,dmax],ytitle=cb_title[datanum],psym=4,symsize=0.5,$ xtickunits='time',xtickformat='label_date',$ position=[px[0],py[0],px[0]+sx,py[1]],/noerase,/device if datanum eq 0 or datanum eq 1 or datanum eq 6 then begin week=data2[week1:week2-1] oplot,weektime,week,color=250,psym=4,symsize=0.5 endif endif ; ; Add a title ; if smonth eq 1 then smon='Jan' if smonth eq 2 then smon='Feb' if smonth eq 3 then smon='Mar' if smonth eq 4 then smon='Apr' if smonth eq 5 then smon='May' if smonth eq 6 then smon='Jun' if smonth eq 7 then smon='Jul' if smonth eq 8 then smon='Aug' if smonth eq 9 then smon='Sep' if smonth eq 10 then smon='Oct' if smonth eq 11 then smon='Nov' if smonth eq 12 then smon='Dec' if site eq 'sgp' then begin capsite='SGP' datastream='average.1hr' endif else if site eq 'nsa' then begin capsite='NSA' datastream='average.1hr' endif else if site eq 'twpc1' then begin capsite='TWP Manus' datastream='average.1hr' endif else if site eq 'twpc2' then begin capsite='TWP Nauru' datastream='average.1hr' endif syr=strcompress(string(syear),/remove_all) if datanum eq 0 then begin xyouts,0.04,0.95,align=0,charsize=1.7,/normal,color=0,$ 'Monthly Summary of Hourly Averages for Laser Cloud Base & ' xyouts,0.71,0.95,align=0,charsize=1.7,/normal,color=250,$ 'Radar First Cloud Top' xyouts,0.5,0.947,align=0.5,charsize=1.7,/normal,color=0,$ '!C'+capsite+' - '+smon+' '+syr endif else if datanum eq 1 then begin xyouts,0.09,0.95,align=0,charsize=1.7,/normal,color=0,$ 'Monthly Summary of Hourly Averages for LWP (mm/10) and ' xyouts,0.75,0.95,align=0,charsize=1.7,/normal,color=250,$ 'PWV (cm)' xyouts,0.5,0.947,align=0.5,charsize=1.7,/normal,color=0,$ '!C'+capsite+' - '+smon+' '+syr endif else if datanum eq 6 then begin xyouts,0.08,0.95,align=0,charsize=1.7,/normal,color=0,$ 'Monthly Summary of Hourly Averages for Clear Sky Flux & ' xyouts,0.72,0.95,align=0,charsize=1.7,/normal,color=250,$ 'Downwelling Solar' xyouts,0.5,0.947,align=0.5,charsize=1.7,/normal,color=0,$ '!C'+capsite+' - '+smon+' '+syr endif else $ xyouts,0.5,0.95,align=0.5,charsize=1.7,/normal,color=0,$ 'Monthly Summary of Hourly Averages for '+dataname[datanum]+'!C'+capsite+' - '+smon+' '+syr ; ; Create gif file ; strmon=string(smonth) if smonth lt 10 then strmon='0'+strmon strday=string(sday) if sday lt 10 then strday='0'+strday curdate=strcompress(syr+strmon+strday,/remove_all) gifdir='/data/mace4/arm_data/temp_image/' giffile=site+'.'+datastream+'.'+curdate+'.'+datatag[datanum]+'.gif' print, gifdir+giffile write_gif,gifdir+giffile,tvrd( ) ; ; Remove the png file ; pngfile=site+'.'+datastream+'.'+curdate+'.'+datatag[datanum]+'.png' unix_command='rm '+gifdir+pngfile spawn,unix_command nodata: endfor ;end loop through variables end