Hello
Earlier I responded to a query regarding about NCL's
"systemfunc" and the Unix "date" utility.
I thought it might be good to add a comment
about NCL's "ut_inv_calendar"
http://www.ncl.ucar.edu/Document/Functions/Built-in/ut_inv_calendar.shtml
and how it relates to the Unix "date" utility.
==== Original response
ncl > Sdatetime = "'2/26/2006 9:14:37 AM'"
ncl > time = systemfunc("date -d " +Sdatetime+ " '+%s'")
ncl > print(time)
Variable: time
Type: string
[snip]
(0) 1140970477
====
man date
will yield the following information [edited]
%s seconds since '00:00:00 1970-01-01 UTC' (a GNU extension)
The %s qualifier is a GNU extension which returns
a number [here, returned as a variable of type "string"].
This number represents the seconds since 1970-01-01
====
The same information can be attained using "ut_inv_calendar"
but it requires an additional bit of information.
By example:
ncl > units = "seconds since 1970-1-1 00:00:0.0"
ncl > TIME = ut_inv_calendar(2006, 2, 26 ,9 , 14, 37.0 ,units, 0)
ncl > print(TIME)
Variable: TIME
Type: double
units : seconds since 1970-1-1 00:00:0.0
(0) 1140945277
Note: this returns a variable of type double.
Also, I'm sure the reaction is "Hey, that's not the same number"
It is different by 25200 seconds [= 1140970477-1140945277]
Ummm, using a super computer one can determine that
7*3600 just happens to be 25200
Well, the additional qualifier for the unit is
ncl > units = "seconds since 1970-1-1 00:00:0.0 -7:00"
ncl > Time = ut_inv_calendar(2006, 2, 26 ,9 , 14, 37.0 ,units, 0)
ncl > print(Time)
Variable: Time
Type: double
units : seconds since 1970-1-1 00:00:0.0 7:00
(0) 1140970477
=====
Hope this helps ....
D
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 09 2006 - 13:22:45 MST
This archive was generated by hypermail 2.2.0 : Thu Mar 09 2006 - 17:28:09 MST