<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Alan,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">When you say &quot;this function&quot; are you still referring to the &quot;time_to_newtime&quot; function?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I took a look at this code, and it is indeed copying the &quot;calendar&quot; attribute. But, it *does* make use of this attribute via the previous calls to cd_calendar and cd_inv_calendar, which do recognize this attribute.  I believe the &quot;time_to_newtime&quot; code is just making sure that the calendar attribute is reattached to the return variable, if it existed on the input variable.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 6, 2014 at 12:07 PM, Alan Brammer <span dir="ltr">&lt;<a href="mailto:abrammer@albany.edu" target="_blank">abrammer@albany.edu</a>&gt;</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>What version of ncl are you using? I just tested a similar few lines of code in 6.1.1 and 6.2.0 and they both copied the calendar attribute as expected. Also have you tried cd_convert() seems to do the same thing? </div><div><br></div><div>However in these tests and looking around I have a strong suspicion there is a significant bug in this function.  In that the code copies the calendar attribute but does not actually make use of it and thus returns the wrong answer disguised as the correct one. </div><div><br></div><div><br></div><div>Attached is my edited code.  load this below a load &quot;....contibuted.ncl&quot; line if you have one and this version of the code will replace the stock version.  A developer will hopefully weigh in with more insight in this. </div><div><br></div><div><br></div><div>Good luck, </div><div><br></div><div>Alan</div><div><br></div><div><br></div><div><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 3, 2014 at 10:08 PM, Lam Hoang <span dir="ltr">&lt;<a href="mailto:lamhpvn@gmail.com" target="_blank">lamhpvn@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear NCL supporting team,<div>I want to convert the time units from a CMIP5 model to make them unique.</div><div>I try to use time_to_newtime function but unfortunately after convert the time units, the calendar attribute changes to &quot;gregorian&quot; as well. </div><div>What should I do if I want to keep the calendar attribute as the original time variable?</div><div><br></div><div>Regards,</div><div>Lam<br clear="all"><div><br></div><div><br></div><div><div>f = addfile(&quot;./oldtime_psl_day_NorESM1-M_historicalExt_r3i1p1_20060101-20121231.nc&quot;,&quot;r&quot;)</div><div>temp<span style="white-space:pre-wrap">                </span>= f-&gt;psl</div><div>t<span style="white-space:pre-wrap">        </span>= f-&gt;time</div><div><br></div><div>printVarSummary(t)</div><div><p style="margin:0px;font-size:11px;font-family:Menlo">*** Variable: t</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Type: double</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Total Size: 20440 bytes</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***             2555 values</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Number of Dimensions: 1</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[time | 2555]</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Coordinates: </p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***             time: [ 0.5..2554.5]</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Number Of Attributes: 6</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   bounds :<span style="white-space:pre-wrap">        </span>time_bnds</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   units :<span style="white-space:pre-wrap">        </span>days since 2006-01-01 00:00:00</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   <font color="#ff0000">calendar :<span style="white-space:pre-wrap">        </span>noleap</font></p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   axis :<span style="white-space:pre-wrap">        </span>T</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   long_name :<span style="white-space:pre-wrap">        </span>time</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   standard_name :<span style="white-space:pre-wrap">        </span>time</p></div><div><br></div><div>t<span style="white-space:pre-wrap">        </span>= time_to_newtime(t, &quot;days since 1850-01-01 00:00:00&quot;)</div><div><br></div><div>printVarSummary(t)<br></div></div><div><br></div><div><p style="margin:0px;font-size:11px;font-family:Menlo">*** Variable: t</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Type: double</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Total Size: 20440 bytes</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***             2555 values</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Number of Dimensions: 1</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[time | 2555]</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Coordinates: </p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***             time: [56978.5..59534.5]</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">*** Number Of Attributes: 6</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   <font color="#ff0000">calendar :<span style="white-space:pre-wrap">        </span>gregorian</font></p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   units :<span style="white-space:pre-wrap">        </span>days since 1850-01-01 00:00:00</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   bounds :<span style="white-space:pre-wrap">        </span>time_bnds</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   axis :<span style="white-space:pre-wrap">        </span>T</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   long_name :<span style="white-space:pre-wrap">        </span>time</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">***   standard_name :<span style="white-space:pre-wrap">        </span>time</p></div><span><font color="#888888"><div><br></div><div><br></div>-- <br>Hoang Phuc Lam<br>Viet Nam National Center of Hydro-Meteorology Forecasting<br>National Hydro-Meteorological Services of Vietnam<br>Mob: +84 12 1616 5258<br>Tel:   <a href="tel:%2B844%2038247002" value="+84438247002" target="_blank">+844 38247002</a><br>Fax:  <a href="tel:%2B844%2038254278" value="+84438254278" target="_blank">+844 38254278</a><br>
</font></span></div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div></div>