<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"></p>
<div>Hi Rick,<br>
Please ignore my previous email. I checked again my test.h5 file with a brief ncl script where I used cd_calendar function:<br>
<br>
begin<br>
<br>
f = addfile("test.h5","r")<br>
<br>
time = f->time(0)<br>
<br>
utc_date = cd_calendar(time,0)<br>
  year   = tointeger(utc_date(:,0))    ; Convert to integer for<br>
   month  = tointeger(utc_date(:,1))    ; use sprinti<br>
   day    = tointeger(utc_date(:,2))<br>
   hour   = tointeger(utc_date(:,3))<br>
   minute = tointeger(utc_date(:,4))<br>
   second = tointeger(utc_date(:,5))<br>
<br>
date_str = sprinti("%0.4i", year) +"-"+ sprinti("%0.2i", month) +"-"+ sprinti("%0.2i ", day) + \<br>
               sprinti("%0.2i ", hour) + sprinti("%0.2i ", minute)+ sprinti("%0.2i ", second)<br>
<br>
<br>
print(date_str)<br>
print(time)<br>
print(utc_date)<br>
<br>
and I got correct time value with this function:<br>
Variable: date_str<br>
Type: string<br>
Total Size: 8 bytes<br>
            1 values<br>
Number of Dimensions: 1<br>
Dimensions and sizes:   [1]<br>
Coordinates:<br>
(0)     2017-07-01 00 00 05<br>
<br>
<br>
Variable: time<br>
Type: double<br>
Total Size: 8 bytes<br>
            1 values<br>
Number of Dimensions: 1<br>
Dimensions and sizes:   [DIM_000 | 1]<br>
Coordinates:<br>
Number Of Attributes: 1<br>
  units :       days since 1970-01-01<br>
(0)     17348.00006944444<br>
<br>
<br>
Variable: utc_date<br>
Type: float<br>
Total Size: 24 bytes<br>
            6 values<br>
Number of Dimensions: 2<br>
Dimensions and sizes:   [1] x [6]<br>
Coordinates:<br>
Number Of Attributes: 1<br>
  calendar :    standard<br>
(0,0)   2017<br>
(0,1)    7<br>
(0,2)    1<br>
(0,3)    0<br>
(0,4)    0<br>
(0,5)   06<br>
<br>
However, date_str gives one second earlier time. Moreover, I also checked the test.h5 file in CDO with cdo sinfo test.h5 and it also gives correct time values.<br>
Best regards, Beata</div>
<br>
<p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> ncl-talk <ncl-talk-bounces@ucar.edu> on behalf of Beáta Szabó-Takács <szabo.b@czechglobe.cz><br>
<b>Sent:</b> Wednesday, May 30, 2018 5:56:48 PM<br>
<b>To:</b> Rick Brownrigg<br>
<b>Cc:</b> ncl-talk (ncl-talk@ucar.edu)<br>
<b>Subject:</b> Re: [ncl-talk] Strange units of time</font>
<div> </div>
</div>
<meta content="text/html; charset=utf-8">
<meta name="x_Generator" content="Microsoft Word 15 (filtered medium)">
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
a:x_link, span.x_MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:x_visited, span.x_MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
p.x_MsoNoSpacing, li.x_MsoNoSpacing, div.x_MsoNoSpacing
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
p.x_m-807346121106154904msonospacing, li.x_m-807346121106154904msonospacing, div.x_m-807346121106154904msonospacing
        {margin-right:0cm;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
span.x_EmailStyle18
        {font-family:"Calibri",sans-serif;
        color:#1F497D}
.x_MsoChpDefault
        {font-family:"Calibri",sans-serif}
@page WordSection1
        {margin:70.85pt 70.85pt 70.85pt 70.85pt}
div.x_WordSection1
        {}
-->
</style>
<div lang="HU" link="blue" vlink="purple">
<div class="x_WordSection1">
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D">Hi Rick,</span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D">Thank you for your response. I use NCL in a server where NCL 6.3 and NCL 6.4.0 are installed. If I want to use NCL 6.4.0 I have to export NCARG_ROOT=/opt/ncl640 export PATH=$NCARG_ROOT/bin/:$PATH. To be
 honest I forgot to export. I checked it with NCL 6.4.0 as well and I got correct units. I checked the test.h5 in Panoply as well.
</span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D"> </span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D">I do not understand why NCL and Panoply are not able to convert the serial date to date even though I add an attribute as units is days since 1971-01-01? I created also NetCDF file in Java based on
<a href="https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/tutorial/NetcdfWriting.html">
https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/tutorial/NetcdfWriting.html</a> and I used the same serial date number with same attribute and both Panoply and NCL are able to convert it to date. Is it possible that the matter is that the
 time can be declared as dimension in NetCDF file e.g:</span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D"> </span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D">Dimension timeDim = ncfile.addUnlimitedDimension("time");</span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D">Variable time = ncfile.addVariable(null, "time", DataType.DOUBLE, "time");</span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D">time.addAttribute( new Attribute("units", "days since 1970-01-01"));</span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D"> </span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D">but it is not possible in HDF5?</span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D">Thank you for your response in advance!</span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D">Best regards,</span></p>
<p class="x_MsoNoSpacing"><span style="color:#1F497D">Beata</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#1F497D"> </span></p>
<p class="x_MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri",sans-serif"> Rick Brownrigg [mailto:brownrig@ucar.edu]
<br>
<b>Sent:</b> Wednesday, May 30, 2018 3:15 PM<br>
<b>To:</b> Beáta Szabó-Takács <szabo.b@czechglobe.cz><br>
<b>Cc:</b> ncl-talk (ncl-talk@ucar.edu) <ncl-talk@ucar.edu><br>
<b>Subject:</b> Re: [ncl-talk] Strange units of time</span></p>
<p class="x_MsoNormal"> </p>
<div>
<div>
<div>
<div>
<p class="x_MsoNormal" style="margin-bottom:12.0pt">Hi,</p>
</div>
<p class="x_MsoNormal" style="margin-bottom:12.0pt">Its hard to say where the issue lies, offhand. Do you have other tools that can look at that HDF5 file, and is the odd units string absent there?</p>
</div>
<p class="x_MsoNormal" style="margin-bottom:12.0pt">If so, what version of NCL are you using?  If you are using the latest, 6.4.0, are you able to send that HDF5 file to me? (either email directly, is not too large, or see the instructions about our FTP site:<br>
<br>
   <a href="http://ncl.ucar.edu/ftp_files.shtml">http://ncl.ucar.edu/ftp_files.shtml</a><br>
<br>
)</p>
</div>
<p class="x_MsoNormal">Rick</p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<div>
<p class="x_MsoNormal"> </p>
<div>
<p class="x_MsoNormal">On Wed, May 30, 2018 at 2:38 AM, Beáta Szabó-Takács <<a href="mailto:szabo.b@czechglobe.cz" target="_blank">szabo.b@czechglobe.cz</a>> wrote:</p>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0cm 0cm 0cm 6.0pt; margin-left:4.8pt; margin-right:0cm">
<div>
<div>
<p class="x_MsoNormal" style="">Dear NCL Users,</p>
<p class="x_MsoNormal" style="">I wrote a HDF5 file in Java by IHDF5Writer <a href="http://svnsis.ethz.ch/doc/openbis/S176.0/ch/systemsx/cisd/hdf5/IHDF5Writer.html" target="_blank">
http://svnsis.ethz.ch/doc/openbis/S176.0/ch/systemsx/cisd/hdf5/IHDF5Writer.html</a></p>
<p class="x_MsoNormal" style="">Because IHDF5Writer can write timestamps as number of milliseconds since January 1, 1970, 00:00:00 GMT<span style="font-size:9.0pt; font-family:"Arial",sans-serif; color:#353833; background:white">
</span>I converted the java.Util.Date to serial date number as days since 1970-01-01.</p>
<p class="x_m-807346121106154904msonospacing">I wrote the time values into HDF5 file</p>
<p class="x_m-807346121106154904msonospacing">writer.writeDoubleArray("time", time);</p>
<p class="x_m-807346121106154904msonospacing">writer.string().setAttr("time", "units", "days since 1970-01-01");</p>
<p class="x_m-807346121106154904msonospacing"> </p>
<p class="x_MsoNormal" style="">I checked the resulted test.h5 in NCL and printed the time variable and I got the following result:</p>
<p class="x_m-807346121106154904msonospacing">fn = "test.h5"</p>
<p class="x_m-807346121106154904msonospacing">fi = addfile(fn, "r")</p>
<p class="x_m-807346121106154904msonospacing">time = fi->time</p>
<p class="x_m-807346121106154904msonospacing">time1 = time(0)</p>
<p class="x_m-807346121106154904msonospacing">print(time1)</p>
<p class="x_MsoNormal" style=""> </p>
<p class="x_m-807346121106154904msonospacing">Variable: time1</p>
<p class="x_m-807346121106154904msonospacing">Type: double</p>
<p class="x_m-807346121106154904msonospacing">Total Size: 8 bytes</p>
<p class="x_m-807346121106154904msonospacing">            1 values</p>
<p class="x_m-807346121106154904msonospacing">Number of Dimensions: 1</p>
<p class="x_m-807346121106154904msonospacing">Dimensions and sizes:   [1]</p>
<p class="x_m-807346121106154904msonospacing">Coordinates:</p>
<p class="x_m-807346121106154904msonospacing">Number Of Attributes: 1</p>
<p class="x_m-807346121106154904msonospacing">  units :       days since 1970-01-01tyeratelatedofileion</p>
<p class="x_m-807346121106154904msonospacing">(0)     17348.00006944444</p>
<p class="x_m-807346121106154904msonospacing"> </p>
<p class="x_m-807346121106154904msonospacing">Can someone let me know why ncl receive a strange units?
</p>
<p class="x_MsoNormal" style=""> </p>
</div>
</div>
<p class="x_MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<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" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></p>
</blockquote>
</div>
<p class="x_MsoNormal"> </p>
</div>
</div>
</div>
</body>
</html>