NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: Time

>Date: Thu, 13 Jan 1994 11:04:32 -0500 (EST)
>From: PEPKE@xxxxxxxxxxxx
>To: netcdfgroup@xxxxxxxxxxxxxxxx
>Subject: Time

In the above message you wrote:

>I have a problem with time.  I have netCDF and the udunits packages.  I want to
>be able to write time-dependent meteorological datasets where the time is
>hours, minutes, and seconds, either local or Zulu time.
>
>I would like to do this, satisfying these conditions:
>
>A) I would like to do it in a standard, de facto standard, or quasistandard
>way.
>
>B) I would like my visualization program to be able to figure out, just by
>looking at the file without my having to press buttons, that the time should be
>displayed as hh:mm:ss.

I would store the times in a netCDF `double' variable with a unit
attribute something like "seconds since 1993-12-15 00:00 UTC".  I'd then
interpret and display the netCDF file in something like the following
manner:

    #include <udunits.h>
    ...

        char    string[128];    /* value & units print-buffer */
        utUnit  unit;           /* input units */
        double  value;          /* input value */
        ...
        if (utIsTime(unit))
        {
            /*
             * We're dealing with a temporal unit.
             */
            int         year, month, day, hour, minute;
            float       second;

            (void) utCalendar(value, unit, &year, &month, &day, &hour, 
                              &minute, &second);
            (void) sprintf(string, "%d-%d-%d %d:%d:%d UTC", year, month,
                           day, hour, minute, (int)second);
        }
        else
        {
            /*
             * We're dealing with a non-temporal unit.
             */
            (void) sprintf(string, "%g ", value);
            (void) utPrint(unit, string + strlen(string));
        }

>Also, is there such a thing as a udunits document?

Yes.  It's the manual page in the UDUNITS package.

--------
Steve Emmerson   <steve@xxxxxxxxxxxxxxxx>


  • References:
  • 1994 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: