def test_equality(self) -> None: rs_1 = RangeSummary(5, 10) rs_2 = RangeSummary(5, 10) rs_3 = RangeSummary(5, 11) self.assertEqual(rs_1, rs_2) self.assertNotEqual(rs_1, rs_3) self.assertNotEqual(rs_1, (5, 10))
def test_center_frequency(self) -> None: collection = self.collection.clone() summaries_ext = SarExtension.summaries(collection, True) center_frequency_range = RangeSummary(4.405, 6.405) summaries_ext.center_frequency = center_frequency_range self.assertEqual( summaries_ext.center_frequency, center_frequency_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertEqual( summaries_dict["sar:center_frequency"], center_frequency_range.to_dict(), )
def anx_datetime(self, v: Optional[RangeSummary[Datetime]]) -> None: self._set_summary( ANX_DATETIME_PROP, map_opt( lambda s: RangeSummary(datetime_to_str(s.minimum), datetime_to_str(s.maximum)), v, ), )
def test_set_incidence_angle_summaries(self) -> None: collection = self.collection.clone() view_summaries = ViewExtension.summaries(collection, True) view_summaries.incidence_angle = RangeSummary(5, 15) self.assertDictEqual({ "minimum": 5, "maximum": 15 }, view_summaries.incidence_angle.to_dict())
def test_set_sun_azimuth_summaries(self) -> None: collection = self.collection.clone() view_summaries = ViewExtension.summaries(collection, True) view_summaries.sun_azimuth = RangeSummary(210, 275) self.assertDictEqual({ "minimum": 210, "maximum": 275 }, view_summaries.sun_azimuth.to_dict())
def test_looks_equivalent_number(self) -> None: collection = self.collection.clone() summaries_ext = SarExtension.summaries(collection, True) looks_equivalent_number_range = RangeSummary(400.0, 600.0) summaries_ext.looks_equivalent_number = looks_equivalent_number_range self.assertEqual( summaries_ext.looks_equivalent_number, looks_equivalent_number_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertEqual( summaries_dict["sar:looks_equivalent_number"], looks_equivalent_number_range.to_dict(), )
def test_set_off_nadir_summaries(self) -> None: collection = self.collection.clone() view_summaries = ViewExtension.summaries(collection, True) view_summaries.off_nadir = RangeSummary(0, 10) self.assertDictEqual({ "minimum": 0, "maximum": 10 }, view_summaries.off_nadir.to_dict())
def expires(self, v: Optional[RangeSummary[datetime]]) -> None: self._set_summary( EXPIRES_PROP, map_opt( lambda s: RangeSummary(datetime_to_str(s.minimum), datetime_to_str(s.maximum)), v, ), )
def test_looks_azimuth(self) -> None: collection = self.collection.clone() summaries_ext = SarExtension.summaries(collection, True) looks_azimuth_range = RangeSummary(400, 600) summaries_ext.looks_azimuth = looks_azimuth_range self.assertEqual( summaries_ext.looks_azimuth, looks_azimuth_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertEqual( summaries_dict["sar:looks_azimuth"], looks_azimuth_range.to_dict(), )
def test_absolute_orbit(self) -> None: collection = self.collection() summaries_ext = SatExtension.summaries(collection, True) absolute_orbit_range = RangeSummary(2000, 3000) summaries_ext.absolute_orbit = absolute_orbit_range self.assertEqual( summaries_ext.absolute_orbit, absolute_orbit_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertEqual( summaries_dict["sat:absolute_orbit"], absolute_orbit_range.to_dict(), )
def test_resolution_azimuth(self) -> None: collection = self.collection.clone() summaries_ext = SarExtension.summaries(collection, True) resolution_azimuth_range = RangeSummary(800.0, 1200.0) summaries_ext.resolution_azimuth = resolution_azimuth_range self.assertEqual( summaries_ext.resolution_azimuth, resolution_azimuth_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertEqual( summaries_dict["sar:resolution_azimuth"], resolution_azimuth_range.to_dict(), )
def test_count(self) -> None: collection = self.collection.clone() summaries_ext = PointcloudExtension.summaries(collection, True) count_range = RangeSummary(1000, 10000) summaries_ext.count = count_range self.assertEqual( summaries_ext.count, count_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertEqual( summaries_dict["pc:count"], count_range.to_dict(), )
def test_density(self) -> None: collection = self.collection.clone() summaries_ext = PointcloudExtension.summaries(collection, True) density_range = RangeSummary(500.0, 1000.0) summaries_ext.density = density_range self.assertEqual( summaries_ext.density, density_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertEqual( summaries_dict["pc:density"], density_range.to_dict(), )
def test_relative_orbit(self) -> None: collection = self.collection() summaries_ext = SatExtension.summaries(collection, True) relative_orbit_range = RangeSummary(50, 100) summaries_ext.relative_orbit = relative_orbit_range self.assertEqual( summaries_ext.relative_orbit, relative_orbit_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertEqual( summaries_dict["sat:relative_orbit"], relative_orbit_range.to_dict(), )
def unpublished(self, v: Optional[RangeSummary[datetime]]) -> None: self._set_summary( UNPUBLISHED_PROP, map_opt( lambda s: RangeSummary(datetime_to_str(s.minimum), datetime_to_str(s.maximum)), v, ), )
def test_set_sun_elevation_summaries(self) -> None: collection = self.collection.clone() view_summaries = ViewExtension.summaries(collection, True) view_summaries.sun_elevation = RangeSummary(-10, 38) self.assertDictEqual({ "minimum": -10, "maximum": 38 }, view_summaries.sun_elevation.to_dict())
def test_pixel_spacing_azimuth(self) -> None: collection = self.collection.clone() summaries_ext = SarExtension.summaries(collection, True) pixel_spacing_azimuth_range = RangeSummary(400.0, 600.0) summaries_ext.pixel_spacing_azimuth = pixel_spacing_azimuth_range self.assertEqual( summaries_ext.pixel_spacing_azimuth, pixel_spacing_azimuth_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertEqual( summaries_dict["sar:pixel_spacing_azimuth"], pixel_spacing_azimuth_range.to_dict(), )
def unpublished(self) -> Optional[RangeSummary[datetime]]: """Get or sets the summary of :attr:`TimestampsExtension.unpublished` values for this Collection. """ return map_opt( lambda s: RangeSummary(str_to_datetime(s.minimum), str_to_datetime(s.maximum)), self.summaries.get_range(UNPUBLISHED_PROP), )
def expires(self) -> Optional[RangeSummary[datetime]]: """Get or sets the summary of :attr:`TimestampsExtension.expires` values for this Collection. """ return map_opt( lambda s: RangeSummary(str_to_datetime(s.minimum), str_to_datetime(s.maximum)), self.summaries.get_range(EXPIRES_PROP), )
def test_summaries(self) -> None: col = pystac.Collection.from_file(self.EO_COLLECTION_URI) eo_summaries = EOExtension.summaries(col) # Get cloud_cover_summaries = eo_summaries.cloud_cover assert cloud_cover_summaries is not None self.assertEqual(cloud_cover_summaries.minimum, 0.0) self.assertEqual(cloud_cover_summaries.maximum, 80.0) bands = eo_summaries.bands assert bands is not None self.assertEqual(len(bands), 11) # Set eo_summaries.cloud_cover = RangeSummary(1.0, 2.0) eo_summaries.bands = [Band.create(name="test")] col_dict = col.to_dict() self.assertEqual(len(col_dict["summaries"]["eo:bands"]), 1) self.assertEqual(col_dict["summaries"]["eo:cloud_cover"]["minimum"], 1.0)
def test_unpublished(self) -> None: collection = self.collection() summaries_ext = TimestampsExtension.summaries(collection, True) unpublished_range = RangeSummary( str_to_datetime("2020-01-01T00:00:00.000Z"), str_to_datetime("2020-01-02T00:00:00.000Z"), ) summaries_ext.unpublished = unpublished_range self.assertEqual( summaries_ext.unpublished, unpublished_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertDictEqual( summaries_dict["unpublished"], { "minimum": datetime_to_str(unpublished_range.minimum), "maximum": datetime_to_str(unpublished_range.maximum), }, )
def test_anx_datetime(self) -> None: collection = self.collection() summaries_ext = SatExtension.summaries(collection, True) anx_datetime_range = RangeSummary( str_to_datetime("2020-01-01T00:00:00.000Z"), str_to_datetime("2020-01-02T00:00:00.000Z"), ) summaries_ext.anx_datetime = anx_datetime_range self.assertEqual( summaries_ext.anx_datetime, anx_datetime_range, ) summaries_dict = collection.to_dict()["summaries"] self.assertDictEqual( summaries_dict["sat:anx_datetime"], { "minimum": datetime_to_str(anx_datetime_range.minimum), "maximum": datetime_to_str(anx_datetime_range.maximum), }, )
def test_repr(self) -> None: rs = RangeSummary(5, 10) self.assertEqual("{'minimum': 5, 'maximum': 10}", rs.__repr__())
def anx_datetime(self) -> Optional[RangeSummary[Datetime]]: return map_opt( lambda s: RangeSummary(str_to_datetime(s.minimum), str_to_datetime(s.maximum)), self.summaries.get_range(ANX_DATETIME_PROP), )