<div dir="ltr"><div><div><div>Well, I think you have to look at your times. Please carefully read:<br> <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml">http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml</a><br><br>ncl 0> time = (/697594.5d, 1021954.5d/) ; min and max provided by user<br>ncl 1> time!0 = "time"<br>ncl 2> time@units = "hours since 1900-1-1 00:00:00" ; CDO created units<br>ncl 3> ymdhms = cd_calendar(time, 0)<br>ncl 4> print(ymdhms)<br><br><br>Variable: ymdhms<br>Type: float<br>Total Size: 48 bytes<br> 12 values<br>Number of Dimensions: 2<br>Dimensions and sizes: [2] x [6] . two time steps, 6 elements<br>Coordinates: <br>Number Of Attributes: 1<br> calendar : standard<br></div><div>(0,0) 1979 year<br></div><div>(0,1) 8 month<br></div><div>(0,2) 1 day<br></div><div>(0,3) 10 hour<br></div><div>(0,4) 30 minute<br></div><div>(0,5) 0 second<br><br></div><div>(1,0) 2016<br>(1,1) 8<br>(1,2) 1<br>(1,3) 10<br>(1,4) 30<br>(1,5) 0<br><br></div>So, your time variable spans 197908 to 201608.<br></div>You wrote:<br> "My data file contains single value for every year (JJAS season .."<br></div>So, <br><br> 197908<br> 198008<br> 198108<br> ..........<br> 201508<br> 201608<br><div><br><br></div><div>I think you should create:<br><br>ncl 5> year = ispan(1979,2016,1)<br>ncl 6> print(year)<br><br></div><div>This (year) should be your 'time' (x) axis.<br><br>======<br></div><div>Also, you said you used the following and it failed.<br></div><div>Did you read the documentation for either function?<br></div><div>A rule: (1) read documentation; (2) then, use the function<br></div><div><br><a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/yyyymm_time.shtml">http://www.ncl.ucar.edu/Document/Functions/Contributed/yyyymm_time.shtml</a><br><a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/yyyymm_to_yyyyfrac.shtml">http://www.ncl.ucar.edu/Document/Functions/Contributed/yyyymm_to_yyyyfrac.shtml</a><br></div><div><br>ncl 9> tstart = 1979<br>ncl 10> tend = 2016<br>ncl 11> yyyymm = yyyymm_time(tstart, tend, "integer")<br>ncl 12> yyyyfrac = yyyymm_to_yyyyfrac(yyyymm,0.0)<br><br>ncl 13> print(yyyymm+" "+yyyyfrac)<br><br>(0) 197901 1979 ; Note: the default print used 2 decimal place but there are more.<br>(1) 197902 1979.08<br>(2) 197903 1979.17<br>(3) 197904 1979.25<br>(4) 197905 1979.33<br>(5) 197906 1979.42<br>(6) 197907 1979.5<br>(7) 197908 1979.58<br></div><div>[snip]<br>(448) 201605 2016.33<br>(449) 201606 2016.42<br>(450) 201607 2016.5<br>(451) 201608 2016.58<br>(452) 201609 2016.67<br>(453) 201610 2016.75<br>(454) 201611 2016.83<br></div><div>(455) 201612 2016.92<br>(448) 201605 2016.33<br></div><div>(449) 201606 2016.42<br>(450) 201607 2016.5<br>(451) 201608 2016.58<br>(452) 201609 2016.67<br>(453) 201610 2016.75<br>(454) 201611 2016.83<br>(455) 201612 2016.92<br><br></div><div>you write: "<font face="georgia, serif">which gave the label in years but not for the full series of time"<br></font></div><div><font face="georgia, serif">I do not understand.</font> What is wrong with these numbers? <br><br><br></div><div><br><br></div><div><br><br></div><div><br><br></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 5, 2017 at 10:29 AM, Dhirendra Kumar <span dir="ltr"><<a href="mailto:dhirendra.cub@gmail.com" target="_blank">dhirendra.cub@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Mary</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Thank you for such a prompt reply.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">My data file contains single value for every year (JJAS season), and it was processed through CDO. The PrintMinMax gives the output:</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><div class="gmail_default" style="font-family:georgia,serif">Number Of Attributes: 6</div><div class="gmail_default" style="font-family:georgia,serif"> standard_name : time</div><div class="gmail_default" style="font-family:georgia,serif"> long_name : time</div><div class="gmail_default" style="font-family:georgia,serif"> bounds : time_bnds</div><div class="gmail_default" style="font-family:georgia,serif"> units : hours since 1900-1-1 00:00:00</div><div class="gmail_default" style="font-family:georgia,serif"> calendar : standard</div><div class="gmail_default" style="font-family:georgia,serif"> axis : T</div><div class="gmail_default" style="font-family:georgia,serif">(0) time: min=697594.5 max=1021954.5</div><div style="font-family:georgia,serif"><br></div><div style="font-family:georgia,serif">You were correct about the date. So that was the reason, it did not work. As I am a newbie here; could you please guide me further to correct the dates for the plotting with the same file. I have also tried using the function mentioned in the mail but it give labels starting from 7000. </div><div style="font-family:georgia,serif">Then I had tried adding the following line in the code: </div><div style="font-family:georgia,serif"><br></div><div><div><font face="georgia, serif"> tstart = 1979</font></div><div><font face="georgia, serif"> tend = 2016</font></div><div><font face="georgia, serif"> yyyymm = yyyymm_time(tstart, tend, "integer")</font></div><div><font face="georgia, serif"> yyyyfrac = yyyymm_to_yyyyfrac(yyyymm,0.0) ; create fractional years for</font></div><div><font face="georgia, serif"> ; plotting purposes</font></div></div><div><font face="georgia, serif"><br></font></div><div><font face="georgia, serif">which gave the label in years but not for the full series of time.</font></div><div><font face="georgia, serif"><br></font></div><div>Looking forward for your input.</div><div><br></div><div>Thanks</div><div><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 5, 2017 at 9:38 PM, Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dhirendra,<br><br>First, a couple of NCL tips:<br><br>1) <div class="gmail_default" style="font-size:small;display:inline">You don't need to use a "do" loop to do simple array arithmetic. You can replace the following code:</div><span><br><br><font face="monospace, monospace"> <div class="gmail_default" style="font-size:small;display:inline"> </div>dateF = new (dimDate, float) <br> do n=0,dimDate-1 <br> yyyy = date(n)/100 <br> mon = date(n)-yyyy*100<br> dateF(n) = tofloat(yyyy + (mon-1)/12.) <br> end do<br></font><br></span><div class="gmail_default" style="font-size:small;display:inline">with:</div><br><br><font face="monospace, monospace"> yyyy = date/100 <br> mon = date-yyyy*100<br> dateF = tofloat(yyyy + (mon-1)/12.) </font><br><br>2) We have a function that converts YYYYMM to YYYY.frac, so the above code can be replaced with<div class="gmail_default" style="font-size:small;display:inline"> one line:</div><br><br><font face="monospace, monospace"> dateF = yyyymm_to_yyyyfrac(date,0.0)</font><div><div class="gmail_default" style="font-size:small"><div class="gmail_default"><div class="gmail_default" style="font-size:12.8px"><br></div></div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The values on your X axis look suspicious to me, as they go from around 7000 to over 10000. Are these really your year values? Did you look at the original "date" variable to make sure these values are actually YYYYMM?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">printVarSummary(date)</font></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">printMinMax(date)</font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">You should also do:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">print(date) </font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">to see what all the numbers look like.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">To get nice labels on a time axis, I highly recommend the use of the time_axis_labels function:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Document/Functions/User_contributed/time_axis_labels.shtml" target="_blank">http://www.ncl.ucar.edu/Docume<wbr>nt/Functions/User_contributed/<wbr>time_axis_labels.shtml</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">You have lots of options for how to format your labels.</div><div class="gmail_default"><br></div><div class="gmail_default">You can see some examples of how to use this at:</div><div class="gmail_default"><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Applications/time_labels.shtml" target="_blank">http://www.ncl.ucar.edu/Applic<wbr>ations/time_labels.shtml</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">In particular, look at time_labels_4.ncl. This shows how to plot time data that is in a YYYYMM format. I'm not sure your time is in this format, but hopefully the above page will give you enough information to format your X labels the way you want them.</div><div class="gmail_default"><br></div><div class="gmail_default">--Mary</div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_8964310496104972692h5">On Thu, Jan 5, 2017 at 8:09 AM, Dhirendra Kumar <span dir="ltr"><<a href="mailto:dhirendra.cub@gmail.com" target="_blank">dhirendra.cub@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_8964310496104972692h5"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif"><div class="gmail_default" style="font-size:12.8px">Hi</div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default" style="font-size:12.8px">I am trying to plot an nc file having anomaly time series for the JJAS season. I have tried to follow the sample scripts over the NCL web resource, but could not succeed in getting the correct labels of time (year) on the X axis.</div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default" style="font-size:12.8px">Would appreciate if anybody could help...</div><div class="gmail_default" style="font-size:12.8px">the script is as following- </div><div class="gmail_default" style="font-size:12.8px"><br></div><div class="gmail_default" style="font-family:arial,sans-serif;font-size:12.8px"><div class="gmail_default"><font face="georgia, serif">begin</font></div><div class="gmail_default"><font face="georgia, serif"> f = addfile ("<a href="http://std_tim_anomaly.nc/" target="_blank">std_tim_anomaly.nc</a>", "r") ; add file</font></div><div class="gmail_default"><font face="georgia, serif"> date = f->time</font></div><div class="gmail_default"><font face="georgia, serif"> printVarSummary(date)</font></div><div class="gmail_default"><font face="georgia, serif"> precip= f->tp(:,0,0)</font></div><div class="gmail_default"><font face="georgia, serif"> printVarSummary(precip)</font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif"> dimDate = dimsizes(date) ; number of dates</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">; convert integer YYYYMM to float</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif"> dateF = new (dimDate, float) </font></div><div class="gmail_default"><font face="georgia, serif"> do n=0,dimDate-1 </font></div><div class="gmail_default"><font face="georgia, serif"> yyyy = date(n)/100 </font></div><div class="gmail_default"><font face="georgia, serif"> mon = date(n)-yyyy*100</font></div><div class="gmail_default"><font face="georgia, serif"> dateF(n) = tofloat(yyyy + (mon-1)/12.) </font></div><div class="gmail_default"><font face="georgia, serif"> end do</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">;*****************************<wbr>****</font></div><div class="gmail_default"><font face="georgia, serif">; create plot</font></div><div class="gmail_default"><font face="georgia, serif">;*****************************<wbr>***</font></div><div class="gmail_default"><font face="georgia, serif"> wks = gsn_open_wks ("ps", "bar" ) ; send graphics to PS file</font></div><div class="gmail_default"><font face="georgia, serif"> res = True ; plot mods desired</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnScale = True </font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif">; these four resources allow the user to stretch the plot size, and</font></div><div class="gmail_default"><font face="georgia, serif">; decide exactly where on the page to draw it.</font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif"> res@vpXF = 0.10 ; In page coordinates, where to start</font></div><div class="gmail_default"><font face="georgia, serif"> res@vpYF = 0.75 ; the plot</font></div><div class="gmail_default"><font face="georgia, serif"> res@vpHeightF = 0.43 ; Changes the aspect ratio</font></div><div class="gmail_default"><font face="georgia, serif"> res@vpWidthF = 0.85</font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif"> res@trYMinF = -3.0 ; min value on y-axis</font></div><div class="gmail_default"><font face="georgia, serif"> res@trYMaxF = 3.0 ; max value on y-axis</font></div><div class="gmail_default"><font face="georgia, serif"> </font></div><div class="gmail_default"><font face="georgia, serif"> res@tiYAxisString = "Anomalies" ; y-axis label </font></div><div class="gmail_default"><font face="georgia, serif">; this resource changes a regular line plot to a bar chart</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnXYBarChart = True ; create bar chart </font></div><div class="gmail_default"><font face="georgia, serif">; this resource is required to get bars above and below a reference line</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnYRefLine = 0. ; reference line </font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnXYBarChart = True ; create bar chart </font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnAboveYRefLineColor = "red" ; above ref line fill red</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnBelowYRefLineColor = "blue" ; below ref line fill blue</font></div><div class="gmail_default"><font face="georgia, serif"> res@gsnXYBarChartBarWidth = 24.0</font></div><div class="gmail_default"><font face="georgia, serif"> plot = gsn_csm_xy (wks,dateF(::),precip,res)</font></div><div class="gmail_default"><font face="georgia, serif">end</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif"><img src="cid:ii_1596f07b17109416" alt="Inline image 1" class="m_8964310496104972692m_3982256965907451223m_4754589073469523680gmail-CToWUd m_8964310496104972692m_3982256965907451223m_4754589073469523680gmail-a6T" height="285" width="524"></font><span style="font-family:georgia,serif">this is the plot which is being created.</span><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">Thanks in anticipation.</font></div></div></div><span class="m_8964310496104972692m_3982256965907451223HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_8964310496104972692m_3982256965907451223m_4754589073469523680gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">==============================<wbr>==========</div><div dir="ltr">Dhirendra Kumar<div>PhD Student<br></div><div>School of Environmental Sciences, JNU<br></div><div>New Delhi (India)</div><div>Contact: <font face="comic sans ms, sans-serif"><a href="tel:+91%2099107%2078043" value="+919910778043" target="_blank">+91 9910778043</a></font></div><div>Alternate email: <a href="mailto:dhirendra.cub@outlook.com" target="_blank">dhirendra.cub@outlook.com</a></div><div>==============================<wbr>===========</div></div></div></div></div></div></div></div></div></div></div>
</font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_8964310496104972692gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">==============================<wbr>==========</div><div dir="ltr">Dhirendra Kumar<div>PhD Student<br></div><div>School of Environmental Sciences, JNU<br></div><div>New Delhi (India)</div><div>Contact: <font face="comic sans ms, sans-serif"><a href="tel:+91%2099107%2078043" value="+919910778043" target="_blank">+91 9910778043</a></font></div><div>Alternate email: <a href="mailto:dhirendra.cub@outlook.com" target="_blank">dhirendra.cub@outlook.com</a></div><div>==============================<wbr>===========</div></div></div></div></div></div></div></div></div></div></div>
</div>
</div></div><br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>