<div dir="ltr"><div>I have made a lot of progress with:</div><div> times = f->time ; get times in file<br> cd_date = cd_calendar(times, -2)<br>; print(cd_date) This prints all the dates correctly as yyyymmdd<br></div><div><br></div><div>Then I have:</div><div> res = True<br> restick = True<br> restick@ttmValues = cd_date<br> restick@ttmFormat = "%D/%N/%Y"<br> res@xyLineThicknessF = 3.0 ; set line thickness<br> res@xyLineColor = "red" ; set line color<br> res@xyDashPatterns = 0 ; solid line<br> res@tmXBLabelFontHeightF = 0.010<br> res@tiYAxisString = "Daily " + " " + y@standard_name +" "+ "at 15S/30E" ; y-axis string<br><br>; create the plot<br>;-----------------------------------------------<br> time_axis_labels(cd_date,res,restick) ; call the formatting procedure<br> plot = gsn_csm_xy(wks,cd_date,y,res) ; should produce bottom x-axis ticks as dd/mm/yyyy (01/01/1971).</div><div><br></div><div>I am able to have yyyy0000 on the x-axis. What I am trying to figure out now is how to use "time_axis_labels".</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 4, 2021 at 10:17 PM Barry Lynn <<a href="mailto:barry.h.lynn@gmail.com">barry.h.lynn@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Hi:</div><div dir="auto"><br></div><div dir="auto">You have to define year, month, etc from your data. </div><div dir="auto"><br></div><div dir="auto">Can you do that?</div><div dir="auto"><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 4 Feb 2021 at 20:39 Zilore Mumba <<a href="mailto:zmumba@gmail.com" target="_blank">zmumba@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello Lynn,</div><div>Sorry I have had no success with the code you sent me. On the line</div><div>new_time_array = cd_inv_calendar( year(it,1,1), month(it,1,1), day(it,1,1), hour(it,1,1), minute(it,1,1), 0, new_time_units,0)</div><div>I get the error: fatal:Undefined identifier: (year) is undefined, can't continue</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 4, 2021 at 7:55 AM Barry Lynn <<a href="mailto:barry.h.lynn@gmail.com" target="_blank">barry.h.lynn@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi:<div><br></div><div>Try adjusting the third line here:</div><div><br></div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"<br></div><div><br></div><div>begin code...</div><div><br></div><div>new_time_units = "hours since 1800-01-01 00:00"<br>new_time_units = new_time_units<br>new_time_array = cd_inv_calendar( year(it,1,1), month(it,1,1), day(it,1,1), hour(it,1,1), minute(it,1,1), 0, new_time_units,0)<br>print("new_time_array = " + new_time_array)<br>printVarSummary(new_time_array)<br>format = "" ;; defaults to "%H%M IST %d %c %Y"<br> format = "%H%M IST %d %c %Y"<br> new_time_array = new_time_array + 2.01<br>;format = "%H%M IDT %d %c %Y"<br>;new_time_array = new_time_array + 3.01<br>time_var=cd_string(new_time_array,format)<br>print("time_var = " + time_var)<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 4, 2021 at 7:17 AM Zilore Mumba via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello,</div><div>I hope I can get quick help to set me off as it is taking me days to make sense of what I have to do.</div><div>I have historical (1971-200) and model simulation (2021-2050) data. I have adapted an ncl script from the DKRZ website for plotting a time series.</div><div><br></div><div>With print(times) I get the time range 7701.5 to 18658.5.</div><div>When I plot the time series at a point I get the x-axis range 6000 60 20000</div><div>ncdump -h on the file indicates that time:units = "days since 1949-12-01 00:00:00"</div><div>my data has format yyyymmdd (yearmothday). I want the x-axis to show dates.</div><div><br></div><div>I have been looking in the ncl documentation how to do this. This may take me days or weeks.</div><div>I would appreciate any help in this.</div><div><div>The script I have is below</div></div><div><br></div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"<br>begin<br><br> diri = "./" ; directory where to find the data<br> fili = "pr_AFR-44_CNRM-CERFACS-CNRM-CM5_historical_r1i1p1_SMHI-RCA4_v1_day_19710101_20001231Reg.nc" ; file name<br><br> f = addfile(diri+fili,"r") ; open file<br><br> t1 = f->pr(:,{-15},{30}) ; read precip time series at 15S/30E<br><br> times = f->time ; get times in file<br> cd_date = cd_calendar(times, -2)<br><br>; open a workstation<br>;----------------------------------------------------------------<br> wks_type = "X11" ; graphics output type<br> wks_type@wkWidth = 1024 ; graphics output width in pixels<br> wks_type@wkHeight = 1048 ; graphics output height in pixels<br><br> wks = gsn_open_wks(wks_type, "plot_xy_multiple_lines_axis")<br><br>; resources for variable t1, y-axis<br>;----------------------------------------------------------<br> resT1 = True <br> resT1@ttmValues = cd_date<br> resT1@xyLineThicknessF = 3.0 ; set line thickness<br> resT1@xyLineColor = "red" ; set line color<br> resT1@xyDashPatterns = 0 ; solid line<br> resT1@tmXBLabelFontHeightF = 0.010<br> resT1@tiYAxisString = "Daily " + " " + t1@standard_name +" "+ "at 15S/30E" ; y-axis string<br><br>; create the plot<br>;-----------------------------------------------<br> plot = gsn_csm_xy(wks, times&time, t1, resT1)<br> <br>end</div><div><br></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><span style="color:rgb(34,34,34)">Guest Editor of Special Issue “Extreme Hydroclimatic Events and Prediction”</span><br style="color:rgb(34,34,34)"><span style="color:rgb(34,34,34)">LINK:</span><br style="color:rgb(34,34,34)"><a href="https://www.mdpi.com/journal/water/special_issues/Extreme_Hydroclimatic_Events" rel="noreferrer" style="color:rgb(17,85,204)" target="_blank">https://www.mdpi.com/journal/water/special_issues/Extreme_Hydroclimatic_Events</a><br></div><div dir="ltr"><br></div><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Associate Scientist, Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br><br></div></div></div></div></div>
</blockquote></div>
</blockquote></div></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><span style="color:rgb(34,34,34)">Guest Editor of Special Issue “Extreme Hydroclimatic Events and Prediction”</span><br style="color:rgb(34,34,34)"><span style="color:rgb(34,34,34)">LINK:</span><br style="color:rgb(34,34,34)"><a href="https://www.mdpi.com/journal/water/special_issues/Extreme_Hydroclimatic_Events" rel="noreferrer" style="color:rgb(17,85,204)" target="_blank">https://www.mdpi.com/journal/water/special_issues/Extreme_Hydroclimatic_Events</a><br></div><div dir="ltr"><br></div><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Associate Scientist, Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br><br></div></div></div></div></div>
</blockquote></div>