Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add intertidal properties to known-properties #334

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions eodatasets3/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ def datetime_type(value):
def of_enum_type(
vals: Union[EnumMeta, Tuple[str, ...]] = None, lower=False, upper=False, strict=True
) -> Callable[[str], str]:
"""
A String value with a fixed set of known values.

:param vals: The set of allowed values. Can be an Enum class or a tuple of strings.
:param lower: Automatically normalise values to lowercase
:param upper: Automatically normalise values to uppercase
:param strict: raise a ValueError if the value is not in the list of allowed values
(If not strict, you're just using this for warnings)
"""
if isinstance(vals, EnumMeta):
vals = tuple(vals.__members__.keys())

Expand Down Expand Up @@ -282,6 +291,20 @@ def parsed_sentinel_datastrip_id(tile_id) -> Tuple[str, Dict]:
"sinergise_product_id": None,
}

_DERIVATIVE_PRODUCT_PROPS = {
"intertidal:category": of_enum_type(
("mesotidal", "macrotidal", "microtidal"), lower=True, strict=False
),
"intertidal:hat": float,
"intertidal:hot": float,
"intertidal:lat": float,
"intertidal:lot": float,
"intertidal:offset_high": float,
"intertidal:offset_low": float,
"intertidal:otr": float,
"intertidal:spread": float,
"intertidal:tr": float,
}

_STAC_MISC_PROPS = {
"providers": None, # https://github.com/radiantearth/stac-spec/blob/master/item-spec/common-metadata.md#provider,
Expand Down Expand Up @@ -342,6 +365,7 @@ class Eo3Dict(collections.abc.MutableMapping):
**_LANDSAT_EXTENDED_PROPS,
**_GQA_FMASK_PROPS,
**_SENTINEL_EXTENDED_PROPS,
**_DERIVATIVE_PRODUCT_PROPS,
**_STAC_MISC_PROPS,
}

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ignore = [
# ... but only enforce line length to be under this larger 120 limit.
pycodestyle.max-line-length = 120

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"docs/conf.py" = ["A001"] # Variable `copyright` shadowing a Python builtin (needed for api)

[tool.black]
Expand Down
Loading