question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support rendering of `cftime` time axes

See original GitHub issue

proplot 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.

Screen Shot 2020-01-08 at 1 36 15 PM Screen Shot 2020-01-08 at 1 36 19 PM

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
lukelbdcommented, Feb 10, 2020

I discovered the problem; will close this soon.

0reactions
lukelbdcommented, Feb 11, 2020

I decided to also release a new version (v0.5.0), which includes Fabio’s colormaps and this fix. Feel free to update.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found