Skip to content

Conversation

spencerkclark
Copy link
Member

🚀 Pull Request

Addresses #75. I think we can probably close #16 as well.

Description

This makes it possible to plot cftime's universal datetime object, which was introduced in cftime 1.3.0. The following example now works:

import random

import cftime
import matplotlib.pyplot as plt
import nc_time_axis

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)

We will raise a ValueError if someone tries to plot dates without a specified calendar.

I have taken the liberty to update the example in the README to follow this approach, because it is simpler than using CalendarDateTime. Since nc-time-axis now requires cftime >= 1.5 (#69), this update should be safe.

@codecov-commenter
Copy link

Codecov Report

Merging #80 (ea208f6) into main (59c567d) will increase coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #80      +/-   ##
==========================================
+ Coverage   90.58%   90.69%   +0.10%     
==========================================
  Files           1        1              
  Lines         170      172       +2     
  Branches       41       42       +1     
==========================================
+ Hits          154      156       +2     
  Misses         11       11              
  Partials        5        5              
Impacted Files Coverage Δ
nc_time_axis/__init__.py 90.69% <100.00%> (+0.10%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59c567d...ea208f6. Read the comment docs.

Copy link
Contributor

@aulemahal aulemahal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good!
Good change to the readme, the example is now closer to a real usage.

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

Successfully merging this pull request may close these issues.

Why can't we just visualise a vanilla netcdftime.datetime
3 participants