From ee77544b8daedeb049fc97b08d47e61e8e9646b1 Mon Sep 17 00:00:00 2001 From: nicolasK Date: Fri, 15 Dec 2023 15:17:07 +0100 Subject: [PATCH 1/4] chore(version) : v0.0.4 --- CHANGELOG.md | 4 +++- earthdaily/__init__.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6be051cc..195c7cd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.4] + ## [0.0.3] - 2023-12-15 ### Added -- Only query assets directly avaible in the search items (better performance). +- Ability to query assets in the search items. ## [0.0.2] - 2023-12-15 diff --git a/earthdaily/__init__.py b/earthdaily/__init__.py index 500b8926..de39cd9f 100644 --- a/earthdaily/__init__.py +++ b/earthdaily/__init__.py @@ -1,3 +1,3 @@ from . import earthdatastore, datasets -__version__ = "0.0.3" +__version__ = "0.0.4" From cf5710bd7cb41fdae35a34b9a34ec8e428aa616e Mon Sep 17 00:00:00 2001 From: nicolasK Date: Tue, 30 Jan 2024 14:40:26 +0100 Subject: [PATCH 2/4] chore(dims to sizes) for xarray --- earthdaily/earthdatastore/cube_utils/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/earthdaily/earthdatastore/cube_utils/__init__.py b/earthdaily/earthdatastore/cube_utils/__init__.py index 346694c6..27f66e48 100644 --- a/earthdaily/earthdatastore/cube_utils/__init__.py +++ b/earthdaily/earthdatastore/cube_utils/__init__.py @@ -21,7 +21,7 @@ def _datacubes(method): @wraps(method) def _impl(self, *args, **kwargs): - collections = kwargs.get("collections", args[0]) + collections = kwargs.get("collections", args[0] if len(args)>0 else None) if isinstance(collections, list) and len(collections) > 1: if "collections" in kwargs.keys(): kwargs.pop("collections") @@ -42,7 +42,7 @@ def _impl(self, *args, **kwargs): def _match_xy_dims(src, dst, resampling=Resampling.nearest): - if src.dims != dst.dims: + if src.sizes != dst.sizes: src = src.rio.reproject_match(dst, resampling=resampling) return src @@ -61,7 +61,7 @@ def _apply_nodata(ds, nodata_assets: dict): def _autofix_unfrozen_coords_dtype(ds): - attrs = {c: ds.coords[c].data.tolist() for c in ds.coords if c not in ds.dims} + attrs = {c: ds.coords[c].data.tolist() for c in ds.coords if c not in ds.sizes} # force str for attr in attrs: if not isinstance(attrs[attr], (str, int, float, np.ndarray, list, tuple)): @@ -369,7 +369,7 @@ def _propagade_rio(src, ds): def _drop_unfrozen_coords(ds): - unfrozen_coords = [i for i in list(ds.coords) if i not in ds.dims] + unfrozen_coords = [i for i in list(ds.coords) if i not in ds.sizes] ds = ds.drop(unfrozen_coords) return ds @@ -391,8 +391,8 @@ def _groupby(ds, by="time.date", how="mean"): def _have_same_xy(*cubes): - x_size = list(set(cube.dims["x"] for cube in cubes)) - y_size = list(set(cube.dims["y"] for cube in cubes)) + x_size = list(set(cube.sizes["x"] for cube in cubes)) + y_size = list(set(cube.sizes["y"] for cube in cubes)) if len(x_size) == 1 and len(y_size) == 1: return True return False @@ -413,4 +413,5 @@ def metacube(*cubes, concat_dim="time", by="time.date", how="mean"): ) cube = xr.concat([_drop_unfrozen_coords(cube) for cube in cubes], dim=concat_dim) cube = _groupby(cube, by=by, how=how) + cube = cube.sortby(cube.time) return _propagade_rio(cubes[0], cube) From 98f6c131641c325c007daff245bb70988c94b251 Mon Sep 17 00:00:00 2001 From: nkarasiak Date: Tue, 30 Jan 2024 13:40:43 +0000 Subject: [PATCH 3/4] style(ruff) : automatic lint/format --- earthdaily/earthdatastore/cube_utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/earthdaily/earthdatastore/cube_utils/__init__.py b/earthdaily/earthdatastore/cube_utils/__init__.py index 27f66e48..cf93ef49 100644 --- a/earthdaily/earthdatastore/cube_utils/__init__.py +++ b/earthdaily/earthdatastore/cube_utils/__init__.py @@ -21,7 +21,7 @@ def _datacubes(method): @wraps(method) def _impl(self, *args, **kwargs): - collections = kwargs.get("collections", args[0] if len(args)>0 else None) + collections = kwargs.get("collections", args[0] if len(args) > 0 else None) if isinstance(collections, list) and len(collections) > 1: if "collections" in kwargs.keys(): kwargs.pop("collections") From c5ab4099dbea9eede5c04701aed6d3817e15591a Mon Sep 17 00:00:00 2001 From: nicolasK Date: Wed, 31 Jan 2024 17:37:34 +0100 Subject: [PATCH 4/4] chore(changelog) --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 195c7cd9..8ce0c69a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.0.4] +### Fixed + +- "collections" from datacube now supports in args. + +### Changed + +- Modify dims attributs to sizes for xarray. + ## [0.0.3] - 2023-12-15 ### Added