[ncl-talk] Bug in cd_inv_calendar

Jared Lee jaredlee at ucar.edu
Tue Apr 7 16:42:16 MDT 2015


Hi, I just found a bug in cd_inv_calendar. I'm using NCL v6.3.0 on
Yellowstone.

I have discovered that if the 'seconds' variable has a @_FillValue
attribute, then the cd_inv_calendar function will return missing values. If
that attribute is not present, then the function works properly. The other
variables ('years', 'months', 'days', 'hours', and 'minutes') can all have
@_FillValue attributes (or not have them) and the function will work
properly, also. It's only the 'seconds' input variable that apparently
cannot have that attribute. Below I've included a simple code and output to
demonstrate the bug.

Sample code (bug_cd_inv_calendar.ncl):

************
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"

begin

yr = 2006
mo = 01
dy = 01
hr = 00
mn = 00
sc = 00

time_units = "hours since 2006-01-01 00:00:00"

time1 = cd_inv_calendar(yr, mo, dy, hr, mn, sc, time_units, 0)
print(time1)

sc at _FillValue = -999
time2 = cd_inv_calendar(yr, mo, dy, hr, mn, sc, time_units, 0)
print(time2)

yr at _FillValue = -999
mo at _FillValue = -999
dy at _FillValue = -999
hr at _FillValue = -999
mn at _FillValue = -999
delete(sc at _FillValue)
time3 = cd_inv_calendar(yr, mo, dy, hr, mn, sc, time_units, 0)
print(time3)

end
************

And here is the output from that sample code:

************
-bash-4.1$ ncl < bug_cd_inv_calendar.ncl
 Copyright (C) 1995-2015 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.3.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.


Variable: time1
Type: double
Total Size: 8 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates:
Number Of Attributes: 2
  calendar :    standard
  units :       hours since 2006-01-01 00:00:00
(0)        0


Variable: time2
Type: double
Total Size: 8 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates:
Number Of Attributes: 3
  _FillValue :  9.969209968386869e+36
  calendar :    standard
  units :       hours since 2006-01-01 00:00:00
(0)     9.969209968386869e+36


Variable: time3
Type: double
Total Size: 8 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates:
Number Of Attributes: 3
  _FillValue :  9.969209968386869e+36
  calendar :    standard
  units :       hours since 2006-01-01 00:00:00
(0)        0
***************

Jared

-- 
===============================
Jared A. Lee, Ph.D.
Project Scientist I
Research Applications Laboratory
National Center for Atmospheric Research
Boulder, Colorado, USA

Email: jaredlee at ucar.edu (w)
Phone: 303.497.8485 (w)
Web: https://staff.ucar.edu/users/jaredlee
===============================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150407/1a2a000f/attachment.html 


More information about the ncl-talk mailing list