[ncl-talk] bug in ut_string_fix

Mary Haley haley at ucar.edu
Mon Nov 27 11:44:48 MST 2017


Jared,

Thanks for providing a simple script that shows the problem.

Apparently this function slipped through the cracks!  It was a easy
one-line fix to force ut_string_fix to call ut_calendar_fix instead of
ut_calendar under the hood. The documentation was also updated.

You can try this ut_string_fix.ncl, or just modify your own to make the
one-line fix.

--Mary





On Wed, Nov 22, 2017 at 11:07 AM, Jared Lee <jaredlee at ucar.edu> wrote:

> Oh, and one more thing. The documentation page for ut_string_fix should
> say to load ut_string_fix.ncl, rather than ut_string.ncl, in order to use
> the function.
>
> Jared
>
> On Wed, Nov 22, 2017 at 10:38 AM, Jared Lee <jaredlee at ucar.edu> wrote:
>
>> Hi, I and others have previously written about the bug in cd_string that
>> results in "60" being written in the seconds place, instead of incrementing
>> the minutes place by 1 and resetting seconds to 0. To address this,
>> ut_string_fix was introduced as a temporary fix. Unfortunately, I am
>> finding the same exact bug in ut_string_fix that is in both cd_string and
>> ut_string. I'll attach my script as a file, but for posterity in the web
>> archives, here's my short demo script, followed by the resulting output,
>> which demonstrates the problem. (The values for time that I specified were
>> copy-pasted from another script where I first discovered this bug.)
>>
>> -----
>> ;; bug_ut_string_fix.ncl
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/ut_string.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/ut_string_fix.ncl"
>>
>> time_units = "hours since 2000-01-01 00:00:00"
>> time_fmt = "%Y-%N-%D_%H:%M:%S"
>>
>> time = (/23375.86666666664d, 23376.33333333331d, 23376.61666666664d/)
>> time at units = time_units
>> time at calendar = "standard"
>> print(time)
>>
>> time_ut_string = ut_string(time, time_fmt)
>> print(time_ut_string)
>> time_ut_string_fix = ut_string_fix(time, time_fmt)
>> print(time_ut_string_fix)
>> time_cd_string = cd_string(time, time_fmt)
>> print(time_cd_string)
>>
>> -----
>>
>> And now here is the output from running the script:
>>
>> jaredlee at cheyenne5:~/tools/nclscripts/NREL_Alaska> ncl
>> bug_ut_string_fix.ncl
>>  Copyright (C) 1995-2017 - All Rights Reserved
>>  University Corporation for Atmospheric Research
>>  NCAR Command Language Version 6.4.0
>>  The use of this software is governed by a License Agreement.
>>  See http://www.ncl.ucar.edu/ for more details.
>>
>>
>> Variable: time
>> Type: double
>> Total Size: 24 bytes
>>             3 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [3]
>> Coordinates:
>> Number Of Attributes: 2
>>   calendar : standard
>>   units : hours since 2000-01-01 00:00:00
>> (0) 23375.86666666664
>> (1) 23376.33333333331
>> (2) 23376.61666666664
>>
>>
>> Variable: time_ut_string
>> Type: string
>> Total Size: 24 bytes
>>             3 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [3]
>> Coordinates:
>> Number Of Attributes: 1
>>   _FillValue : missing
>> (0) 2002-08-31_23:51:60
>> (1) 2002-09-01_00:19:60
>> (2) 2002-09-01_00:36:60
>>
>>
>> Variable: time_ut_string_fix
>> Type: string
>> Total Size: 24 bytes
>>             3 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [3]
>> Coordinates:
>> Number Of Attributes: 1
>>   _FillValue : missing
>> (0) 2002-08-31_23:51:60
>> (1) 2002-09-01_00:19:60
>> (2) 2002-09-01_00:36:60
>>
>>
>> Variable: time_cd_string
>> Type: string
>> Total Size: 24 bytes
>>             3 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [3]
>> Coordinates:
>> Number Of Attributes: 1
>>   _FillValue : missing
>> (0) 2002-08-31_23:51:60
>> (1) 2002-09-01_00:19:60
>> (2) 2002-09-01_00:36:60
>>
>> -----
>>
>> Jared
>>
>> --
>> ===============================
>> Jared A. Lee, Ph.D.
>> Project Scientist I
>> Research Applications Laboratory
>> National Center for Atmospheric Research
>> Boulder, Colorado, USA
>>
>> Member, AMS Planning Commission
>>
>> Email: jaredlee at ucar.edu (w)
>> Phone: 303.497.8485 <(303)%20497-8485> (w)
>> Web: https://staff.ucar.edu/users/jaredlee
>> ===============================
>>
>
>
>
> --
> ===============================
> Jared A. Lee, Ph.D.
> Project Scientist I
> Research Applications Laboratory
> National Center for Atmospheric Research
> Boulder, Colorado, USA
>
> Member, AMS Planning Commission
>
> Email: jaredlee at ucar.edu (w)
> Phone: 303.497.8485 <(303)%20497-8485> (w)
> Web: https://staff.ucar.edu/users/jaredlee
> ===============================
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171127/bf5c1968/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ut_string_fix.ncl
Type: application/octet-stream
Size: 7687 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171127/bf5c1968/attachment.obj>


More information about the ncl-talk mailing list