Skip to content

Commit

Permalink
add converters for Sentinel 1 & 2 level 1
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 committed Feb 15, 2024
1 parent f133bc9 commit 07bb624
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
35 changes: 33 additions & 2 deletions geospaas_processing/converters/idf/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ class Sentinel1IDFConverter(MultiFilesIDFConverter):
"""IDF converter for Sentinel-1 datasets"""

PARAMETER_SELECTORS = (
ParameterSelector(matches=lambda d: re.match('^S1[AB]_[A-Z0-9]{2}_OCN.*$', d.entry_id),
parameter_files=('sentinel1_l2_rvl',)),
ParameterSelector(
matches=lambda d: re.match('^S1[AB]_[A-Z0-9]{2}_OCN.*$', d.entry_id),
parameter_files=('sentinel1_l2_rvl',)),
ParameterSelector(
matches=lambda d: re.match('^S1[AB]_[A-Z0-9]{2}_(GRD|SLC).*$', d.entry_id),
parameter_files=('sentinel1_l1',)),
)

@staticmethod
Expand All @@ -157,6 +161,33 @@ def list_files_to_convert(dataset_file_path):
f"Could not find a measurement directory inside {dataset_file_path}") from error


@IDFConversionManager.register()
class Sentinel2IDFConverter(MultiFilesIDFConverter):
"""IDF converter for Sentinel-2 datasets"""

PARAMETER_SELECTORS = (
ParameterSelector(
matches=lambda d: re.match('^S2[AB]_MSIL1C.*$', d.entry_id),
parameter_files=('sentinel2_l1',)),
)

@staticmethod
def list_files_to_convert(dataset_file_path):
"""Returns the path to the granule L1C directory of the
dataset
"""
measurement_dir = os.path.join(dataset_file_path, 'GRANULE')
try:
return [
os.path.join(measurement_dir, path)
for path in os.listdir(measurement_dir)
if path.startswith('L1C')
]
except (FileNotFoundError, NotADirectoryError) as error:
raise ConversionError(
f"Could not find a measurement directory inside {dataset_file_path}") from error


@IDFConversionManager.register()
class Sentinel3SLSTRL2WSTIDFConverter(MultiFilesIDFConverter):
"""IDF converter for Sentinel 3 SLSTR L2 WST datasets"""
Expand Down
3 changes: 3 additions & 0 deletions geospaas_processing/converters/idf/parameters/sentinel1_l1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-t sentinel1/L1
-o path = seacope/data
collection = sentinel1_l1
3 changes: 3 additions & 0 deletions geospaas_processing/converters/idf/parameters/sentinel2_l1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-t sentinel2/L1
-o path = seacope/data
collection = sentinel2_l1

0 comments on commit 07bb624

Please sign in to comment.