[ncl-talk] Time string with 1 minute interval

Sakib Ahmed nonicknameforever at gmail.com
Fri Jul 12 12:51:50 MDT 2019


Hello NCL Community,

I'm stuck with a simple problem of creating time string with an interval of
1 minute. I'm working with a wind model and the output file doesn't have
any time coordinates attached. I'm using the cd_inv_calendar and cd_string
functions for creating time string.  In my model output, I have outputs
saved in each minute and in total, I have 900 minutes (15 hours) of data
stored in the output file. This is what I tried:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"

; model start time 2017-09-10 12Z

syyyy = 2017
smm = 09
sdd = 10
shh = 12

; model end time 2017-09-11 03Z


eyyyy = 2017
emm = 09
edd = 11
ehh = 03

timeUnits = "hours since 1800-01-01 00:00:00"

sdate = cd_inv_calendar(syyyy,smm,sdd,shh,00,00,timeUnits,0)
edate = cd_inv_calendar(eyyyy,emm,edd,ehh,00,00,timeUnits,0)

ntimes = toint((edate-sdate)/.01666666667) +1 ; model has 900 steps, each
step is 1 minute

times = new( (/ntimes/), "float")

times at units = timeUnits

do n=0,ntimes-1
   times(n) = tofloat(sdate + (.01666666667*n)) ;multiplying n by 1 makes
time interval as 1 hour. Multiplying n by 0.25 makes time interval 15
minutes. But multiplying by 0.01666666667 doesn't create 1 minute interval.
 end do

 time_str = cd_string(times,"%H%M UTC %d %c %Y")

print(time_str)

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Variable: time_str
Type: string
Total Size: 7200 bytes
            900 values
Number of Dimensions: 1
Dimensions and sizes:   [900]
Coordinates:
Number Of Attributes: 1
  _FillValue :  missing
(0)     1200 UTC 10 Sep 2017
(1)     1200 UTC 10 Sep 2017
(2)     1200 UTC 10 Sep 2017
(3)     1200 UTC 10 Sep 2017
(4)     1207 UTC 10 Sep 2017
(5)     1207 UTC 10 Sep 2017
(6)     1207 UTC 10 Sep 2017
(7)     1207 UTC 10 Sep 2017
(8)     1207 UTC 10 Sep 2017
(9)     1207 UTC 10 Sep 2017
(10)    1207 UTC 10 Sep 2017
(11)    1207 UTC 10 Sep 2017
(12)    1215 UTC 10 Sep 2017
(13)    1215 UTC 10 Sep 2017
.
.
.
(891)   0252 UTC 11 Sep 2017
(892)   0252 UTC 11 Sep 2017
(893)   0252 UTC 11 Sep 2017
(894)   0252 UTC 11 Sep 2017
(895)   0252 UTC 11 Sep 2017
(896)   0252 UTC 11 Sep 2017
(897)   0300 UTC 11 Sep 2017
(898)   0300 UTC 11 Sep 2017
(899)   0300 UTC 11 Sep 2017

--
Thank you,
Sakib Ahmed
Connecticut College
Environmental Studies Major,
New London, CT 06320
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190712/89a83058/attachment.html>


More information about the ncl-talk mailing list