;This ncl script will plot the DEC PM2.5 data ; begin ;************************************ ; f = "Albany0005PM-S702.out" f0 = "County081-PM-0124-Final1.out" f1 = "County081-SO2-0124-Final.out" f2 = "County081-NOx-0124-Final.out" f3 = "County081-O3-0124-Final.out" f4 = "County081-CO-0124-Final.out" ; Column information (NOTE NCL COLUMN COUNT IS IN PARENTHIESE) ; 1 (0) sensor ID number ; 2 (1) Date in YYYYMMDD.PPPPPP format P is hourly julian day decimal ; 3 (2) PM2.5 data missing data is -999 ; ; data = asciiread(f,(/112728,4/),"float") ; Albany0005PM-S702.out data0 = asciiread(f0,(/6574,2/),"double") ; PM data data1= asciiread(f1,(/6574,2/),"double") ; SO2 data data2= asciiread(f2,(/6574,2/),"double") ; NOx data data3= asciiread(f3,(/6574,2/),"double") ; O3 data data4= asciiread(f4,(/6574,2/),"double") ; CO data ;*********************************************************************** ; Processing data0 PM2.5 data x0 = data0(:,0) yyyymmdd = toint(x0) ; convert to yyyymmdd ; yyyymmddhh = yyyymmdd*100.d ; * by 100 to prepare for yyyymmddhh setting ; do gg = 0,23 ; yyyymmddhh(gg::24) = yyyymmddhh(gg::24)+gg ; end do ; yyyyfrac = yyyymmddhh_to_yyyyfrac(yyyymmddhh,0) ; print(x+" "+yyyymmddhh+" "+yyyyfrac) yyyyfrac = yyyymmdd_to_yyyyfrac(yyyymmdd,0) print(x0+" "+yyyymmdd+" "+yyyyfrac) ; x0@long_name = "PM2.5 concentration (ug/m^3)" x0@long_name = "Date/Time" y0 = data1(:,1) ; y0@long_name = "Date/Time" y0@long_name = "PM2.5 concentration (ug/m^3)" y0@_FillValue=integertoshort(-999) y0=where(y0.lt.0,y0@FillValue,y0) ;********************************************************************** ; Process the SO2 data x1 = data1(:,0) yyyymmdd = toint(x1) ; convert to yyyymmdd ; yyyymmddhh = yyyymmdd*100.d ; * by 100 to prepare for yyyymmddhh setting ; do gg = 0,23 ; yyyymmddhh(gg::24) = yyyymmddhh(gg::24)+gg ; end do ; yyyyfrac = yyyymmddhh_to_yyyyfrac(yyyymmddhh,0) ; print(x+" "+yyyymmddhh+" "+yyyyfrac) yyyyfrac = yyyymmdd_to_yyyyfrac(yyyymmdd,0) print(x1+" "+yyyymmdd+" "+yyyyfrac) ; x1@long_name = "SO2 concentration (ppb)" x1@long_name = "Date/Time" y1 = data0(:,1) ; y1@long_name = "Date/Time" y1@long_name = "SO2 concentration (ppb)" y1@_FillValue=integertoshort(-999) y1=where(y1.lt.-5.0,y1@FillValue,y1) ;************************************************************************ ; Process the NOx data x2 = data2(:,0) yyyymmdd = toint(x2) ; convert to yyyymmdd ; yyyymmddhh = yyyymmdd*100.d ; * by 100 to prepare for yyyymmddhh setting ; do gg = 0,23 ; yyyymmddhh(gg::24) = yyyymmddhh(gg::24)+gg ; end do ; yyyyfrac = yyyymmddhh_to_yyyyfrac(yyyymmddhh,0) ; print(x+" "+yyyymmddhh+" "+yyyyfrac) yyyyfrac = yyyymmdd_to_yyyyfrac(yyyymmdd,0) print(x2+" "+yyyymmdd+" "+yyyyfrac) ; x1@long_name = "NOx concentration (ppb)" x2@long_name = "Date/Time" y2 = data0(:,1) ; y2@long_name = "Date/Time" y2@long_name = "NOx concentration (ppb)" y2@_FillValue=integertoshort(-999) y2=where(y2.lt.-5.0,y2@FillValue,y2) ;************************************************************************ ; Process the O3 data x3 = data3(:,0) yyyymmdd = toint(x3) ; convert to yyyymmdd ; yyyymmddhh = yyyymmdd*100.d ; * by 100 to prepare for yyyymmddhh setting ; do gg = 0,23 ; yyyymmddhh(gg::24) = yyyymmddhh(gg::24)+gg ; end do ; yyyyfrac = yyyymmddhh_to_yyyyfrac(yyyymmddhh,0) ; print(x+" "+yyyymmddhh+" "+yyyyfrac) yyyyfrac = yyyymmdd_to_yyyyfrac(yyyymmdd,0) print(x3+" "+yyyymmdd+" "+yyyyfrac) ; x3@long_name = "O3 concentration (ppm)" x3@long_name = "Date/Time" y3 = data0(:,1) ; y3@long_name = "Date/Time" y3@long_name = "O3 concentration (ppm)" y3@_FillValue=integertoshort(-999) y3=where(y3.lt.-5.0,y3@FillValue,y3) ;************************************************************************ x4 = data4(:,0) yyyymmdd = toint(x4) ; convert to yyyymmdd ; yyyymmddhh = yyyymmdd*100.d ; * by 100 to prepare for yyyymmddhh setting ; do gg = 0,23 ; yyyymmddhh(gg::24) = yyyymmddhh(gg::24)+gg ; end do ; yyyyfrac = yyyymmddhh_to_yyyyfrac(yyyymmddhh,0) ; print(x+" "+yyyymmddhh+" "+yyyyfrac) yyyyfrac = yyyymmdd_to_yyyyfrac(yyyymmdd,0) print(x4+" "+yyyymmdd+" "+yyyyfrac) ; x4@long_name = "CO concentration (ppm)" x4@long_name = "Date/Time" y4 = data0(:,1) ; y4@long_name = "Date/Time" y4@long_name = "CO concentration (ppm)" y4@_FillValue=integertoshort(-999) y4=where(y4.lt.-5.0,y4@FillValue,y4) ;************************************************************************ ;************************************ ; Plotting parameters ;************************************ plot = new (5, "graphic") wks = gsn_open_wks ("png","multitest.png") res = True attachres = True attachres@gsnAttachPlotsXAxis= True attachres@gsnAttachBorderOn = True ;; border please attachres1 = True attachres1@gsnAttachPlotsXAxis = True ;; attaches along x-axis attachres1@gsnAttachBorderOn = True ;; border please ;***************************************************************************** res@gsnMaximize = True res@gsnDraw = False res@gsnFrame = False res@vpWidthF = 0.8 ; Make plots wider than res@vpHeightF = 0.2 ; they are high. res@tiYAxisString = "PM2.5 Conc (ug/m^3)" res@xyLineColor = "Black" res@tiYAxisFontColor = res@xyLineColor plot(0) = gsn_csm_xy(wks,yyyyfrac,y0,res) ; Create the four plots. res1 = True res1@gsnDraw = True res1@gsnFrame = True ;************************************************************** res@tiYAxisString = "SO2 Conc (ppb)" res@xyLineColor = "Red" plot(1) = gsn_csm_xy(wks,yyyyfrac,y1,res1) ; Create the four plots. res@tiYAxisString = "NOx Conc (ppb)" res@xyLineColor = "Blue" plot(2) = gsn_csm_xy(wks,yyyyfrac,y2,res1) ; They won't be drawn yet. res@tiYAxisString = "O3 Conc (ppm)" res@xyLineColor = "Orange" plot(3) = gsn_csm_xy(wks,yyyyfrac,y3,res1) res@tiYAxisString = "CO Conc (ppm)" res@xyLineColor = "ForestGreen" plot(4) = gsn_csm_xy(wks,yyyyfrac,y4,res1) res1@gsnMaximize = True res1@gsnAttachPlotsXAxis = True res@tiMainString = "Albany0005PM" ; Title ; res@trXMaxF = 2008 ; set minimum X-axis value ; res@trXMaxF = 2009 ; set maximum X-axis value res1@tmXBMode = "Explicit" res1@tmXBValues = ispan(2002,2020,4) res1@tmXBLabels = ispan(2002,2020,4) ; or (/"2006","2010","2014","2018","2020"/) ; plot = gsn_csm_xy (wks,yyyyfrac,y,res) ; create plot ; xy0 is the base plot ; plot = gsn_csm_xy (wks,yyyyfrac,y0,res1) ; create plot ; amid = gsn_attach_plots(xy0,(/xy1,xy2,xy3,xy4/),res,res1) attachid1 = gsn_attach_plots(plot(0),plot(1:4),attachres,attachres1) ; Resize base plot and watch how other plots follow. setvalues plot(0) "vpWidthF" : 0.4 "vpHeightF" : 0.15 end setvalues draw(attachid1) ; All four plots will be smaller. frame(wks) end