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

Issues with dates with non default unit #40

Closed
philippjfr opened this issue Dec 3, 2018 · 1 comment
Closed

Issues with dates with non default unit #40

philippjfr opened this issue Dec 3, 2018 · 1 comment

Comments

@philippjfr
Copy link

This is more of a usage question so apologies if this is the incorrect place to ask this. I'm trying to plot some xarray data but am running into issues with dates that have custom 'days since x' units, e.g. adapting the example from the README this code errors for me:

import random

import matplotlib.pyplot as plt
import xarray as xr
import nc_time_axis
import cftime

dates = xr.cftime_range(start='0001', periods=24, freq='MS', calendar='noleap')
c_d_time = [nc_time_axis.CalendarDateTime(item, "noleap") for item in dates]
temperatures = [round(random.uniform(0, 12), 3) for _ in range(len(c_d_time))]

plt.plot(c_d_time, temperatures)
plt.margins(0.1)
plt.ylim(0, 12)
plt.xlabel("Date")
plt.ylabel("Temperature")
plt.show()
ValueError: invalid year provided in cftime.DatetimeNoLeap(0, 10, 23, 2, 24, 0, 8, 3, 296)

Apologies if I've missed something obvious but I would appreciate a pointer on how to deal with dates like this.

@philippjfr
Copy link
Author

I think this is simply due to an old version of cftime (1.0.0 vs 1.0.2.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant