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 0581d14
Show file tree
Hide file tree
Showing 7 changed files with 698 additions and 366 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
12 changes: 10 additions & 2 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,25 @@
"standard_name": "time",
},
)
time_cf.encoding["calendar"] = "standard"
time_cf.encoding["units"] = "days since 2000-01-01"

# NOTE: When opening a dataset with `decode_times=False``, the encoding attrs
# such as 'calendar' and 'units' are saved in the `.attrs` dict rather than the
# `.encoding` dict. After the decoding process is done, these attributes are
# stored in the encoding dictionary (same behavior as xarray).
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 0581d14

Please sign in to comment.