[ncl-talk] A bug of use cd_calendar , second = 60

qiuxiaobin.tj qiuxiaobin.tj at qq.com
Sun Feb 19 01:55:23 MST 2017


Dear all

I met a bug when use cd_calendar. Some times it return second = 60.
Here is the input time:
Variable: time
Type: double
Total Size: 680 bytes
            85 values
Number of Dimensions: 1
Dimensions and sizes:	[time | 85]
Coordinates:
Number Of Attributes: 3
  _FillValue :	9.969209968386869e+36
  calendar :	gregorian
  units :	hours since 1601-01-01 00:00:0.0
(0)	3615141
(1)	3615141.083333333
(2)	3615141.166666667
(3)	3615141.25
(4)	3615141.333333333
(5)	3615141.416666667
(6)	3615141.5
(7)	3615141.583333333
(8)	3615141.666666667
(9)	3615141.75
(10)	3615141.833333333
(11)	3615141.916666667
(12)	3615142
(13)	3615142.083333333
(14)	3615142.166666667
(15)	3615142.25
..............



Here is the scripts:


utc_date = cd_calendar(time, 0)
;
; Store return information into more meaningful variables.
;
year   = tointeger(utc_date(:,0))    ; Convert to integer for
month  = tointeger(utc_date(:,1))    ; use sprinti 
day    = tointeger(utc_date(:,2))
hour   = tointeger(utc_date(:,3))
minute = tointeger(utc_date(:,4))
second = tointeger(utc_date(:,5))


;
; Write out strings in the format "hhZ dd mmm yyyy".




date_str = sprinti("%0.4i",year) + "_" + sprinti("%0.2i",month) + "_" + sprinti("%0.2i",day) + "_" + sprinti("%0.2i",hour) + "_" + sprinti("%0.2i",minute) + "_" + sprinti("%0.2i",second)


print(date_str) 



Here is the output:
Variable: date_str
Type: string
Total Size: 680 bytes
            85 values
Number of Dimensions: 1
Dimensions and sizes:	[85]
Coordinates:
(0)	2013_05_31_21_00_00
(1)	2013_05_31_21_05_00
(2)	2013_05_31_21_09_60
(3)	2013_05_31_21_15_00
(4)	2013_05_31_21_20_00
(5)	2013_05_31_21_24_60
(6)	2013_05_31_21_30_00
(7)	2013_05_31_21_35_00
(8)	2013_05_31_21_39_60
(9)	2013_05_31_21_45_00
(10)	2013_05_31_21_50_00
(11)	2013_05_31_21_54_60
(12)	2013_05_31_22_00_00
(13)	2013_05_31_22_05_00
(14)	2013_05_31_22_09_60
(15)	2013_05_31_22_15_00



How to overcome this? Thanks a lot.


Best,
Xiaobin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170219/add38a73/attachment.html 


More information about the ncl-talk mailing list