Skip to content

Commit

Permalink
Update temporal accessor to use specific cftime objects
Browse files Browse the repository at this point in the history
- 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`
- Remove `Jupyter` setting from VS Code workspace
  • Loading branch information
tomvothecoder committed Aug 8, 2022
1 parent 197281d commit d3e1dd4
Show file tree
Hide file tree
Showing 7 changed files with 700 additions and 369 deletions.
3 changes: 1 addition & 2 deletions .vscode/xcdat.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
// Extension settings
// ===================
"jupyter.notebookFileRoot": "${workspaceFolder}",
"jupyter.runStartupCommands": ["%load_ext autoreload", "%autoreload 2"],
"autoDocstring.docstringFormat": "numpy"
"autoDocstring.docstringFormat": "numpy",
}
}
1 change: 1 addition & 0 deletions conda-env/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
- numpy=1.22.4
- pandas=1.4.3
- xarray=2022.3.0
- xesmf=0.6.3
- python-dateutil=2.8.2
- types-python-dateutil=2.8.19
# Quality Assurance
Expand Down
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 d3e1dd4

Please sign in to comment.