-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from GeoscienceAustralia/scene-and-orbit-tests
Functions and tests for managing scenes and orbits
- Loading branch information
Showing
8 changed files
with
264 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ jobs: | |
- name: Run tests | ||
shell: micromamba-shell {0} | ||
run: | | ||
pytest | ||
pytest tests/sar_antarctica/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from sar_antarctica.nci.preparation.orbits import find_latest_orbit_for_scene | ||
from sar_antarctica.nci.preparation.scenes import find_scene_file_from_id | ||
|
||
import dataclasses | ||
from datetime import datetime | ||
from pathlib import Path | ||
import pytest | ||
|
||
@dataclasses.dataclass | ||
class Scene: | ||
id: str | ||
file: Path | ||
sensor: str | ||
start_date: datetime | ||
stop_date: datetime | ||
latest_orbit: Path | ||
latest_poe_orbit: Path | ||
latest_res_orbit: Path | ||
|
||
|
||
scene_1 = Scene( | ||
id="S1A_EW_GRDM_1SDH_20220612T120348_20220612T120452_043629_053582_0F66", | ||
file=Path("/g/data/fj7/Copernicus/Sentinel-1/C-SAR/GRD/2022/2022-06/65S115E-70S120E/S1A_EW_GRDM_1SDH_20220612T120348_20220612T120452_043629_053582_0F66.zip"), | ||
sensor="S1A", | ||
start_date=datetime(2022,6,12,12,3,48), | ||
stop_date=datetime(2022,6,12,12,4,52), | ||
latest_orbit=Path("/g/data/fj7/Copernicus/Sentinel-1/POEORB/S1A/S1A_OPER_AUX_POEORB_OPOD_20220702T081845_V20220611T225942_20220613T005942.EOF"), | ||
latest_poe_orbit=Path("/g/data/fj7/Copernicus/Sentinel-1/POEORB/S1A/S1A_OPER_AUX_POEORB_OPOD_20220702T081845_V20220611T225942_20220613T005942.EOF"), | ||
latest_res_orbit=Path("/g/data/fj7/Copernicus/Sentinel-1/RESORB/S1A/S1A_OPER_AUX_RESORB_OPOD_20220612T143829_V20220612T104432_20220612T140202.EOF"), | ||
) | ||
|
||
scene_2 = Scene( | ||
id="S1B_EW_GRDM_1SDH_20191130T165626_20191130T165726_019159_0242A2_2F58", | ||
file=Path("/g/data/fj7/Copernicus/Sentinel-1/C-SAR/GRD/2019/2019-11/65S160E-70S165E/S1B_EW_GRDM_1SDH_20191130T165626_20191130T165726_019159_0242A2_2F58.zip"), | ||
sensor="S1B", | ||
start_date=datetime(2019,11,30,16,56,26), | ||
stop_date=datetime(2019,11,30,16,57,26), | ||
latest_orbit=Path("/g/data/fj7/Copernicus/Sentinel-1/POEORB/S1B/S1B_OPER_AUX_POEORB_OPOD_20191220T110516_V20191129T225942_20191201T005942.EOF"), | ||
latest_poe_orbit=Path("/g/data/fj7/Copernicus/Sentinel-1/POEORB/S1B/S1B_OPER_AUX_POEORB_OPOD_20191220T110516_V20191129T225942_20191201T005942.EOF"), | ||
latest_res_orbit=Path("/g/data/fj7/Copernicus/Sentinel-1/RESORB/S1B/S1B_OPER_AUX_RESORB_OPOD_20191130T210136_V20191130T154804_20191130T190534.EOF"), | ||
) | ||
|
||
scenes = [scene_1, scene_2] | ||
|
||
@pytest.mark.parametrize("scene", scenes) | ||
def test_find_latest_orbit_for_scene(scene: Scene): | ||
assert find_latest_orbit_for_scene(scene.id) == scene.latest_orbit | ||
assert find_latest_orbit_for_scene(scene.id, orbit_type="RES") == scene.latest_res_orbit | ||
assert find_latest_orbit_for_scene(scene.id, orbit_type="POE") == scene.latest_poe_orbit | ||
|
||
|
||
@pytest.mark.parametrize("scene", scenes) | ||
def test_find_scene_file_from_id(scene: Scene): | ||
assert find_scene_file_from_id(scene.id) == scene.file |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from sar_antarctica.nci.preparation.orbits import parse_orbit_file_dates | ||
|
||
from pathlib import Path | ||
import pytest | ||
import dataclasses | ||
from datetime import datetime | ||
|
||
@dataclasses.dataclass | ||
class Orbit: | ||
file: str | ||
published_date: datetime | ||
start_date: datetime | ||
stop_date: datetime | ||
|
||
orbit_1 = Orbit( | ||
file="S1A_OPER_AUX_POEORB_OPOD_20141207T123431_V20141115T225944_20141117T005944.EOF", | ||
published_date=datetime(2014, 12, 7,12,34,31), | ||
start_date=datetime(2014,11,15,22,59,44), | ||
stop_date=datetime(2014,11,17,0,59,44) | ||
) | ||
orbit_2 = Orbit( | ||
file="S1A_OPER_AUX_POEORB_OPOD_20191220T120706_V20191129T225942_20191201T005942.EOF", | ||
published_date=datetime(2019,12,20,12,7,6), | ||
start_date=datetime(2019,11,29,22,59,42), | ||
stop_date=datetime(2019,12,1,0,59,42) | ||
) | ||
|
||
orbits = [orbit_1, orbit_2] | ||
|
||
@pytest.mark.parametrize("orbit", orbits) | ||
def test_parse_orbit_file_dates(orbit: Orbit): | ||
date_tuple = (orbit.published_date, orbit.start_date, orbit.stop_date) | ||
assert parse_orbit_file_dates(orbit.file) == date_tuple |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import datetime | ||
from sar_antarctica.nci.preparation.scenes import ( | ||
parse_scene_file_dates, | ||
parse_scene_file_sensor, | ||
) | ||
|
||
import dataclasses | ||
from datetime import datetime | ||
from pathlib import Path | ||
import pytest | ||
|
||
@dataclasses.dataclass | ||
class Scene: | ||
id: str | ||
file: Path | ||
sensor: str | ||
start_date: datetime | ||
stop_date: datetime | ||
|
||
scene_1 = Scene( | ||
id="S1A_EW_GRDM_1SDH_20200330T165825_20200330T165929_031907_03AF02_8570", | ||
file=Path("/g/data/fj7/Copernicus/Sentinel-1/C-SAR/GRD/2020/2020-03/70S050E-75S055E/S1A_EW_GRDM_1SDH_20200330T165825_20200330T165929_031907_03AF02_8570.zip"), | ||
sensor="S1A", | ||
start_date=datetime(2020,3,30,16,58,25), | ||
stop_date=datetime(2020,3,30,16,59,29) | ||
) | ||
|
||
scene_2 = Scene( | ||
id="S1B_EW_GRDM_1SDH_20210914T112333_20210914T112403_028693_036C96_3EA8", | ||
file=Path("/g/data/fj7/Copernicus/Sentinel-1/C-SAR/GRD/2021/2021-09/60S120E-65S125E/S1B_EW_GRDM_1SDH_20210914T112333_20210914T112403_028693_036C96_3EA8.zip"), | ||
sensor="S1B", | ||
start_date=datetime(2021,9,14,11,23,33), | ||
stop_date=datetime(2021,9,14,11,24,3) | ||
) | ||
|
||
scenes = [scene_1, scene_2] | ||
|
||
@pytest.mark.parametrize("scene", scenes) | ||
def test_parse_scene_file_dates(scene: Scene): | ||
date_tuple = (scene.start_date, scene.stop_date) | ||
assert parse_scene_file_dates(scene.id) == date_tuple | ||
|
||
|
||
@pytest.mark.parametrize("scene", scenes) | ||
def test_parse_scene_file_sensor(scene: Scene): | ||
assert parse_scene_file_sensor(scene.id) == scene.sensor | ||
|
||
|