Skip to content

Commit

Permalink
Add parse_swath_timings (with tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Apr 14, 2021
1 parent 58936ca commit af4e440
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_esa_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,31 @@ def test_parse_orbit() -> None:
assert set(res[0]) == expected


def test_parse_swath_timing() -> None:
annotation_path = (
DATA_FOLDER
/ "S1B_IW_SLC__1SDV_20210401T052622_20210401T052650_026269_032297_EFA4.SAFE"
/ "annotation"
/ "s1b-iw1-slc-vv-20210401t052624-20210401t052649-026269-032297-004.xml"
)
expected = {
"azimuthTime",
"azimuthAnxTime",
"sensingTime",
"byteOffset",
"firstValidSample",
"lastValidSample",
}
res = esa_safe.parse_swath_timing(annotation_path)

assert isinstance(res, dict)
assert "burstList" in res
assert "burst" in res["burstList"]
burst_list = res["burstList"]["burst"]
assert isinstance(burst_list, list)
assert set(burst_list[0]) == expected


@pytest.mark.parametrize("product_id,expected", SENTINEL1_ATTRIBUTES.items())
def test_parse_manifest_sentinel1(
product_id: str, expected: T.Dict[str, T.Any]
Expand Down
4 changes: 4 additions & 0 deletions xarray_sentinel/esa_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def parse_geolocation_grid_points(
return parse_tag_list(annotation_path, "product", ".//geolocationGridPoint")


def parse_swath_timing(annotation_path: PathType,) -> T.List[T.Dict[str, T.Any]]:
return parse_tag_list(annotation_path, "product", ".//swathTiming")


def open_manifest(
product_folder: T.Union[str, "os.PathLike[str]"]
) -> ElementTree.ElementTree:
Expand Down

0 comments on commit af4e440

Please sign in to comment.