Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable plotting of now calendar-aware cftime.datetime objects #75

Closed
spencerkclark opened this issue Aug 8, 2021 · 1 comment
Closed
Labels
New: Feature Highlight a new community raised "feature request" issue
Milestone

Comments

@spencerkclark
Copy link
Member

spencerkclark commented Aug 8, 2021

✨ Feature Request

In cftime version 1.3.0 cftime.datetime objects are now calendar-aware. Eventually this will obviate the need for calendar-specific subclasses, like cftime.DatetimeNoLeap. nc-time-axis currently does not register cftime.datetime objects in matplotlib's units registry, so matplotlib does not attempt to convert them. It would be great if -- similar to the subclasses -- we could also directly plot the new calendar-aware base class using nc-time-axis.

Motivation

E.g. while we can currently do:

import random

import cftime
import matplotlib.pyplot as plt
import nc_time_axis

dt = [cftime.DatetimeNoLeap(2017, 2, day) for day in range(1, 28)]
temperatures = [round(random.uniform(0, 12), 3) for _ in range(len(dt))]
plt.plot(dt, temperatures)

It would be great if we could also do:

dt = [cftime.datetime(2017, 2, day, calendar="noleap") for day in range(1, 28)]
temperatures = [round(random.uniform(0, 12), 3) for _ in range(len(dt))]
plt.plot(dt, temperatures)

This currently results in an error, because matplotlib does not convert the dates.

@spencerkclark spencerkclark added the New: Feature Highlight a new community raised "feature request" issue label Aug 8, 2021
@spencerkclark spencerkclark added this to the v1.4.0 milestone Aug 14, 2021
@spencerkclark
Copy link
Member Author

Closed by #80.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New: Feature Highlight a new community raised "feature request" issue
Projects
None yet
Development

No branches or pull requests

1 participant