<div dir="ltr"><div>Lzl lai, the first argument to the cd_calendar function must be one of the NCL basic "numeric" data types. See the function documentation. Your "time" variable is type int64, which is "extra-numeric", not "numeric". Please see the NCL reference manual under "Basic numeric types". The cd_calendar function needs to be updated, but NCL is not receiving maintenance right now.</div><div><br></div><div>The easy fix is to convert your "time" variable to type "double" before input to cd_calendar. This will probably work fine for units = "seconds since 1970-01-01".</div><div><br></div><div>However, there is a risk of loss of precision if some of your int64 time values are outside the range of exact integer representation for type double. You can check for exact conversion like this (untested):</div><div><br></div><div>time2 = todouble (time)</div><div>time3 = toint64 (time2)</div><div>if (any (time3 .ne. time)) then</div><div> print ("Warning, loss of precision when converting time coordinates.")</div><div> max_dif = max (abs (time3 - time))</div><div> print ("Maximum precision loss = " + max_dif + " seconds.")</div><div>end if</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 7, 2024 at 2:10 AM lzl lai via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, <div>I have a problem using cd_calendar to c<span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px">onvert time variable to a UT-referenced date.</span></div><div><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px">my data is ECMWF( monthly reanalysis), their </span>valid_time<span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px"> type is int64</span></div><div><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px">when I use cd_calendar, it shows fatal message:</span></div><div><span style="color:rgb(51,51,51);font-family:verdana,sans-serif;font-size:13.3333px">--------</span></div><div>Variable: time<br>Type: int64<br>Total Size: 8120 bytes<br> 1015 values<br>Number of Dimensions: 1<br>Dimensions and sizes: [valid_time | 1015]<br>Coordinates:<br> valid_time: [-946771200..1719792000]<br>Number Of Attributes: 4<br> long_name : time<br> standard_name : time<br> units : seconds since 1970-01-01<br> calendar : proleptic_gregorian<br>fatal:Argument type mismatch on argument (0) of (cd_calendar) can not coerce<br></div><div>--------------------</div><div><br></div><div>Can anyone help me to deal with this problem? Thank you very much</div></div>
</blockquote></div></div>