Skip to content

Commit

Permalink
Use cftime for temporal averaging operations (#302)
Browse files Browse the repository at this point in the history
* attempted fix for #301: use cftime for temporal operations

* Update temporal accessor to use specific cftime objects
- Update format of `decode_non_cf_time()` conditional statement
- Update `time_cf` with encoding dict attributes (xarray behavior)
- Update `test_dataset.py` and `test_temporal.py` with specific `cftime` date_type objects
- Add `xesmf` to `dev.yml`

Co-authored-by: Tom Vo <tomvothecoder@gmail.com>
  • Loading branch information
pochedls and tomvothecoder authored Aug 10, 2022
1 parent 1d242e5 commit 4c51879
Show file tree
Hide file tree
Showing 5 changed files with 710 additions and 394 deletions.
13 changes: 11 additions & 2 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,26 @@
"standard_name": "time",
},
)
# NOTE: With `decode_times=True`, the "calendar" and "units" attributes are
# stored in `.encoding`.
time_cf.encoding["calendar"] = "standard"
time_cf.encoding["units"] = "days since 2000-01-01"


# NOTE: With `decode_times=False`, the "calendar" and "units" attributes are
# stored in `.attrs`.
time_non_cf = xr.DataArray(
data=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
dims=["time"],
attrs={
"units": "months since 2000-01-01",
"calendar": "standard",
"axis": "T",
"long_name": "time",
"standard_name": "time",
"calendar": "standard",
"units": "months since 2000-01-01",
},
)

time_non_cf_unsupported = xr.DataArray(
data=np.arange(1850 + 1 / 24.0, 1851 + 3 / 12.0, 1 / 12.0),
dims=["time"],
Expand Down
Loading

0 comments on commit 4c51879

Please sign in to comment.