Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasK committed Jan 31, 2024
2 parents 85e20a4 + c41fe54 commit aee7824
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ 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]

### Fixed

- "collections" from datacube now supports in args.

### Changed

- Modify dims attributs to sizes for xarray.

## [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

Expand Down
2 changes: 1 addition & 1 deletion earthdaily/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from . import earthdatastore, datasets

__version__ = "0.0.3"
__version__ = "0.0.4"
13 changes: 7 additions & 6 deletions earthdaily/earthdatastore/cube_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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

Expand All @@ -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)):
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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)

0 comments on commit aee7824

Please sign in to comment.