From e50446e9e54d7d409f627907de934d75a28479d8 Mon Sep 17 00:00:00 2001 From: Tom Vo Date: Tue, 9 Nov 2021 08:03:33 -0800 Subject: [PATCH] Update `HISTORY.rst` and fix docstrings --- HISTORY.rst | 55 ++++++++++++++++++++++++++++++++++++++++++-- xcdat/dataset.py | 12 ++++------ xcdat/spatial_avg.py | 4 ++-- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 1c5b4e6f..c4b3b912 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,5 +2,56 @@ History ======= -0.1.0 (2021-09-30) ------------------- +v0.1.0 (7 October, 2021) +------------------------ + +New Features +~~~~~~~~~~~~ + +- Add geospatial averaging API through + ``DatasetSpatialAverageAccessor`` class by @pochedls and + @tomvothecoder in #87 + + - Does not support parallelism with Dask yet + +- Add wrappers for xarray's ``open_dataset`` and ``open_mfdataset`` to + apply common operations such as: + + - If the dataset has a time dimension, decode both CF and non-CF + time units + - Generate bounds for supported coordinates if they don’t exist + - Option to limit the Dataset to a single regular (non-bounds) data + variable while retaining any bounds data variables + +- Add ``DatasetBoundsAccessor`` class for filling missing bounds, + returning mapping of bounds, returning names of bounds keys +- Add ``XCDATBoundsAccessor`` class for accessing xcdat public methods + from other accessor classes + + - This will be probably be the API endpoint for most users, unless + they prefer importing the individual accessor classes + +- Add ability to infer data variables in xcdat APIs based on the + "xcdat_infer" Dataset attr + + - This attr is set in ``xcdat.open_dataset()``, + ``xcdat_mfdataset()``, or manually + +- Utilizes ``cf_xarray`` package + (https://github.com/xarray-contrib/cf-xarray) + + +Documentation +~~~~~~~~~~~~~ + +- Visit the docs here: + https://xcdat.readthedocs.io/en/latest/index.html + +CI/CD +~~~~~ + +- 100% code coverage (https://app.codecov.io/gh/XCDAT/xcdat) +- GH Actions for CI/CD build (https://github.com/XCDAT/xcdat/actions) +- Pytest and pytest-cov for test suite + +**Full Changelog**: https://github.com/XCDAT/xcdat/commits/v0.1.0 diff --git a/xcdat/dataset.py b/xcdat/dataset.py index f991ad41..f7dfe25a 100644 --- a/xcdat/dataset.py +++ b/xcdat/dataset.py @@ -62,15 +62,13 @@ def open_dataset( Keep a single variable in the Dataset: >>> from xcdat.dataset import open_dataset - >>> ds = open_dataset("file_path", keep_vars="tas") + >>> ds = open_dataset("file_path", data_var="tas") Keep multiple variables in the Dataset: >>> from xcdat.dataset import open_dataset - >>> ds = open_dataset("file_path", keep_vars=["ts", "tas"]) + >>> ds = open_dataset("file_path", data_var=["ts", "tas"]) """ - # NOTE: Using decode_times=False may add incorrect units for existing time - # bounds (becomes "days since 1970-01-01 00:00:00"). ds = xr.open_dataset(path, decode_times=False, **kwargs) ds = infer_or_keep_var(ds, data_var) @@ -141,15 +139,13 @@ def open_mfdataset( Keep a single variable in the Dataset: >>> from xcdat.dataset import open_dataset - >>> ds = open_mfdataset(["file_path1", "file_path2"], keep_vars="tas") + >>> ds = open_mfdataset(["file_path1", "file_path2"], data_var="tas") Keep multiple variables in the Dataset: >>> from xcdat.dataset import open_dataset - >>> ds = open_mfdataset(["file_path1", "file_path2"], keep_vars=["ts", "tas"]) + >>> ds = open_mfdataset(["file_path1", "file_path2"], data_var=["ts", "tas"]) """ - # NOTE: Using decode_times=False may add incorrect units for existing time - # bounds (becomes "days since 1970-01-01 00:00:00"). ds = xr.open_mfdataset(paths, decode_times=False, **kwargs) ds = infer_or_keep_var(ds, data_var) diff --git a/xcdat/spatial_avg.py b/xcdat/spatial_avg.py index 48869d2e..8a7c2b2b 100644 --- a/xcdat/spatial_avg.py +++ b/xcdat/spatial_avg.py @@ -107,9 +107,9 @@ def avg( Get time series in Nino 3.4 domain: - >>> ts_n34 = ds.spatial.avg("tas", axis=["lat", "lon"], + >>> ts_n34 = ds.spatial.avg("ts", axis=["lat", "lon"], >>> lat_bounds=(-5, 5), - >>> lon_bounds=(-170, -120))["tas"] + >>> lon_bounds=(-170, -120))["ts"] Get zonal mean time series: