Skip to content

Printing time coordinates with long time intervals #3098

@DPeterK

Description

@DPeterK

If you print a coordinate with a long time unit interval (one of months or years), the time coordinate points are not rendered as datetimes. This is not the case for shorter time unit intervals. For example:

a = np.arange(0, 34, 3)

tc = iris.coords.DimCoord(a, standard_name='time',
                          units=cf_units.Unit('months since 1970-01-01', calendar='gregorian'))
print(tc)
DimCoord([ 0  3  6  9 12 15 18 21 24 27 30 33], standard_name='time', calendar='gregorian')

tc2 = iris.coords.DimCoord(a, standard_name='time',
                           units=cf_units.Unit('days since 1970-01-01', calendar='gregorian'))
print(tc2)
DimCoord([1970-01-01 00:00:00, 1970-01-04 00:00:00, 1970-01-07 00:00:00,
       1970-01-10 00:00:00, 1970-01-13 00:00:00, 1970-01-16 00:00:00,
       1970-01-19 00:00:00, 1970-01-22 00:00:00, 1970-01-25 00:00:00,
       1970-01-28 00:00:00, 1970-01-31 00:00:00, 1970-02-03 00:00:00], standard_name='time', calendar='gregorian')

Follows on from #2354. Thanks to @PAGWatson for originally bringing this to our attention there.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions