<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="" style="word-wrap:break-word">Hi!
<div class=""><br class="">
</div>
<div class="">I am trying to plot monthly data of threshold exceedance from a precipitation dataset I created prior. The data is already prepared and from 1980 to 2014 in monthly resolution (420 values). My problem is, the plot doesn’t plot the data per month
and year but plots all 12 values on the full year and then jumps to the next year (say 1980 -> 1981 -> 1982) instead of the individual months (basically: 1980/1 -> 1980/2 -> 1980/3 etc.). I did create a float dateF variable as described in example 5 (<a href="https://www.ncl.ucar.edu/Applications/Scripts/xy_5.ncl" class="">https://www.ncl.ucar.edu/Applications/Scripts/xy_5.ncl</a>,
plot here: <a href="https://www.ncl.ucar.edu/Applications/Images/xy_5_1_lg.png" class="">https://www.ncl.ucar.edu/Applications/Images/xy_5_1_lg.png</a>) but the plots still didn’t change.</div>
<div class=""><br class="">
</div>
<div class="">My script is written using example 5 as a rough template.</div>
<div class=""><br class="">
</div>
<div class="">Below is my script, and attached are two zip files with my data to test, and two plots from 1980 to 1989 as it looks right now.</div>
<div class=""><br class="">
</div>
<div class="">I would appreciate any help and thank you for your time!</div>
<div class=""><br class="">
</div>
<div class="">Best,</div>
<div class="">Toni</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class="">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="text-align:start; text-indent:0px; word-wrap:break-word">
<div class="" style="color:rgb(0,0,0); letter-spacing:normal; text-transform:none; white-space:normal; word-spacing:0px">
<b class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)">Toni Klemm</b><br class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)">
<div class=""><span class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)">Ph.D. Candidate</span><br class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)">
<span class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)">The University of Oklahoma</span><br class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)">
<span class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)">South Central Climate Science Center</span><br class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)">
</div>
<div class=""><span class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)">phone: 405 325 1272</span></div>
<div class="">Contributor at the <a href="https://www.eccforum.org/" class="">Early Career Climate Forum</a></div>
<div class=""><span class="" style="color:rgb(51,51,153); background-color:rgb(255,255,255)"><a href="http://www.toni-klemm.de/" class="">www.toni-klemm.de</a> | </span><a href="https://twitter.com/ToniKlemm" class="">@toniklemm</a></div>
</div>
<div class="" style="color:rgb(0,0,0); letter-spacing:normal; text-transform:none; white-space:normal; word-spacing:0px">
<br class="">
</div>
<div class="" style="color:rgb(0,0,0); letter-spacing:normal; text-transform:none; white-space:normal; word-spacing:0px">
<br class="">
</div>
<div class="">
<div class=""><font face="Courier" class="">; *************************************************************************************************************</font></div>
<div class=""><font face="Courier" class="">; Compare maximum and total number of monthly threshold exceedance days for 95th percentile and 99th percentile</font></div>
<div class=""><font face="Courier" class="">; *************************************************************************************************************</font></div>
<div class=""><font face="Courier" class="">;</font></div>
<div class=""><font face="Courier" class="">; Used as template: <a href="https://www.ncl.ucar.edu/Applications/Scripts/xy_5.ncl" class="">
https://www.ncl.ucar.edu/Applications/Scripts/xy_5.ncl</a></font></div>
<div class=""><font face="Courier" class="">;</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">begin</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("**** Start ****")</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">; ***********************************************</font></div>
<div class=""><font face="Courier" class="">; 1 - READ IN FILES</font></div>
<div class=""><font face="Courier" class="">; ***********************************************</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("1 - Read in q95 and q99 data")</font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class=""> q95_files = systemfunc("ls ~/OBS/PRECIP/daily/threshold/by_month_and_year/q95/nc/*.nc")</font></div>
<div class=""><font face="Courier" class=""> q95_f = addfiles(q95_files,"r")</font></div>
<div class=""><font face="Courier" class=""> ListSetType(q95_f,"join")</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> q99_files = systemfunc("ls ~/OBS/PRECIP/daily/threshold/by_month_and_year/q99/nc/*.nc")</font></div>
<div class=""><font face="Courier" class=""> q99_f = addfiles(q99_files,"r")</font></div>
<div class=""><font face="Courier" class=""> ListSetType(q99_f,"join")</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">; ***********************************************</font></div>
<div class=""><font face="Courier" class="">; 2 - READ IN VARIABLES</font></div>
<div class=""><font face="Courier" class="">; ***********************************************</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("2 - Read in q95 and q99 variables")</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> max_yes_95 = q95_f[:]->max_yes_95</font></div>
<div class=""><font face="Courier" class=""> min_max_yes_95 = min(max_yes_95)</font></div>
<div class=""><font face="Courier" class=""> max_max_yes_95 = max(max_yes_95)</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> total_yes_95 = q95_f[:]->total_yes_95</font></div>
<div class=""><font face="Courier" class=""> min_total_yes_95 = min(total_yes_95)</font></div>
<div class=""><font face="Courier" class=""> max_total_yes_95 = max(total_yes_95)</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> max_yes_99 = q99_f[:]->max_yes_99</font></div>
<div class=""><font face="Courier" class=""> min_max_yes_99 = min(max_yes_99)</font></div>
<div class=""><font face="Courier" class=""> max_max_yes_99 = max(max_yes_99)</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> total_yes_99 = q99_f[:]->total_yes_99</font></div>
<div class=""><font face="Courier" class=""> min_total_yes_99 = min(total_yes_99)</font></div>
<div class=""><font face="Courier" class=""> max_total_yes_99 = max(total_yes_99)</font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class=""> date = q95_f[:]->date</font></div>
<div class=""><font face="Courier" class=""> dimDate = dimsizes(date)</font></div>
<div class=""><font face="Courier" class=""> dateF = new(dimDate,float)</font></div>
<div class=""><font face="Courier" class=""> do n=0,dimDate-1 ; date = 198001</font></div>
<div class=""><font face="Courier" class=""> yyyy = date(n)/100 ; yyyy = 1980</font></div>
<div class=""><font face="Courier" class=""> mon = date(n)-yyyy*100 ; mon = 198001 - (1980*100) = 1</font></div>
<div class=""><font face="Courier" class=""> dateF(n) = yyyy + (mon-1)/12 ; dateF(n) = 1980 + (1-1)/12 = 1980.0833</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("date(n) = " + date(n) + "(" + n + ")")</font></div>
<div class=""><font face="Courier" class=""> print("yyyy = " + yyyy)</font></div>
<div class=""><font face="Courier" class=""> print("mon = " + mon)</font></div>
<div class=""><font face="Courier" class=""> print("dateF(n) = " + dateF(n) + "(" + n + ")")</font></div>
<div class=""><font face="Courier" class=""> print("max_yes_95(n) = " + max_yes_95(n) + "(" + n + ")")</font></div>
<div class=""><font face="Courier" class=""> end do</font></div>
<div class=""><font face="Courier" class=""> printVarSummary(dateF)</font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class="">; print(max_yes_95)</font></div>
<div class=""><font face="Courier" class="">; printVarSummary(dateF)</font></div>
<div class=""><font face="Courier" class="">; printVarSummary(total_yes_95)</font></div>
<div class=""><font face="Courier" class="">; printVarSummary(total_yes_99)</font></div>
<div class=""><font face="Courier" class="">; printVarSummary(yyyymm)</font></div>
<div class=""><font face="Courier" class="">; sleep(10)</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">;******************************************</font></div>
<div class=""><font face="Courier" class="">; 3A - DEFINE XY PLOT FOR MAXIMA COMPARISON</font></div>
<div class=""><font face="Courier" class="">;******************************************</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("3A - Define XY plot for maxima comparison")</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> diro = "~/OBS/PRECIP/daily/threshold/by_month_and_year/"</font></div>
<div class=""><font face="Courier" class=""> wks = gsn_open_wks ("png",diro + "obs_precip_SHP_daily_yes_no_xy_plot_max") ; send graphics to PNG file</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> res = True ; plot mods desired</font></div>
<div class=""><font face="Courier" class=""> res@gsnFrame = False ; don't advance frame yet </font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> res@vpHeightF= 0.2 ; change aspect ratio of plot</font></div>
<div class=""><font face="Courier" class=""> res@vpWidthF = 0.7</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> res@gsnLeftString = "Range q95: " + min_max_yes_95 + " - " + max_max_yes_95 + " days"<span class="x_Apple-tab-span" style="white-space:pre">
</span>; map subtitle, printed on the top left</font></div>
<div class=""><font face="Courier" class=""> res@gsnRightString = "Range q99: " + min_max_yes_99 + " - " + max_max_yes_99 + " days"<span class="x_Apple-tab-span" style="white-space:pre">
</span>; map subtitle, printed on the top left</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> res@trYMinF = 0.0<span class="x_Apple-tab-span" style="white-space:pre">
</span> ; min value on y-axis</font></div>
<div class=""><font face="Courier" class=""> res@trYMaxF = 8.0 ; max value on y-axis</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">; since we stretch the plot, we need to slide it over a bit so it does not</font></div>
<div class=""><font face="Courier" class="">; run off the page. we do this by:</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">; res@vpXF = 0.1 ; start plot at x ndc coord </font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class=""> res@tiYAxisString = "Days per Month" ; y-axis label </font></div>
<div class=""><font face="Courier" class=""> res@tiYAxisFontHeightF = 0.012</font></div>
<div class=""><font face="Courier" class=""> res@tiMainString = "Maximum Days per Month > 95~S~th~N~ Percentile and 99~S~th~N~ Percentile" ; title</font></div>
<div class=""><font face="Courier" class=""> res@tiMainFontHeightF = 0.02</font></div>
<div class=""><font face="Courier" class=""> res@tiMainFont = 22</font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class="">; create a reference line and shade values above and below with selected colors. This is shading array dsoid.</font></div>
<div class=""><font face="Courier" class=""> res@gsnYRefLine = 0.0 ; create a reference line </font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">;*********************************</font></div>
<div class=""><font face="Courier" class="">; polyline parameters used on both plots</font></div>
<div class=""><font face="Courier" class="">;*********************************</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> polyres = True</font></div>
<div class=""><font face="Courier" class=""> polyres@gsLineThicknessF = 3.0</font></div>
<div class=""><font face="Courier" class="">; polyres@gsLineColor = 4.0</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">;******************************************</font></div>
<div class=""><font face="Courier" class="">; 3B - CREATE XY PLOT FOR MAXIMA COMPARISON</font></div>
<div class=""><font face="Courier" class="">;******************************************</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("3B - Create XY plot for Maxima Comparison")</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">; res@gsnAboveYRefLineColor = "green" <span class="x_Apple-tab-span" style="white-space:pre">
</span> <span class="x_Apple-tab-span" style="white-space:pre"></span>; above ref line fill red</font></div>
<div class=""><font face="Courier" class="">; res@gsnBelowYRefLineColor = "blue"
<span class="x_Apple-tab-span" style="white-space:pre"></span><span class="x_Apple-tab-span" style="white-space:pre"></span>; below ref line fill blue</font></div>
<div class=""><font face="Courier" class=""> plot = gsn_csm_xy(wks,dateF,max_yes_95,res)
<span class="x_Apple-tab-span" style="white-space:pre"></span>; create plot</font></div>
<div class=""><font face="Courier" class=""> gsn_polyline(wks,plot,dateF,(/max_yes_99/),polyres) <span class="x_Apple-tab-span" style="white-space:pre">
</span> ; add polyline</font></div>
<div class=""><font face="Courier" class=""> frame(wks)<span class="x_Apple-tab-span" style="white-space:pre">
</span>; now advance frame</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("**** Done Maxima ****")</font></div>
<div class=""><font face="Courier" class=""> print("")</font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class="">;******************************************</font></div>
<div class=""><font face="Courier" class="">; 4A - DEFINE XY PLOT FOR TOTALS COMPARISON</font></div>
<div class=""><font face="Courier" class="">;******************************************</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("4A - Define XY plot for totals comparison")</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> diro = "~/OBS/PRECIP/daily/threshold/by_month_and_year/"</font></div>
<div class=""><font face="Courier" class=""> wks = gsn_open_wks ("png",diro + "obs_precip_SHP_daily_yes_no_xy_plot_totals") ; send graphics to PNG file</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> res = True ; plot mods desired</font></div>
<div class=""><font face="Courier" class=""> res@gsnFrame = False ; don't advance frame yet </font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> res@vpHeightF= 0.2 ; change aspect ratio of plot</font></div>
<div class=""><font face="Courier" class=""> res@vpWidthF = 0.7</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> res@gsnLeftString = "Range q95: " + min_total_yes_95 + " - " + max_total_yes_95 + " days"<span class="x_Apple-tab-span" style="white-space:pre">
</span>; map subtitle, printed on the top left</font></div>
<div class=""><font face="Courier" class=""> res@gsnRightString = "Range q99: " + min_total_yes_99 + " - " + max_total_yes_99 + " days"<span class="x_Apple-tab-span" style="white-space:pre">
</span>; map subtitle, printed on the top left</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> res@trYMinF = 0.0<span class="x_Apple-tab-span" style="white-space:pre">
</span> ; min value on y-axis</font></div>
<div class=""><font face="Courier" class=""> res@trYMaxF = 800.0 ; max value on y-axis</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">; since we stretch the plot, we need to slide it over a bit so it does not</font></div>
<div class=""><font face="Courier" class="">; run off the page. we do this by:</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">; res@vpXF = 0.1 ; start plot at x ndc coord </font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class=""> res@tiYAxisString = "Days per Month" ; y-axis label </font></div>
<div class=""><font face="Courier" class=""> res@tiYAxisFontHeightF = 0.012</font></div>
<div class=""><font face="Courier" class=""> res@tiMainString = "Total Days per Month > 95~S~th~N~ Percentile and 99~S~th~N~ Percentile" ; title</font></div>
<div class=""><font face="Courier" class=""> res@tiMainFontHeightF = 0.02</font></div>
<div class=""><font face="Courier" class=""> res@tiMainFont = 22</font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class="">; create a reference line and shade values above and below with selected colors. This is shading array dsoid.</font></div>
<div class=""><font face="Courier" class=""> res@gsnYRefLine = 0.1 ; create a reference line </font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">;*********************************</font></div>
<div class=""><font face="Courier" class="">; polyline parameters used on both plots</font></div>
<div class=""><font face="Courier" class="">;*********************************</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> polyres = True</font></div>
<div class=""><font face="Courier" class=""> polyres@gsLineThicknessF = 3.0</font></div>
<div class=""><font face="Courier" class="">; polyres@gsLineColor = 4.0</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">;******************************************</font></div>
<div class=""><font face="Courier" class="">; 4B - CREATE XY PLOT FOR TOTALS COMPARISON</font></div>
<div class=""><font face="Courier" class="">;******************************************</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("4B - Create XY plot for totals comparison")</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">; res@gsnAboveYRefLineColor = "green" <span class="x_Apple-tab-span" style="white-space:pre">
</span> <span class="x_Apple-tab-span" style="white-space:pre"></span>; above ref line fill red</font></div>
<div class=""><font face="Courier" class="">; res@gsnBelowYRefLineColor = "blue"
<span class="x_Apple-tab-span" style="white-space:pre"></span><span class="x_Apple-tab-span" style="white-space:pre"></span>; below ref line fill blue</font></div>
<div class=""><font face="Courier" class=""> plot = gsn_csm_xy(wks,dateF,total_yes_95,res)
<span class="x_Apple-tab-span" style="white-space:pre"></span>; create plot</font></div>
<div class=""><font face="Courier" class=""> gsn_polyline(wks,plot,dateF,(/total_yes_99/),polyres) <span class="x_Apple-tab-span" style="white-space:pre">
</span> ; add polyline</font></div>
<div class=""><font face="Courier" class=""> frame(wks)<span class="x_Apple-tab-span" style="white-space:pre">
</span>; now advance frame</font></div>
<div class=""><font face="Courier" class=""> </font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class=""> print("**** Done Totals ****")</font></div>
<div class=""><font face="Courier" class=""><br class="">
</font></div>
<div class=""><font face="Courier" class="">end</font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br class="x_Apple-interchange-newline">
</div>
<div class=""><br class="x_webkit-block-placeholder">
</div>
<div class=""><br class="">
</div>
</div>
</div>
<div style="word-wrap:break-word">
<div></div>
</div>
<div style="word-wrap:break-word">
<div></div>
</div>
<div><img src="cid:409ef8d3-680a-4f3d-bf2c-b72d15b0708e@namprd03.prod.outlook.com">
</div>
<div style="word-wrap:break-word">
<div></div>
</div>
<div><img src="cid:33fa7a1f-0331-4cba-a36f-05911bce70c2@namprd03.prod.outlook.com">
</div>
<div class="" style="word-wrap:break-word">
<div class=""></div>
</div>
</body>
</html>