<div dir="ltr">Thank you very much Dave. With the changes you have suggested, all is working very well now. I appreciate greatly.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 4, 2021 at 11:31 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov">dave.allured@noaa.gov</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 dir="ltr"><div dir="ltr"><div>Okay. Comment out these two lines. You might need to put them back later, but they do not do what you think. @ttmValues is only to select the date positions to have visible printed labels. In other words it is to select a subset of dates across the whole axis.</div><div><br></div><div><div> cd_date = cd_calendar(times, -2)<br></div><div> restick@ttmValues = cd_date<br> </div><div>Then change these two lines to read as follows. These functions need the <b>original time coordinates</b>, not the <b>decoded date/time values</b> that you made in <b>cd_date</b>.</div><div><br> time_axis_labels (<b>time</b>, res, restick)<br> plot = gsn_csm_xy (wks, <b>time</b>, y, res) </div></div><div dir="ltr"><br></div><div>Pay close attention to the details in the function documentation for <b>time_axis_labels</b>. Note that most of the <b>"ttm"</b> input attributes for that procedure are optional. You only use them to get certain special effects if you want them.</div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 4, 2021 at 1:58 PM 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>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" 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="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></blockquote></div></blockquote></div></blockquote></div></div></blockquote></div></blockquote></div></div></div></div>
</blockquote></div>