Re: ut_calendar

From: Mary Haley (haley AT XXXXXX)
Date: Sun Dec 21 2003 - 16:03:13 MST

  • Next message: Takeshi Enomoto: "ShadeLtContour and ShadeLtGtContour"

    >
    > Hi all,
    >
    > I am hoping some guru out there has stumbled across this quirk before...
    >
    > Regarding the ut_calendar function, I have a netcdf file with the time
    > units attribute defined as
    >
    > time@units = "Days since 0000-1-1 00:00:00 -0.00"
    >
    > These data were created in Matlab using the Matlab default function
    > datenum. This calendar function creates a serial date which is defined
    > exactly as above, at least that's what the documentation says. If I
    > generate a plot in ferret (another graphics package which deals with
    > netcdf files) I get what I'm looking for. That is the serial date
    > number (for example 731200.0000 corresponds to Dec 15, 2001) is
    > interpreted correctly and parsed into a string etc. In NCL I try
    >
    > time = 731200.0
    > time@units = "Days since 0000-1-1 00:00:00 -0.00"
    > print(ut_calendar(time,0))
    >
    > and get
    >
    > (0,0) 2002
    > (0,1) 12
    > (0,2) 15
    > (0,3) 0
    > (0,4) 0
    > (0,5) 0
    >
    > which is advanced by a year. The ncview utility, gives the same
    > interpretation as NCL, which I understand, is because they are both
    > based on udunits. The strange thing is that so is ferret. Any
    > suggestions?

    Derrick,

    It is my understanding that in Udunits year 0000 is treated as year
    0001. To test this, I wrote a small Udunits C program where I tried
    two different units of "days since 0000" and "days since 0001". Using
    an input value of 1 day, I got an answer of January 2, 0001 for both
    units. Using an NCL script, I got the same results.

    The NCL function "ut_calendar" calls Udunits directly, and doesn't
    touch the return values in any fashion.

    > I know there is a temporary work around by defining a new serial date
    > vector using greg2jul and jul2greg. However, I exchange files regularly
    > with ferret users. It would be problematic if we are constantly
    > distrustful of the date functions. Any ideas are appreciated...
    >
    >

    If Matlab and Ferret are producing different results than NCL and
    Ncview, then they might doing something additional when they encounter
    a start year of 0000.

    In fact, according to the Matlab "datenum" documentation, it states:

      "By default, the serial day 1 corresponds to 1-Jan-0000."

    Also, I saw a reference to Udunits and Ferret in a Ferret FAQ:

      http://ferret.pmel.noaa.gov/Ferret/Mail_Archives/fu_99/msg00060.html

    Note that it talks about a hack to the Udunits interface.

    Can anybody out there shed some insight on the "year 0000" versus year
    "0001" issue?

    --Mary

    > best,
    > Derrick
    >
    > --
    > Derrick Snowden
    > PhOD/AOML/NOAA Office: 305.361.4322
    > 4301 Rickenbacker Causeway Fax: 305.361.4392
    > Miami, FL 33149 Derrick.Snowden AT noaa.gov
    >
    > _______________________________________________
    > ncl-talk mailing list
    > ncl-talk AT ucar.edu
    > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    >

    -- 
    -------------------------------------------------
    Mary Haley                   haley AT ucar.edu
    NCAR/SCD/VETS                303-497-1254 (voice)
    1850 Table Mesa Dr           303-497-1804 (fax)
    Boulder, CO  80305
    -------------------------------------------------
    _______________________________________________
    ncl-talk mailing list
    ncl-talk AT ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    



    This archive was generated by hypermail 2b29 : Sun Dec 21 2003 - 16:06:00 MST