Skip to content

Commit e90f809

Browse files
author
Jon Duckworth
authored
Merge pull request #363 from emmanuelmathot/solar_illum
Add solar_illumination field in eo extension
2 parents fded8a6 + 10d5a29 commit e90f809

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Added
66

7+
- solar_illumination field in eo extension ([#356](https://github.com/stac-utils/pystac/issues/356))
78
- Added `Link.canonical` static method for creating links with "canonical" rel type ([#351](https://github.com/stac-utils/pystac/pull/351))
89
- Added `RelType` enum containing common `rel` values ([#351](https://github.com/stac-utils/pystac/pull/351))
910

pystac/extensions/eo.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def apply(
5353
description: Optional[str] = None,
5454
center_wavelength: Optional[float] = None,
5555
full_width_half_max: Optional[float] = None,
56+
solar_illumination: Optional[float] = None,
5657
) -> None:
5758
"""
5859
Sets the properties for this Band.
@@ -66,12 +67,15 @@ def apply(
6667
center_wavelength : The center wavelength of the band, in micrometers (μm).
6768
full_width_half_max : Full width at half maximum (FWHM). The width of the band,
6869
as measured at half the maximum transmission, in micrometers (μm).
70+
solar_illumination: The solar illumination of the band,
71+
as measured at half the maximum transmission, in W/m2/micrometers.
6972
""" # noqa
7073
self.name = name
7174
self.common_name = common_name
7275
self.description = description
7376
self.center_wavelength = center_wavelength
7477
self.full_width_half_max = full_width_half_max
78+
self.solar_illumination = solar_illumination
7579

7680
@classmethod
7781
def create(
@@ -81,6 +85,7 @@ def create(
8185
description: Optional[str] = None,
8286
center_wavelength: Optional[float] = None,
8387
full_width_half_max: Optional[float] = None,
88+
solar_illumination: Optional[float] = None,
8489
) -> "Band":
8590
"""
8691
Creates a new band.
@@ -94,6 +99,8 @@ def create(
9499
center_wavelength : The center wavelength of the band, in micrometers (μm).
95100
full_width_half_max : Full width at half maximum (FWHM). The width of the band,
96101
as measured at half the maximum transmission, in micrometers (μm).
102+
solar_illumination: The solar illumination of the band,
103+
as measured at half the maximum transmission, in W/m2/micrometers.
97104
""" # noqa
98105
b = cls({})
99106
b.apply(
@@ -102,6 +109,7 @@ def create(
102109
description=description,
103110
center_wavelength=center_wavelength,
104111
full_width_half_max=full_width_half_max,
112+
solar_illumination=solar_illumination,
105113
)
106114
return b
107115

@@ -186,6 +194,23 @@ def full_width_half_max(self, v: Optional[float]) -> None:
186194
else:
187195
self.properties.pop("full_width_half_max", None)
188196

197+
@property
198+
def solar_illumination(self) -> Optional[float]:
199+
"""Get or sets the solar illumination of the band,
200+
as measured at half the maximum transmission, in W/m2/micrometers.
201+
202+
Returns:
203+
[float]
204+
"""
205+
return self.properties.get("solar_illumination")
206+
207+
@solar_illumination.setter
208+
def solar_illumination(self, v: Optional[float]) -> None:
209+
if v is not None:
210+
self.properties["solar_illumination"] = v
211+
else:
212+
self.properties.pop("solar_illumination", None)
213+
189214
def __repr__(self) -> str:
190215
return "<Band name={}>".format(self.name)
191216

tests/data-files/eo/eo-landsat-example.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"name": "B1",
6666
"common_name": "coastal",
6767
"center_wavelength": 0.44,
68-
"full_width_half_max": 0.02
68+
"full_width_half_max": 0.02,
69+
"solar_illumination": 2000
6970
}
7071
]
7172
},

tests/extensions/test_eo.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_asset_bands(self) -> None:
9393
assert asset_bands is not None
9494
self.assertEqual(len(asset_bands), 1)
9595
self.assertEqual(asset_bands[0].name, "B1")
96+
self.assertEqual(asset_bands[0].solar_illumination, 2000)
9697

9798
index_asset = item.assets["index"]
9899
asset_bands = EOExtension.ext(index_asset).bands
@@ -115,9 +116,21 @@ def test_asset_bands(self) -> None:
115116

116117
# Check adding a new asset
117118
new_bands = [
118-
Band.create(name="red", description=Band.band_description("red")),
119-
Band.create(name="green", description=Band.band_description("green")),
120-
Band.create(name="blue", description=Band.band_description("blue")),
119+
Band.create(
120+
name="red",
121+
description=Band.band_description("red"),
122+
solar_illumination=1900,
123+
),
124+
Band.create(
125+
name="green",
126+
description=Band.band_description("green"),
127+
solar_illumination=1950,
128+
),
129+
Band.create(
130+
name="blue",
131+
description=Band.band_description("blue"),
132+
solar_illumination=2000,
133+
),
121134
]
122135
asset = pystac.Asset(href="some/path.tif", media_type=pystac.MediaType.GEOTIFF)
123136
EOExtension.ext(asset).bands = new_bands

0 commit comments

Comments
 (0)