Re: how to calculate the time by ncl ?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 11 2012 - 14:54:45 MDT

I think you want cd_calendar:

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

You can use option 3. I've written a little script that uses both options 0 and 3:

year = 2012
mon = 2
day = 28
hour = 12

;---Create dummy time array, with 12-hour increments
time = hour + ispan(0,120,12)
time@units = "hours since " + year + "-" + mon + "-" + day

cdt = cd_calendar(time,0) ; n x 6 array
cdt3 = cd_calendar(time,3) ; n array, YYYYMMDDHH
;print(cdt)

;--This is for convenience
years = toint(cdt(:,0))
mons = toint(cdt(:,1))
days = toint(cdt(:,2))
hours = toint(cdt(:,3))

;---Convert to formatted strings
smons = sprinti("%02i",mons)
sdays = sprinti("%02i",days)
shours = sprinti("%02i",hours) + ":00:00"

;---This is from opt=0
print(years + "/" + smons + "/" + sdays + " " + shours)

;---This is from opt=3
print(cdt3)

On Sep 10, 2012, at 4:17 AM, Jie Tang wrote:

> hi ncl-users:
> I want to calculate automaticlly time in ncl script
> For example.
> Now the time is :
> year=2012
> mon=2
> day=28
> hour=12
>
> Now I want to know the correct time information aftere 12 hours.
> how can I output the correct time?
> thank .you .
>
>
>
>
> --
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 11 14:54:55 2012

This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:41 MDT