Skip to content

Commit 820b9d5

Browse files
stephencpopeDescartes Labs Build
authored andcommitted
Catalog: Add data_type and ranges to processing levels (#10777)
GitOrigin-RevId: 283361d3d81fc081b2eacdb3a219f3f7f1d311f3
1 parent 63aecaf commit 820b9d5

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

descarteslabs/_dl_modules/catalog/band.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,41 @@ class ProcessingStepAttribute(MappingAttribute):
147147
the coefficients for the processing function. Required.
148148
index : int
149149
Optional index into the named parameter (an array) for the band.
150+
data_type : str or DataType
151+
Optional data type for pixel values in this band.
152+
data_range : tuple(float, float)
153+
Optional normal range of pixel values stored in the band.
154+
display_range : tuple(float, float)
155+
Optional normal range of pixel values stored in the band for display purposes.
156+
physical_range : tuple(float, float)
157+
Optional normal range of physical values stored in the band.
158+
physical_range_units : str
159+
Optional unit of the physical range.
150160
"""
151161

152162
function = TypedAttribute(str)
153163
parameter = TypedAttribute(str)
154164
index = TypedAttribute(int)
165+
data_type = EnumAttribute(DataType)
166+
data_range = TupleAttribute(
167+
min_length=2,
168+
max_length=2,
169+
coerce=True,
170+
attribute_type=float,
171+
)
172+
display_range = TupleAttribute(
173+
min_length=2,
174+
max_length=2,
175+
coerce=True,
176+
attribute_type=float,
177+
)
178+
physical_range = TupleAttribute(
179+
min_length=2,
180+
max_length=2,
181+
coerce=True,
182+
attribute_type=float,
183+
)
184+
physical_range_unit = Attribute()
155185

156186

157187
class ProcessingLevelsAttribute(ModelAttribute, MutableMapping):

descarteslabs/_dl_modules/catalog/readme.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ Guide <catalog_v2_guide>`.
9696
~descarteslabs.catalog.DataType
9797
~descarteslabs.catalog.BandType
9898
~descarteslabs.catalog.Colormap
99+
~descarteslabs.catalog.ProcessingStepAttribute
100+
~descarteslabs.catalog.ProcessingLevelsAttribute
99101
~descarteslabs.catalog.Resolution
100102
~descarteslabs.catalog.ResolutionUnit
101103
~descarteslabs.catalog.File

descarteslabs/_dl_modules/catalog/tests/test_band.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
MicrowaveBand,
1616
ProcessingStepAttribute,
1717
DerivedParamsAttribute,
18+
DataType,
1819
)
1920
from ..product import Product
2021

@@ -286,6 +287,43 @@ def test_processing_levels_create(self):
286287
},
287288
)
288289

290+
b = SpectralBand(
291+
id=band_id,
292+
processing_levels={
293+
"default": "toa_reflectance",
294+
"toa_reflectance": [
295+
{
296+
"function": "fun",
297+
"parameter": "param",
298+
"index": 0,
299+
"data_type": "Float64",
300+
"data_range": [0, 1],
301+
"display_range": [0, 0.4],
302+
"physical_range": [0, 1],
303+
"physical_range_unit": "reflectance",
304+
}
305+
],
306+
},
307+
)
308+
self.assertEqual(
309+
b.processing_levels,
310+
{
311+
"default": "toa_reflectance",
312+
"toa_reflectance": [
313+
ProcessingStepAttribute(
314+
function="fun",
315+
parameter="param",
316+
index=0,
317+
data_type=DataType("Float64"),
318+
data_range=(0.0, 1.0),
319+
display_range=(0, 0.4),
320+
physical_range=(0.0, 1.0),
321+
physical_range_unit="reflectance",
322+
)
323+
],
324+
},
325+
)
326+
289327
with pytest.raises(AttributeValidationError):
290328
SpectralBand(id=band_id, processing_levels={"default": 1})
291329

0 commit comments

Comments
 (0)