Skip to content

Commit

Permalink
Sinergise datasets have no product root
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyh committed Dec 21, 2023
1 parent f317605 commit 1ddae38
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eodatasets3/wagl.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ def get_quality_masks(dataset: h5py.Dataset, granule: "Granule") -> BandMasks:
granule_metadata_xml = Path(
granule.source_level1_metadata.accessories["metadata:s2_tile"].path
)
product_root = granule_metadata_xml.parts[0]

if not level1_data_path.exists():
raise ValueError(f"Input level 1 data not found {level1_data_path}")

if level1_data_path.suffix == ".zip":
product_root = granule_metadata_xml.parts[0]
# Parse tile metadata xml file
with zipfile.ZipFile(level1_data_path, "r") as z:
mtd_dict = raw_mask_offsets_from_granule_xml(
Expand Down Expand Up @@ -207,12 +207,12 @@ def get_quality_masks(dataset: h5py.Dataset, granule: "Granule") -> BandMasks:
masks: BandMasks = {}
for band_id in list(mtd_dict.keys()):
type, location = mtd_dict[band_id]
mask_path = level1_data_path / product_root / location
mask_path = level1_data_path / location
# Sinergise use the original tile metdata document, but change the directory structure
# So the metadata mask locations are (always?) wrong.
# It's in a 'qi' folder with the original filename.
if not mask_path.exists():
mask_path = level1_data_path / product_root / "qi" / Path(location).name
mask_path = level1_data_path / "qi" / Path(location).name
masks[band_id] = (type, mask_path.as_posix())
return masks
else:
Expand Down

0 comments on commit 1ddae38

Please sign in to comment.