;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 (1, "graphic") wks = gsn_open_wks ("png","multitest.png") res = True ;***************************************************************************** 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 = "xy0" res@xyLineColor = "Black" xy0 = gsn_csm_y(wks,y0,res) ; Create the four plots. res@tiYAxisString = "xy1" res@xyLineColor = "Red" xy1 = gsn_csm_y(wks,y1,res) ; Create the four plots. res@tiYAxisString = "xy2" res@xyLineColor = "Blue" xy2 = gsn_csm_y(wks,y2,res) ; They won't be drawn yet. res@tiYAxisString = "xy3" res@xyLineColor = "Orange" xy3 = gsn_csm_y(wks,y3,res) res@tiYAxisString = "xy4" res@xyLineColor = "ForestGreen" xy4 = gsn_csm_y(wks,y4,res) res1 = True res2 = True res1@gsnMaximize = True res2@gsnAttachPlotsXAxis = True res1@tiMainString = "Albany0005PM" ; Title ; res@trXMaxF = 2008 ; set minimum X-axis value ; res@trXMaxF = 2009 ; set maximum X-axis value res1@tmXBMode = "Explicit" res2@tmXBMode = "Explicit" res1@tmXBValues = ispan(2002,2020,4) res1@tmXBLabels = ispan(2002,2020,4) ; or (/"2006","2010","2014","2018","2022"/) ; res2@tmXBValues = ispan(2002,2020,4) ; res2@tmXBLabels = ispan(2002,2020,4) ; or (/"2006","2010","2014","2018","2022"/) ; res@tmXBValues = ispan(2006,2022,4) ; res@tmXBLabels = ispan(2006,2022,4) ; or (/"2006","2010","2014","2018","2022"/) ; 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/),res1,res2) draw(xy1) ; All four plots will be drawn. frame(wks) ; Resize base plot and watch how other plots follow. setvalues xy1 "vpWidthF" : 0.4 "vpHeightF" : 0.15 end setvalues draw(xy1) ; All four plots will be smaller. frame(wks) ;**************************************************************************** ; res@tiMainString = "Albany0005PM" ; Title ; res@trXMaxF = 2008 ; set minimum X-axis value ; res@trXMaxF = 2009 ; set maximum X-axis value ; ; res@tmXBMode = "Explicit" ; res@tmXBValues = ispan(2006,2020,4) ; res@tmXBLabels = ispan(2006,2020,4) ; or (/"2006","2010","2014","2018","2022"/) ; res@tmXBValues = ispan(2006,2022,4) ; res@tmXBLabels = ispan(2006,2022,4) ; or (/"2006","2010","2014","2018","2022"/) ; plot = gsn_csm_xy (wks,yyyyfrac,y,res) ; create plot end