Re: time conversion

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 11 2011 - 07:09:21 MDT

I don't use Matlab but maybe ...

time = (/730848.5, 730848.9/)
time@units = "days since Jan-1-0000 00:00:00"

date = cd_calendar(time,0) ; year,month,day,hour,minute,sec
print(date)

Due to the way 'cd_calendar' defines the initial day, you may
need to subtract 1 day

So ...

time = (/730848.5, 730848.9/) - 1 ; ?? adjust for different start day
date = cd_calendar(time,0)
print(date)

=====
The inverse is true also

t = cd_inv_calendar(2001,5,19,0,0,0,units,0) - 1 ; Matlab datenum
print(t)
========
cd_calendar is in v6.0.0

if you have an older version of NCL use

date = ut_calendar(time,0)

BUT in ut_calendar year 0 is treated like year 1 ...
so test to get the correct day

# Year 0 is not treated as year 1, like it is with the ut_calendar and
ut_inv_calendar functions.

=======

http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml

http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_inv_calendar.shtml

Good luck

On 7/10/11 9:55 PM, shinn wong wrote:
> Dear all,
> I've got a netcdf file with time in the MATLAB datenum format (eg.
> 730848.5, 730848.9, etc). How can I convert it into a UT-referenced date
> using ncl? Thanks in advance for any help and suggestions.
> Regards,
> Shinn
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 11 07:09:27 2011

This archive was generated by hypermail 2.1.8 : Tue Jul 12 2011 - 15:03:53 MDT