Skip to content

Commit bb9c76c

Browse files
committed
- FIX: Fixing condensed name to avoid duplicates:
- adding the `job_id` for `VHR` products - adding the polarization channels for `SAR` products
1 parent 88088eb commit bb9c76c

12 files changed

Lines changed: 80 additions & 64 deletions

File tree

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
### Bug Fixes
1313

14+
- FIX: Fixing condensed name to avoid duplicates:
15+
- adding the `job_id` for `VHR` products
16+
- adding the polarization channels for `SAR` products
1417
- FIX: Remove import of pystac in `stac_utils`
1518
- FIX: Fix bug for `Vision-1` data looking for non-existing RPC files in case of `ORTP` product type
1619
- FIX: Fix quicklook regex for `Vision-1` data

CI/SCRIPTS/test_satellites.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ def _test_core(
191191
)
192192
# Write to path if needed
193193
if not extent_path.exists():
194-
raise FileNotFoundError(f"Extent not found for {prod}!")
194+
raise FileNotFoundError(
195+
f"Extent not found for {prod.condensed_name}!"
196+
)
195197
# extent_path = os.path.join(
196198
# tmp_dir, f"{prod.condensed_name}_extent.geojson"
197199
# )
@@ -218,7 +220,9 @@ def _test_core(
218220
)
219221
# Write to path if needed
220222
if not footprint_path.exists():
221-
raise FileNotFoundError(f"Footprint not found for {prod}!")
223+
raise FileNotFoundError(
224+
f"Footprint not found for {prod.condensed_name}!"
225+
)
222226
# footprint_path = os.path.join(
223227
# tmp_dir, f"{prod.condensed_name}_footprint.geojson"
224228
# )

eoreader/products/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
"SnapDems",
130130
"CosmoProduct",
131131
"CosmoProductType",
132-
"CosmoPolarization",
133132
"CsgProduct",
134133
"CsgSensorMode",
135134
"CskProduct",
@@ -138,12 +137,10 @@
138137
"IceyeProductType",
139138
"IceyeSensorMode",
140139
"RcmProduct",
141-
"RcmPolarization",
142140
"RcmProductType",
143141
"RcmSensorMode",
144142
"Rs2Product",
145143
"Rs2ProductType",
146-
"Rs2Polarization",
147144
"Rs2SensorMode",
148145
"S1Product",
149146
"S1SensorMode",
@@ -158,12 +155,12 @@
158155
"TsxSensorMode",
159156
]
160157
from .sar.sar_product import SarProduct, SarProductType, SnapDems
161-
from .sar.cosmo_product import CosmoProduct, CosmoProductType, CosmoPolarization
158+
from .sar.cosmo_product import CosmoProduct, CosmoProductType
162159
from .sar.csg_product import CsgProduct, CsgSensorMode
163160
from .sar.csk_product import CskProduct, CskSensorMode
164161
from .sar.iceye_product import IceyeProduct, IceyeProductType, IceyeSensorMode
165-
from .sar.rcm_product import RcmProduct, RcmPolarization, RcmProductType, RcmSensorMode
166-
from .sar.rs2_product import Rs2Product, Rs2ProductType, Rs2Polarization, Rs2SensorMode
162+
from .sar.rcm_product import RcmProduct, RcmProductType, RcmSensorMode
163+
from .sar.rs2_product import Rs2Product, Rs2ProductType, Rs2SensorMode
167164
from .sar.s1_product import S1Product, S1SensorMode, S1ProductType
168165
from .sar.saocom_product import (
169166
SaocomProduct,

eoreader/products/optical/dimap_product.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,3 +1217,12 @@ def get_quicklook_path(self) -> str:
12171217
LOGGER.warning(f"No quicklook found in {self.condensed_name}")
12181218

12191219
return quicklook_path
1220+
1221+
def _get_job_id(self) -> str:
1222+
"""
1223+
Get VHR job ID
1224+
1225+
Returns:
1226+
str: VHR product ID
1227+
"""
1228+
return self.split_name[-1]

eoreader/products/optical/maxar_product.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,3 +1261,12 @@ def get_quicklook_path(self) -> str:
12611261
LOGGER.warning(f"No quicklook found in {self.condensed_name}")
12621262

12631263
return quicklook_path
1264+
1265+
def _get_job_id(self) -> str:
1266+
"""
1267+
Get VHR job ID
1268+
1269+
Returns:
1270+
str: VHR product ID
1271+
"""
1272+
return self.split_name[0].split("-")[-1]

eoreader/products/optical/pneo_product.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,12 @@ def _set_instrument(self) -> None:
121121
Pleiades: https://earth.esa.int/eogateway/missions/pleiades-neo
122122
"""
123123
self.instrument = "Pleiades-Neo Imager"
124+
125+
def _get_job_id(self) -> str:
126+
"""
127+
Get VHR job ID
128+
129+
Returns:
130+
str: VHR product ID
131+
"""
132+
return self.split_name[-5]

eoreader/products/optical/vhr_product.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,22 @@ def __init__(
8383
self._pan_res = None
8484
self._ms_res = None
8585

86+
self._job_id = None
87+
8688
# Initialization from the super class
8789
super().__init__(product_path, archive_path, output_path, remove_tmp, **kwargs)
8890

91+
def _post_init(self, **kwargs) -> None:
92+
"""
93+
Function used to post_init the products
94+
(setting sensor type, band names and so on)
95+
"""
96+
# Job ID
97+
self._job_id = self._get_job_id()
98+
99+
# Post init done by the super class
100+
super()._post_init(**kwargs)
101+
89102
def get_default_band_path(self, **kwargs) -> Union[CloudPath, Path]:
90103
"""
91104
Get default band (:code:`GREEN` for optical data) path.
@@ -467,7 +480,7 @@ def _get_condensed_name(self) -> str:
467480
Returns:
468481
str: Condensed name
469482
"""
470-
return f"{self.get_datetime()}_{self.constellation.name}_{self.product_type.name}_{self.band_combi.name}"
483+
return f"{self.get_datetime()}_{self.constellation.name}_{self.product_type.name}_{self.band_combi.name}_{self._job_id}"
471484

472485
def _get_path(
473486
self, filename: str = "", extension: str = ""
@@ -683,10 +696,20 @@ def default_transform(self, **kwargs) -> (affine.Affine, int, int, CRS):
683696
@abstractmethod
684697
def _get_tile_path(self) -> Union[CloudPath, Path]:
685698
"""
686-
Get the DIMAP filepath
699+
Get the VHR tile path
700+
701+
Returns:
702+
Union[CloudPath, Path]: VHR filepath
703+
"""
704+
raise NotImplementedError
705+
706+
@abstractmethod
707+
def _get_job_id(self) -> Union[CloudPath, Path]:
708+
"""
709+
Get VHR job ID
687710
688711
Returns:
689-
Union[CloudPath, Path]: DIMAP filepath
712+
Union[CloudPath, Path]: VHR product ID
690713
"""
691714
raise NotImplementedError
692715

eoreader/products/optical/vis1_product.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,3 +658,12 @@ def get_quicklook_path(self) -> str:
658658
LOGGER.warning(f"No quicklook found in {self.condensed_name}")
659659

660660
return quicklook_path
661+
662+
def _get_job_id(self) -> str:
663+
"""
664+
Get VHR job ID
665+
666+
Returns:
667+
str: VHR product ID
668+
"""
669+
return self.split_name[-2]

eoreader/products/sar/cosmo_product.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,6 @@ class CosmoProductType(ListEnum):
7373
"""Level 1D, Geocoded Terrain Corrected"""
7474

7575

76-
@unique
77-
class CosmoPolarization(ListEnum):
78-
"""
79-
COSMO-SkyMed (both generations) polarizations used during the acquisition.
80-
More info
81-
`here <https://egeos.my.salesforce.com/sfc/p/#1r000000qoOc/a/69000000JXxZ/WEEbowzi5cmY8vLqyfAAMKZ064iN1eWw_qZAgUkTtXI>`_.
82-
"""
83-
84-
HH = "HH"
85-
"""Horizontal Tx/Horizontal Rx for Himage, ScanSAR and Spotlight modes"""
86-
87-
VV = "VV"
88-
"""Vertical Tx/Vertical Rx for Himage, ScanSAR and Spotlight modes"""
89-
90-
HV = "HV"
91-
"""Horizontal Tx/Vertical Rx for Himage, ScanSAR"""
92-
93-
VH = "VH"
94-
"""Vertical Tx/Horizontal Rx for Himage, ScanSAR"""
95-
96-
9776
class CosmoProduct(SarProduct):
9877
"""
9978
Class for COSMO-SkyMed (both generations) Products

eoreader/products/sar/rcm_product.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,6 @@ class RcmSensorMode(ListEnum):
113113
""" Spotlight Mode [FSL] """
114114

115115

116-
@unique
117-
class RcmPolarization(ListEnum):
118-
"""
119-
RADARSAT-Constellation polarization mode.
120-
Take a look `here <https://catalyst.earth/catalyst-system-files/help/references/gdb_r/RADARSAT_Constellation.html>`_.
121-
"""
122-
123-
RH = "RH"
124-
RV = "RV"
125-
HH = "HH"
126-
VV = "VV"
127-
VH = "VH"
128-
HV = "HV"
129-
130-
131116
class RcmProduct(SarProduct):
132117
"""
133118
Class for RADARSAT-Constellation Products
@@ -375,7 +360,7 @@ def _read_mtd(self) -> (etree._Element, dict):
375360

376361
def _get_condensed_name(self) -> str:
377362
"""
378-
Get products condensed name ({acq_datetime}_RCM_{sensor_mode}_{product_type}).
363+
Get products condensed name ({acq_datetime}_{constellation}_{polarization}_{sensor_mode}_{product_type}).
379364
380365
Returns:
381366
str: Condensed RCM name
@@ -396,7 +381,8 @@ def _get_condensed_name(self) -> str:
396381
else:
397382
mode_name = self.sensor_mode.name
398383

399-
return f"{self.get_datetime()}_{self.constellation.name}_{mode_name}_{self.product_type.value}"
384+
pol_chan = [pol.value for pol in self.pol_channels]
385+
return f"{self.get_datetime()}_{self.constellation.name}_{'_'.join(pol_chan)}_{mode_name}_{self.product_type.value}"
400386

401387
def get_quicklook_path(self) -> str:
402388
"""

0 commit comments

Comments
 (0)