diff --git a/tests/test_esa_safe.py b/tests/test_esa_safe.py index 34a458b..25e3e09 100644 --- a/tests/test_esa_safe.py +++ b/tests/test_esa_safe.py @@ -229,3 +229,28 @@ def test_parse_manifest_sentinel2( res_attrs, res_files = esa_safe.parse_manifest_sentinel2(manifest) assert res_attrs == expected + + +def test_parse_original_manifest_sentinel1() -> None: + manifest_path = str( + DATA_FOLDER + / "S1B_IW_SLC__1SDV_20210401T052622_20210401T052650_026269_032297_EFA4.SAFE" + / "manifest.safe" + ) + + res, _ = esa_safe.parse_original_manifest_sentinel1(manifest_path) + + assert isinstance(res, dict) + assert "safe:platform" in res + assert set(res["safe:platform"]) == { + "safe:nssdcIdentifier", + "safe:familyName", + "safe:number", + "safe:instrument", + } + + _, res = esa_safe.parse_original_manifest_sentinel1(manifest_path) + + assert isinstance(res, list) + assert isinstance(res[0], dict) + assert "@href" in res[0] diff --git a/xarray_sentinel/esa_safe.py b/xarray_sentinel/esa_safe.py index cb2a8e8..2023c8b 100644 --- a/xarray_sentinel/esa_safe.py +++ b/xarray_sentinel/esa_safe.py @@ -24,7 +24,10 @@ @functools.lru_cache() def sentinel1_schemas(schema_type: str) -> xmlschema.XMLSchema: support_dir = pkg_resources.resource_filename(__name__, "resources/sentinel1") - schema_paths = {"product": os.path.join(support_dir, "s1-level-1-product.xsd")} + schema_paths = { + "manifest": os.path.join(support_dir, "my-xfdu.xsd"), + "product": os.path.join(support_dir, "s1-level-1-product.xsd"), + } return xmlschema.XMLSchema(schema_paths[schema_type]) @@ -158,6 +161,22 @@ def parse_manifest_sentinel1( return attributes, files +# unused until we add an interface to access original metadata +def parse_original_manifest_sentinel1( + manifest_path: PathType, +) -> T.Tuple[T.Dict[str, T.Any], T.Dict[str, str]]: + schema = sentinel1_schemas("manifest") + + xml_metadata = {} + for xml_tags in schema.to_dict(manifest_path, ".//xmlData"): + for key, value in xml_tags.items(): + xml_metadata[key] = value + + fileLocation = schema.to_dict(manifest_path, ".//fileLocation") + + return xml_metadata, fileLocation + + def parse_manifest_sentinel2( manifest: ElementTree.ElementTree, ) -> T.Tuple[T.Dict[str, T.Any], T.Dict[str, str]]: diff --git a/xarray_sentinel/resources/sentinel1/my-gml.xsd b/xarray_sentinel/resources/sentinel1/my-gml.xsd new file mode 100644 index 0000000..9c9a718 --- /dev/null +++ b/xarray_sentinel/resources/sentinel1/my-gml.xsd @@ -0,0 +1,4 @@ + + + + diff --git a/xarray_sentinel/resources/sentinel1/my-no-namespace.xsd b/xarray_sentinel/resources/sentinel1/my-no-namespace.xsd new file mode 100644 index 0000000..37c5d5b --- /dev/null +++ b/xarray_sentinel/resources/sentinel1/my-no-namespace.xsd @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xarray_sentinel/resources/sentinel1/my-safe-sentinel-1.0-sentinel-1-sar-level-1.xsd b/xarray_sentinel/resources/sentinel1/my-safe-sentinel-1.0-sentinel-1-sar-level-1.xsd new file mode 100644 index 0000000..cb21d9d --- /dev/null +++ b/xarray_sentinel/resources/sentinel1/my-safe-sentinel-1.0-sentinel-1-sar-level-1.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xarray_sentinel/resources/sentinel1/my-safe-sentinel-1.0-sentinel-1.xsd b/xarray_sentinel/resources/sentinel1/my-safe-sentinel-1.0-sentinel-1.xsd new file mode 100644 index 0000000..054f838 --- /dev/null +++ b/xarray_sentinel/resources/sentinel1/my-safe-sentinel-1.0-sentinel-1.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/xarray_sentinel/resources/sentinel1/my-safe-sentinel-1.0.xsd b/xarray_sentinel/resources/sentinel1/my-safe-sentinel-1.0.xsd new file mode 100644 index 0000000..71e7392 --- /dev/null +++ b/xarray_sentinel/resources/sentinel1/my-safe-sentinel-1.0.xsd @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xarray_sentinel/resources/sentinel1/my-xfdu.xsd b/xarray_sentinel/resources/sentinel1/my-xfdu.xsd new file mode 100644 index 0000000..14eb716 --- /dev/null +++ b/xarray_sentinel/resources/sentinel1/my-xfdu.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +