load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl" begin ; Read in the shapefile a = addfile("data/t2_daily_State_Data_US_rtty_1990.nc","r") day = 365 ; Make a variable "tau". This will just be a 1D variable 1-365 tau = new(day,float) do ii=0,day-1 tau(ii) = ii end do ; Make a variable "times". This will be used to make tick mark lables on the time series. ; we only want labels every 15 days. Otherwise it will be too crowded. times = new(day,string) times = "" do ii=0,day-1,15 times(ii) = flt2string(tau(ii)) end do ; Read in t2max for Colorado and also print a summary of the variable to see the dimensions/size t2max_co = a->T2MAX_Colorado printVarSummary(t2max_co) ; First we will average each day over the 11 year period. The 0th dimension is the year t2max_co_avg = dim_avg_n(t2max_co,0) printVarSummary(t2max_co_avg) ; Next we will average over each of the grid cells for the day. We will end up with a 1D 365 day long ; variable. t2max_co_avg2 = dim_avg_n(t2max_co_avg,1) ; Do the same for t2min over Colorado t2min_co = a->T2MIN_Colorado t2min_co_avg = dim_avg_n(t2min_co,0) t2min_co_avg2 = dim_avg_n(t2min_co_avg,1) ; Here we create a new variable data, and write t2max and t2min to data so they can be plotted ; together easily. To add more data, we just need to change the size of the array. data = new((/2,365/),"float") data(0,:) = t2max_co_avg2 data(1,:) = t2min_co_avg2 ; Open up the workstation for the plot wks = gsn_open_wks("X11","time_series") ; Here we will list all of the options for our time series plot res = True res@tmXBMode = "Explicit" ; Define own tick mark labels. res@tmXBValues = tau(0:day-1:15) ; location of explicit labels res@tmXBLabels = times(0:day-1:15) ; labels are the locations res@tmXTOn = False ; turn off the top tick marks res@tmYROn = False ; turn off the right side tick marks res@tmXBLabelFontHeightF = 0.01 ; Font height for the x axis labels res@tiXAxisString = "Day of Year" ; X axis title res@tiYAxisString = "Temperature (C)" ; Y axis title res@tiMainString = "Daily Max and Min Temperature over CO" ; Title of plot res@trXMaxF = 365. ; Maxiumum X axis length res@tmXBMajorLengthF = 0.017 ; Lenth of the X axis major tick marks ; If we want to add additional data to the time series, we need to adjust the following three lines res@xyLineColors = (/"red","blue"/) ; Line colors for the time series. max is red and min is blue res@xyDashPatterns = (/0,0/) ; Dash patterns. Both max and min here will be 0 (solid line) res@xyLineThicknesses = (/1.0,1.0/) ; Line thicknesses ; Here we list the options for the legend on the plot res@pmLegendDisplayMode = "Always" res@xyExplicitLegendLabels = (/"Max","Min"/) res@pmLegendSide = "Top" ; Change location of res@pmLegendParallelPosF = .9225 ; move units right res@pmLegendOrthogonalPosF = -0.2425 ; move units down res@pmLegendWidthF = 0.125 ; Change width and res@pmLegendHeightF = 0.075 ; height of legend. res@lgPerimOn = True ; turn off/on box around res@lgLabelFontHeightF = .015 ; label font height res@vpWidthF = 0.80 ; change aspect ratio of plot res@vpHeightF = 0.65 res@vpXF = 0.15 res@vpYF = 0.9 ; Finally we make the plot t2_plot = gsn_xy(wks,tau,data,res) ; End of program end