Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle sinergise mask renames #372

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion eodatasets3/wagl.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def _unpack_products(
)


def get_quality_masks(dataset: h5py.Dataset, granule: "Granule") -> BandMasks:
def get_quality_masks(
dataset: h5py.Dataset, granule: "Granule", strict=True
) -> BandMasks:
"""
Get a dictionary of any quality masks to apply for each band (if any).
"""
Expand Down Expand Up @@ -216,6 +218,19 @@ def get_quality_masks(dataset: h5py.Dataset, granule: "Granule") -> BandMasks:
# (It's in a 'qi' folder with the original filename)
if not mask_path.exists():
mask_path = level1_data_path / "qi" / Path(location).name
if not mask_path.exists():
# Sinergise seems to simplify the mask filename.
mask_path = (
level1_data_path / "qi" / Path(location).name.replace("MSK_", "")
)
if not mask_path.exists():
if strict:
raise ValueError(
f"Mask path {mask_path} does not exist for band {band_id}"
)
else:
# Nothing found, and we're not being strict.
return {}

# Skip small ones. See reasoning in ESA block above.
if mask_path.stat().st_size < 500:
Expand Down