def count(self) -> int: """Get or sets the number of buckets of the distribution. Returns: int """ return get_required(self.properties.get("count"), self, "count")
def extent(self) -> List[Union[float, str, None]]: """If the variable consists of `ordinal values <https://en.wikipedia.org/wiki/Level_of_measurement#Ordinal_scale>`, the extent (lower and upper bounds) of the values as two-dimensional array. Use ``None`` for open intervals""" return get_required(self.properties.get(VAR_EXTENT_PROP), "cube:variable", VAR_EXTENT_PROP)
def name(self) -> str: """Get or sets the name of the band (e.g., "B01", "B02", "B1", "B5", "QA"). Returns: str """ return get_required(self.properties.get("name"), self, "name")
def max(self) -> float: """Get or sets the maximum value of the distribution. Returns: float """ return get_required(self.properties.get("max"), self, "max")
def item_assets(self) -> Dict[str, AssetDefinition]: """Gets or sets a dictionary of assets that can be found in member Items. Maps the asset key to an :class:`AssetDefinition` instance.""" result: Dict[str, Any] = get_required( self.collection.extra_fields.get(ITEM_ASSETS_PROP), self, ITEM_ASSETS_PROP) return {k: AssetDefinition(v) for k, v in result.items()}
def dimensions(self) -> List[str]: """The dimensions of the variable. Should refer to keys in the ``cube:dimensions`` object or be an empty list if the variable has no dimensions""" return get_required( self.properties.get(VAR_DIMENSIONS_PROP), "cube:variable", VAR_DIMENSIONS_PROP, )
def schemas(self) -> List[Schema]: """Gets or sets the list of :class:`Schema` instances defining dimensions and types for the data. """ result = get_required( self._get_property(SCHEMAS_PROP, List[Dict[str, Any]]), self, SCHEMAS_PROP) return [Schema(s) for s in result]
def buckets(self) -> List[int]: """Get or sets the Array of integer indicating the number of pixels included in the bucket. Returns: List[int] """ return get_required(self.properties.get("buckets"), self, "buckets")
def frequency_band(self) -> FrequencyBand: """Gets or sets a FrequencyBand for the item.""" return get_required( map_opt(lambda x: FrequencyBand(x), self._get_property(FREQUENCY_BAND_PROP, str)), self, FREQUENCY_BAND_PROP, )
def from_dict(d: Dict[str, Any]) -> "Dimension": dim_type: str = get_required(d.get(DIM_TYPE_PROP), "cube_dimension", DIM_TYPE_PROP) if dim_type == DimensionType.SPATIAL: axis: str = get_required(d.get(DIM_AXIS_PROP), "cube_dimension", DIM_AXIS_PROP) if axis == "z": return VerticalSpatialDimension(d) else: return HorizontalSpatialDimension(d) elif dim_type == DimensionType.TEMPORAL: # The v1.0.0 spec says that AdditionalDimensions can have # type 'temporal', but it is unclear how to differentiate that # from a temporal dimension. Just key off of type for now. # See https://github.com/stac-extensions/datacube/issues/5 return TemporalDimension(d) else: return AdditionalDimension(d)
def test_migrates_pre_1_0_0_rc1_stats_summary(self) -> None: collection = pystac.Collection.from_file( TestCases.get_path( "data-files/examples/1.0.0-beta.2/collection-spec/" "examples/sentinel2.json")) datetime_summary = get_required( collection.summaries.get_range("datetime"), collection.summaries, "datetime") self.assertEqual(datetime_summary.minimum, "2015-06-23T00:00:00Z") self.assertEqual(datetime_summary.maximum, "2019-07-10T13:44:56Z")
def dim_type(self) -> Union[DimensionType, str]: """The type of the dimension. Must be ``"spatial"`` for :stac-ext:`Horizontal Spatial Dimension Objects <datacube#horizontal-spatial-dimension-object>` or :stac-ext:`Vertical Spatial Dimension Objects <datacube#vertical-spatial-dimension-object>`, and ``"temporal"`` for :stac-ext:`Temporal Dimension Objects <datacube#temporal-dimension-object>`. May be an arbitrary string for :stac-ext:`Additional Dimension Objects <datacube#additional-dimension-object>`.""" return get_required(self.properties.get(DIM_TYPE_PROP), "cube:dimension", DIM_TYPE_PROP)
def polarizations(self) -> List[Polarization]: """Gets or sets a list of polarizations for the item.""" return get_required( map_opt( lambda values: [Polarization(v) for v in values], self._get_property(POLARIZATIONS_PROP, List[str]), ), self, POLARIZATIONS_PROP, )
def test_schema_summary(self) -> None: collection = pystac.Collection.from_file( TestCases.get_path( "data-files/examples/1.0.0/collection-only/collection-with-schemas.json" )) instruments_schema = get_required( collection.summaries.get_schema("instruments"), collection.summaries, "instruments", ) self.assertIsInstance(instruments_schema, dict)
def name(self) -> str: """Gets or sets the name property for this Schema.""" return get_required(self.properties.get("name"), self, "name")
def dimensions(self) -> Dict[str, Dimension]: """Dictionary mapping dimension name to a :class:`Dimension` object.""" result = get_required( self._get_property(DIMENSIONS_PROP, Dict[str, Any]), self, DIMENSIONS_PROP) return {k: Dimension.from_dict(v) for k, v in result.items()}
def classes(self) -> Sequence[Union[str, int, float]]: """Gets or sets the class values.""" return get_required(self.properties.get("classes"), self, "classes")
def var_type(self) -> Union[VariableType, str]: """Type of the variable, either ``data`` or ``auxiliary``""" return get_required(self.properties.get(VAR_TYPE_PROP), "cube:variable", VAR_TYPE_PROP)
def value(self) -> float: """Gets or sets the value of the statistic.""" return get_required(self.properties.get("value"), self, "value")
def extent(self) -> List[float]: """Extent (lower and upper bounds) of the dimension as two-dimensional array. Open intervals with ``None`` are not allowed.""" return get_required(self.properties.get(DIM_EXTENT_PROP), "cube:dimension", DIM_EXTENT_PROP)
def axis(self) -> HorizontalSpatialDimensionAxis: """Axis of the spatial dimension. Must be one of ``"x"`` or ``"y"``.""" return get_required(self.properties.get(DIM_AXIS_PROP), "cube:dimension", DIM_AXIS_PROP)
def count(self) -> int: """Get or sets the number of occurrences of the class.""" return get_required(self.properties.get("count"), self, "count")
def label_type(self) -> LabelType: """Gets or sets an Enum of either vector label type or raster label type.""" return LabelType( get_required(self.obj.properties.get(TYPE_PROP), self.obj, TYPE_PROP))
def label_description(self) -> str: """Gets or sets a description of the label, how it was created, and what it is recommended for.""" return get_required(self.obj.properties.get(DESCRIPTION_PROP), self.obj, DESCRIPTION_PROP)
def size(self) -> int: """Gets or sets the size value.""" return get_required(self.properties.get("size"), self, "size")
def axis(self) -> VerticalSpatialDimensionAxis: """Axis of the spatial dimension. Always ``"z"``.""" return get_required(self.properties.get(DIM_AXIS_PROP), "cube:dimension", DIM_AXIS_PROP)
def encoding(self) -> str: """Gets or sets the content encoding or format of the data.""" return get_required(self._get_property(ENCODING_PROP, str), self, ENCODING_PROP)
def name(self) -> str: """Gets or sets the class that this count represents.""" return get_required(self.properties.get("name"), self, "name")
def from_dict(cls, d: Dict[str, Any]) -> "RangeSummary[T]": minimum: T = get_required(d.get("minimum"), "RangeSummary", "minimum") maximum: T = get_required(d.get("maximum"), "RangeSummary", "maximum") return cls(minimum=minimum, maximum=maximum)
def name(self) -> str: """Gets or sets the name of the statistic being reported.""" return get_required(self.properties.get("name"), self, "name")