Skip to content
Open
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
".": "1.14.3",
"core": "1.14.3",
"extensions/classification": "2.0.0",
"extensions/datacube": "2.2.0",
"extensions/datacube": "2.3.0",
"extensions/eo": "1.1.0",
"extensions/file": "2.1.0",
"extensions/grid": "1.1.0",
Expand Down
4 changes: 3 additions & 1 deletion core/pystac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"TemporalExtent",
"Summaries",
"CommonMetadata",
"NoDataStrings",
"DataType",
"RangeSummary",
"Item",
"Asset",
Expand Down Expand Up @@ -81,7 +83,7 @@
SpatialExtent,
TemporalExtent,
)
from pystac.common_metadata import CommonMetadata
from pystac.common_metadata import CommonMetadata, NoDataStrings, DataType
from pystac.summaries import RangeSummary, Summaries
from pystac.asset import Asset
from pystac.item import Item
Expand Down
25 changes: 25 additions & 0 deletions core/pystac/common_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@
P = TypeVar("P")


class DataType(utils.StringEnum):
INT8 = "int8"
INT16 = "int16"
INT32 = "int32"
INT64 = "int64"
UINT8 = "uint8"
UINT16 = "uint16"
UINT32 = "uint32"
UINT64 = "uint64"
FLOAT16 = "float16"
FLOAT32 = "float32"
FLOAT64 = "float64"
CINT16 = "cint16"
CINT32 = "cint32"
CFLOAT32 = "cfloat32"
CFLOAT64 = "cfloat64"
OTHER = "other"


class NoDataStrings(utils.StringEnum):
INF = "inf"
NINF = "-inf"
NAN = "nan"


class CommonMetadata:
"""Object containing fields that are not included in core item schema but
are still commonly used. All attributes are defined within the properties of
Expand Down
3 changes: 2 additions & 1 deletion extensions/datacube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ This extension describes datasets that are organized as multi-dimensional datacu

## Supported versions

- [v2.3.0](https://stac-extensions.github.io/datacube/v2.3.0/schema.json)
- [v2.2.0](https://stac-extensions.github.io/datacube/v2.2.0/schema.json)

## Versioning

This package's version corresponds to the version of the extension specification it targets.
When we release updates to the package code without changing the target extension version, we use [post releases](https://packaging.python.org/en/latest/discussions/versioning/#post-releases), e.g. `2.2.0.post1`.
When we release updates to the package code without changing the target extension version, we use [post releases](https://packaging.python.org/en/latest/discussions/versioning/#post-releases), e.g. `2.3.0.post1`.
2 changes: 1 addition & 1 deletion extensions/datacube/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "pystac-ext-datacube"
description = "Datacube extension for PySTAC"
readme = "README.md"
version = "2.2.0"
version = "2.3.0"
authors = []
maintainers = []
keywords = ["pystac", "imagery", "raster", "catalog", "STAC", "datacube"]
Expand Down
45 changes: 41 additions & 4 deletions extensions/datacube/pystac/extensions/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
"T", pystac.Collection, pystac.Item, pystac.Asset, pystac.ItemAssetDefinition
)

SCHEMA_URI = "https://stac-extensions.github.io/datacube/v2.2.0/schema.json"
SCHEMA_URI = "https://stac-extensions.github.io/datacube/v2.3.0/schema.json"
SCHEMA_URIS = [
"https://stac-extensions.github.io/datacube/v1.0.0/schema.json",
"https://stac-extensions.github.io/datacube/v2.0.0/schema.json",
"https://stac-extensions.github.io/datacube/v2.1.0/schema.json",
"https://stac-extensions.github.io/datacube/v2.2.0/schema.json",
SCHEMA_URI,
]

PREFIX: str = "cube:"
DIMENSIONS_PROP = PREFIX + "dimensions"
Expand All @@ -33,13 +40,16 @@
DIM_REF_SYS_PROP = "reference_system"
DIM_UNIT_PROP = "unit"


# Variable properties
VAR_TYPE_PROP = "type"
VAR_DESC_PROP = "description"
VAR_EXTENT_PROP = "extent"
VAR_VALUES_PROP = "values"
VAR_DIMENSIONS_PROP = "dimensions"
VAR_UNIT_PROP = "unit"
VAR_NODATA_PROP = "nodata"
VAR_DATA_TYPE_PROP = "data_type"


class DimensionType(StringEnum):
Expand Down Expand Up @@ -543,6 +553,35 @@ def unit(self, v: str | None) -> None:
else:
self.properties[VAR_UNIT_PROP] = v

@property
def nodata(self) -> pystac.NoDataStrings | float | None:
"""Value used to identify no-data,
see `common metadata
<https://github.com/radiantearth/stac-spec/blob/v1.1.0/commons/common-metadata.md#no-data>`__
for more details."""
return self.properties.get(VAR_NODATA_PROP)

@nodata.setter
def nodata(self, v: pystac.NoDataStrings | float | None) -> None:
if v is None:
self.properties.pop(VAR_NODATA_PROP, None)
else:
self.properties[VAR_NODATA_PROP] = v

@property
def data_type(self) -> pystac.DataType | None:
"""The data type of the values in the datacube, see `common metadata
<https://github.com/radiantearth/stac-spec/blob/v1.1.0/commons/common-metadata.md#data-types>`__
for more details."""
return self.properties.get(VAR_DATA_TYPE_PROP)

@data_type.setter
def data_type(self, v: pystac.DataType | None) -> None:
if v is None:
self.properties.pop(VAR_DATA_TYPE_PROP, None)
else:
self.properties[VAR_DATA_TYPE_PROP] = v

@staticmethod
def from_dict(d: dict[str, Any]) -> Variable:
return Variable(d)
Expand Down Expand Up @@ -734,9 +773,7 @@ class DatacubeExtensionHooks(ExtensionHooks):
schema_uri: str = SCHEMA_URI
prev_extension_ids = {
"datacube",
"https://stac-extensions.github.io/datacube/v1.0.0/schema.json",
"https://stac-extensions.github.io/datacube/v2.0.0/schema.json",
"https://stac-extensions.github.io/datacube/v2.1.0/schema.json",
*[uri for uri in SCHEMA_URIS if uri != SCHEMA_URI],
}
stac_object_types = {
pystac.STACObjectType.COLLECTION,
Expand Down
Loading