<div dir="ltr"><div dir="ltr"><div>The results look like this. I do not show the individual year, month day arrays, but they are in there if you need them. Is this what you are looking for?</div><div><br></div><div><div>Variable: time2</div><div>Type: double</div><div>Total Size: 64 bytes</div><div> 8 values</div><div>Number of Dimensions: 1</div><div>Dimensions and sizes:<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>[8]</div><div>Coordinates: </div><div>Number Of Attributes: 2</div><div> calendar :<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>gregorian</div><div> units :<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>days since 1850-1-1</div><div>(0)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>30.99444444105029</div><div>(1)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>58.99444444105029</div><div>(2)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>56551.99444444105</div><div>(3)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>56581.99444444105</div><div>(4)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>56612.99444444105</div><div>(5)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>56643.99444444105</div><div>(6)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>56946.99444444105</div><div>(7)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>56977.99444444105</div><div>(0)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span></div><div>(0)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>1850-01-31 23:51:59</div><div>(1)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>1850-02-28 23:51:59</div><div>(2)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>2004-10-31 23:51:59</div><div>(3)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>2004-11-30 23:51:59</div><div>(4)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>2004-12-31 23:51:59</div><div>(5)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>2005-01-31 23:51:59</div><div>(6)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>2005-11-30 23:51:59</div><div>(7)<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>2005-12-31 23:51:59</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 17, 2020 at 2:57 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-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Your input time format is valid, but it is non-standard, so it must be converted with code. Function <b>cd_calendar</b> does not understand this format. Here is some code that creates two different formats, depending on what you want to do next. One format is year, month, day in separate arrays. The other is standard relative time offsets, like you would read in from a CF conforming Netcdf data set.<br><br>Note that proleptic_gregorian is exactly the same as normal Gregorian calendar in this time range.<br><br>Thanks to Dennis Shea for assisting with this reply.<br><br></div><div><font face="monospace">load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"</font></div><div><font face="monospace">begin</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">; This part simulates the original input data, for demo only.</font></div><div><font face="monospace">; It should be deleted and replaced with the original input code.</font></div><div><font face="monospace">; This is a non-standard format, decimal coded integers plus fraction of day.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> time = (/18500131.99444444d0, 18500228.99444444d0 \</font></div><div><font face="monospace"> ,20041031.99444444d0, 20041130.99444444d0 \</font></div><div><font face="monospace"> ,20041231.99444444d0, 20050131.99444444d0 \</font></div><div><font face="monospace"> ,20051130.99444444d0, 20051231.99444444d0 /)</font></div><div><font face="monospace"> time!0 = "time"</font></div><div><font face="monospace"> time@units = "day as %Y%m%d.%f" ; udunits does not understand this</font></div><div><font face="monospace"> time@calendar = "proleptic_gregorian"</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">; This part converts the decimal coded dates to year, month, day arrays.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> YYYY = toint(time/10000)</font></div><div><font face="monospace"> MMDD = toint(time-YYYY*10000)</font></div><div><font face="monospace"> MM = MMDD/100</font></div><div><font face="monospace"> DD = MMDD-MM*100</font></div><div><font face="monospace"> frac = time-toint(time) ; this is fraction of day, 0.0 to 1.0</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">; Now convert the year, month, day arrays to CF standard relative times.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> H = DD ; dummy time of day arrays = 00:00:00, will be replaced</font></div><div><font face="monospace"> H = 0</font></div><div><font face="monospace"> M = H</font></div><div><font face="monospace"> S = H</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> units2 = "days since 1850-1-1"</font></div><div><font face="monospace"> opt = 0</font></div><div><font face="monospace"> opt@calendar = "gregorian"</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> time2 = cd_inv_calendar (YYYY, MM, DD, H, M, S, units2, opt)</font></div><div><font face="monospace"> time2 = time2 + frac ; add fraction of day back in, no conversion needed</font></div><div><font face="monospace"> print (time2)</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">; Decode final result, and display.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> print ("")</font></div><div><font face="monospace"> strings = cd_string (time2, "%Y-%N-%D %H:%M:%S")</font></div><div><font face="monospace"> print (strings+"")</font></div><div><font face="monospace">end</font></div></div><div></div><div dir="ltr"><br></div><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 17, 2020 at 6:15 AM Sri nandini 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-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hello dear ncl-users<br>
<br>
I am trying to convert the time proleptic_gregorian calendar in the time <br>
format of my data to UTC date, so that irs easier to extract the years <br>
to work with.<br>
<br>
The original print time output is this:<br>
<br>
Variable: time<br>
Type: double<br>
Total Size: 14976 bytes<br>
1872 values<br>
Number of Dimensions: 1<br>
Dimensions and sizes: [time | 1872]<br>
Coordinates:<br>
time: [18500131.99444444..20051231.99444444]<br>
Number Of Attributes: 4<br>
standard_name : time<br>
units : day as %Y%m%d.%f<br>
calendar : proleptic_gregorian<br>
axis : T<br>
(0) 18500131.99444444<br>
(1) 18500228.99444444<br>
(2) 18500331.99444444<br>
(3) 18500430.99444444<br>
(4) 18500531.99444444<br>
(5) 18500630.99444444<br>
(6) 18500731.99444444<br>
(7) 18500831.99444444<br>
(8) 18500930.99444444<br>
(9) 18501031.99444444<br>
(10) 18501130.99444444<br>
(11) 18501231.99444444<br>
(12) 18510131.99444444<br>
(13) 18510228.99444444<br>
(14) 18510331.99444444<br>
(15) 18510430.99444444<br>
(16) 18510531.99444444<br>
(17) 18510630.99444444<br>
................continued<br>
<br>
(1852) 20040531.99444444<br>
(1853) 20040630.99444444<br>
(1854) 20040731.99444444<br>
(1855) 20040831.99444444<br>
(1856) 20040930.99444444<br>
(1857) 20041031.99444444<br>
(1858) 20041130.99444444<br>
(1859) 20041231.99444444<br>
(1860) 20050131.99444444<br>
(1861) 20050228.99444444<br>
(1862) 20050331.99444444<br>
(1863) 20050430.99444444<br>
(1864) 20050531.99444444<br>
(1865) 20050630.99444444<br>
(1866) 20050731.99444444<br>
(1867) 20050831.99444444<br>
(1868) 20050930.99444444<br>
(1869) 20051031.99444444<br>
(1870) 20051130.99444444<br>
(1871) 20051231.99444444<br>
<br>
yrStrt = 1986<br>
yrLast = 2005<br>
<br>
f = addfile ("<a href="http://hist_1850-2005_wind10.nc" rel="noreferrer" target="_blank">hist_1850-2005_wind10.nc</a>", "r")<br>
time = f->time<br>
print(time) see above output<br>
<br>
; convert the time proleptic_gregorian calendar to UTC date<br>
YYYY = cd_calendar(time,-1)/100 ;-- convert date to <br>
UT-referenced date<br>
; Set date variable names<br>
year = tointeger(utc_date(:,0)) ;-- get year as <br>
integer value<br>
month = tointeger(utc_date(:,1)) ;-- get month as <br>
integer value<br>
day = tointeger(utc_date(:,2)) ;-- get day as <br>
integer value<br>
hour = tointeger(utc_date(:,3)) ;-- get hour as <br>
integer value<br>
minute = tointeger(utc_date(:,4)) ;-- get minute as <br>
integer value<br>
; Write date as a string (<a href="http://YYYY.MM" rel="noreferrer" target="_blank">YYYY.MM</a>)<br>
date_str = sprinti("%0.4i",year) + "/" + sprinti("%0.2i", month)<br>
return(date_str)<br>
<br>
;-- retrieve the indices of the selected years<br>
<br>
iYYYY = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)<br>
print(iYYYY)<br>
hist_anom=f->wind10(iYYYY,:,:,:)<br>
<br>
but i get the error:<br>
<br>
CDMS error: Error on relative units conversion, string = day as %Y%m%d.%f<br>
<br>
CDMS error: Error on time conversion: invalid month = 10085<br>
<br>
Can someone help me to solve this?<br>
<br>
Sri<br></blockquote></div></div></div></div></div></div>
</blockquote></div></div></div>