Skip to content

Commit

Permalink
Add intertidal properties to known-properties
Browse files Browse the repository at this point in the history
(And fix a config warning in the new version of ruff)
  • Loading branch information
jeremyh committed Feb 28, 2024
1 parent 48a4608 commit d2fac85
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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

0 comments on commit d2fac85

Please sign in to comment.