Support rendering of `cftime` time axes
See original GitHub issueproplot
doesn’t seem to know how to handle cftime
too well, which is increasingly more common in xarray
now and can handle various climate model calendars, making it pretty useful.
It looks like the auto-generated datetime axis fails and tries to fill in every single time step:
import numpy as np
import proplot as plot
import xarray as xr
datetime = np.arange('1990-01', '2000-01', dtype='datetime64[M]')
cftime = xr.cftime_range('1990-01', '2000-01', freq='M')
da_datetime = xr.DataArray(np.random.rand(len(datetime)), dims='time', coords=[datetime])
da_cftime = xr.DataArray(np.random.rand(len(cftime)), dims='time', coords=[cftime])
f, ax = plot.subplots()
%time ax.plot(da_datetime.time, da_datetime)
f, ax = plot.subplots()
%time ax.plot(da_cftime.time, da_cftime)
Timing comes out essentially equivalent but the latter hangs for 10-15 seconds, probably trying to render the image in the notebook.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Support rendering of `cftime` time axes · Issue #103 - GitHub
It looks like this is not supported natively by matplotlib. Do you get the same result? import matplotlib.pyplot as plt import ...
Read more >API — cftime 1.0 documentation
calendar: describes the calendar to be used in the time calculations. All the values currently defined in the CF metadata convention are supported....
Read more >xarray.CFTimeIndex
Compute the symmetric difference of two Index objects. take (indices[, axis, allow_fill, fill_value]). Return a new Index of the values selected ...
Read more >xCDAT Documentation
Generate bounds for axes supported by xcdat if they don't exist in the Dataset ... Optional centering of time coordinates using time bounds....
Read more >NetCDF Climate and Forecast (CF) Metadata Conventions
Independent Latitude, Longitude, Vertical, and Time Axes; 5.2. ... NetCDF does not support a character string type, so these must be represented as ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I discovered the problem; will close this soon.
I decided to also release a new version (v0.5.0), which includes Fabio’s colormaps and this fix. Feel free to update.