Version 2 (modified by domlowe, 13 years ago) (diff)

minor edit.

Calendars supported in CSML for NDG2

In CSML we need to support various calendar systems to describe temporal data. We are using the currently CDAT's cdms.cdtime module for manipulating times and dates within various calendars. This seems to work well and offers support for the following calendars: (these definitions are copied verbatim from  CDAT documentation).

  • cdtime.GregorianCalendar
    • years evenly divisible by four are leap years, except century years not evenly divisible by 400. This is sometimes called the proleptic Gregorian calendar, meaning that the algorithm for leap years applies for all years.
  • cdtime.MixedCalendar
    • mixed Julian/Gregorian? calendar. Dates before 1582-10-15 are encoded with the Julian calendar, otherwise are encoded with the Gregorian calendar. The day immediately following 1582-10-4 is 1582-10-15. This is the default calendar.
  • cdtime.JulianCalendar
    • years evenly divisible by four are leap years,
  • cdtime.NoLeapCalendar
    • all years have 365 days,
  • cdtime.Calendar360
    • all months have 30 days.

However we would like to ensure we support the CF conventions.  CF Conventions 1.0 defines the following calendar definitions:

  • gregorian or standard
  • proleptic_gregorian
    • A Gregorian calendar extended to dates before 1582-10-15. That is, a year is a leap year if either (i) it is divisible by 4 but not by 100 or (ii) it is divisible by 400.
  • noleap or 365_day
    • Gregorian calendar without leap years, i.e., all years are 365 days long.
  • all_leap or 366_day
    • Gregorian calendar with every year being a leap year, i.e., all years are 366 days long.
  • 360_day
    • All years are 360 days divided into 30 day months.
  • julian
    • Julian calendar.
  • none
    • No calendar.

So to map the CF conventions to the cdtime module. We get:

  • 'standard' == cdtime.MixedCalendar
  • 'gregorian' == cdtime.MixedCalendar
  • 'proleptic_gregorian' == cdtime.GregorianCalendar
  • '360_day' == cdtime.!Calendar360
  • 'noleap' == cdtime.NoLeapCalendar
  • '365_day' == cdtime.NoLeapCalendar
  • 'julian' == cdtime.JulianCalendar
  • 'none' == no calendar

So the only CF calendar that isn't handled by cdtime is the all_leap (a.k.a. 366_day) calendar. The sensible thing to do would be to try and provide support for this as a new calendar within the cdtime module.