Example #1
0
    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")
Example #2
0
 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)
Example #3
0
    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")
Example #4
0
    def max(self) -> float:
        """Get or sets the maximum value of the distribution.

        Returns:
            float
        """
        return get_required(self.properties.get("max"), self, "max")
Example #5
0
 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()}
Example #6
0
 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,
     )
Example #7
0
 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]
Example #8
0
    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")
Example #9
0
 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,
     )
Example #10
0
 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)
Example #11
0
 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")
Example #12
0
 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)
Example #13
0
 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,
     )
Example #14
0
    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)
Example #15
0
 def name(self) -> str:
     """Gets or sets the name property for this Schema."""
     return get_required(self.properties.get("name"), self, "name")
Example #16
0
 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()}
Example #17
0
 def classes(self) -> Sequence[Union[str, int, float]]:
     """Gets or sets the class values."""
     return get_required(self.properties.get("classes"), self, "classes")
Example #18
0
 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)
Example #19
0
 def value(self) -> float:
     """Gets or sets the value of the statistic."""
     return get_required(self.properties.get("value"), self, "value")
Example #20
0
 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)
Example #21
0
 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)
Example #22
0
 def count(self) -> int:
     """Get or sets the number of occurrences of the class."""
     return get_required(self.properties.get("count"), self, "count")
Example #23
0
 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))
Example #24
0
 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)
Example #25
0
 def size(self) -> int:
     """Gets or sets the size value."""
     return get_required(self.properties.get("size"), self, "size")
Example #26
0
 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)
Example #27
0
 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)
Example #28
0
 def name(self) -> str:
     """Gets or sets the class that this count represents."""
     return get_required(self.properties.get("name"), self, "name")
Example #29
0
 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)
Example #30
0
 def name(self) -> str:
     """Gets or sets the name of the statistic being reported."""
     return get_required(self.properties.get("name"), self, "name")