Skip to content

Commit

Permalink
v0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasK committed Feb 29, 2024
1 parent f4bc1d9 commit 85f2cf4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +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.9] - Unreleased
## [0.0.9] - 2024-02-29

### Fixed

- `_typer` has a better args management.
- `available_indices` returns only indices that can be computed.

## [0.0.8] - 2024-02-28

### Added
Expand Down
4 changes: 4 additions & 0 deletions earthdaily/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from . import earthdatastore, datasets
from .accessor import EarthDailyAccessorDataArray, EarthDailyAccessorDataset
import warnings

# to hide warnings from rioxarray or nano seconds conversion
warnings.filterwarnings("ignore")

__version__ = "0.0.9"
17 changes: 9 additions & 8 deletions earthdaily/accessor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ def force(*args, **kwargs):
idx = 1
for key, val in func.__annotations__.items():
is_kwargs = key in kwargs.keys()
if (
val not in _SUPPORTED_DTYPE
or kwargs.get(key, None) is None
and is_kwargs
or len(args) == 1
):
if not is_kwargs and idx>= len(args):
continue
input_value = kwargs.get(key, None) if is_kwargs else args[idx]
if type(input_value) == val:
continue
if raise_mistype and (
val != type(kwargs.get(key))
Expand Down Expand Up @@ -256,20 +254,23 @@ def _auto_mapper(self):
params[_BAND_MAPPING[v]] = self._obj[v]
return params

def available_index(self, details=False):
def available_indices(self, details=False):
mapper = list(self._auto_mapper().keys())
indices = spyndex.indices
available_indices = []
for k, v in indices.items():
needed_bands = v.bands
missing_bands = False
for needed_band in needed_bands:
if needed_band not in mapper:
missing_bands = True
break
if missing_bands is False:
available_indices.append(spyndex.indices[k] if details else k)
return available_indices

@_typer()
def add_index(self, index: list, **kwargs):
def add_indices(self, index: list, **kwargs):
"""
Uses spyndex to compute and add index.
Expand Down
4 changes: 1 addition & 3 deletions examples/field_evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
# Plots cube with SCL with at least 50% of clear data
# ----------------------------------------------------
pivot_cube = pivot_cube.load()
pivot_cube.to_array(dim="band").plot.imshow(
vmin=0, vmax=0.4, col="time", col_wrap=3
)
pivot_cube.ed.plot_rgb(col_wrap=3)

plt.title("Clear cover percent with SCL")
plt.title("Pivot evolution with SCL masks")
Expand Down
11 changes: 4 additions & 7 deletions examples/multisensors_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
)

# Add the NDVI
datacube = datacube.ed.add_index('NDVI')
datacube = datacube.ed.add_indices(['NDVI'])

# Load in memory
datacube = datacube.load()
Expand All @@ -52,18 +52,15 @@
# See the evolution in RGB
# -------------------------------------------

datacube[["red", "green", "blue"]].to_array(dim="band").plot.imshow(
col="time", col_wrap=3, vmax=0.2
)
datacube.ed.plot_rgb(col_wrap=3)
plt.show()


##############################################################################
# See the NDVI evolution
# -------------------------------------------

datacube["NDVI"].plot.imshow(
col="time", col_wrap=3, vmin=0, vmax=0.8, cmap="RdYlGn"
)
datacube["NDVI"].ed.plot_index(col_wrap=3, vmin=0, vmax=0.8, cmap="Greens")
plt.show()

##############################################################################
Expand Down

0 comments on commit 85f2cf4

Please sign in to comment.