home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 594436316

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
594436316 MDExOlB1bGxSZXF1ZXN0Mzk5MDYzNDQ1 3935 Add a days_in_month accessor to CFTimeIndex 6628425 closed 0     3 2020-04-05T12:38:50Z 2020-04-06T14:02:58Z 2020-04-06T14:02:11Z MEMBER   0 pydata/xarray/pulls/3935
  • [x] Tests added
  • [x] Passes isort -rc . && black . && mypy . && flake8
  • [x] Fully documented, including whats-new.rst for all changes and api.rst for new API

This adds a days_in_month accessor to CFTimeIndex, which allows for easy computation of monthly time weights for non-standard calendars: ``` In [1]: import xarray as xr

In [2]: times = xr.cftime_range("2000", periods=24, freq="MS", calendar="noleap")

In [3]: da = xr.DataArray(times, dims=["time"])

In [4]: da.dt.days_in_month Out[4]: <xarray.DataArray 'days_in_month' (time: 24)> array([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]) Coordinates: * time (time) object 2000-01-01 00:00:00 ... 2001-12-01 00:00:00 ```

This simplifies the "Calculating Seasonal Averages from Timeseries of Monthly Means" example @jhamman wrote for the docs a while back, which I've taken the liberty of updating.

The ability to add this feature to xarray is thanks in large part to @huard, who added a daysinmonth attribute to cftime.datetime objects late last year: https://github.com/Unidata/cftime/pull/138.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3935/reactions",
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 pull

Links from other tables

  • 1 row from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.518ms · About: xarray-datasette