Skip to content

Commit 219ef5d

Browse files
LiangJYuyunjunz
andauthored
unit tests (#38)
* unit tests * github action to run unit test in env with miniconda Co-authored-by: Zhang Yunjun <[email protected]>
1 parent 2cc4e66 commit 219ef5d

13 files changed

+121905
-2
lines changed

.github/workflows/unit_tests.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Unit tests
2+
on: [push]
3+
4+
jobs:
5+
unit_tests:
6+
name: Unit tests
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: conda-incubator/setup-miniconda@v2
13+
with:
14+
activate-environment: s1reader
15+
auto-update-conda: true
16+
environment-file: environment.yaml
17+
python-version: 3.9
18+
auto-activate-base: false
19+
- name: Run pytest
20+
shell: bash -l {0}
21+
run: |
22+
conda activate s1reader
23+
pip install .
24+
conda install pytest
25+
pytest

environment.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: s1reader
2+
channels:
3+
- defaults
4+
- conda-forge
5+
dependencies:
6+
- numpy
7+
- gdal
8+
- isce3
9+
- shapely

src/s1reader/s1_burst_slc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def as_dict(self):
369369
temp['lut2d']['data'] = val.lut2d.data.flatten().tolist()
370370

371371
val = temp
372-
elif key in ['orbit']:
372+
elif key == 'orbit':
373373
temp = {}
374374
temp['ref_epoch'] = str(val.reference_epoch)
375375
temp['time'] = {}

src/s1reader/s1_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def burst_from_xml(annotation_path: str, orbit_path: str, tiff_path: str,
368368

369369
# get orbit from state vector list/element tree
370370
sensing_duration = datetime.timedelta(
371-
seconds=n_samples * azimuth_time_interval)
371+
seconds=n_lines * azimuth_time_interval)
372372
orbit = get_burst_orbit(sensing_start, sensing_start + sensing_duration,
373373
osv_list)
374374

tests/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The SAFE zip in the data directory is a light version of an actual Sentinel-1 SAFE zip. The paths within the zip adhere to the ESA specifications. To keep the file size small, the tiff files in the ```measurement` directory have been replaced with empty files (crated with `touch`).
2+
3+
Extra, empty orbit files created with touch to test orbit file finding.

tests/conftest.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pathlib
2+
import pytest
3+
import types
4+
5+
from s1reader import s1_reader
6+
7+
@pytest.fixture(scope="session")
8+
def test_paths():
9+
test_paths = types.SimpleNamespace()
10+
11+
test_path = pathlib.Path(__file__).parent.resolve()
12+
test_paths.safe = f"{test_path}/data/S1A_IW_SLC__1SDV_20200511T135117_20200511T135144_032518_03C421_7768.zip"
13+
test_paths.orbit_dir = f"{test_path}/data/orbits"
14+
test_paths.orbit_file = "S1A_OPER_AUX_POEORB_OPOD_20210318T120818_V20200510T225942_20200512T005942.EOF"
15+
16+
return test_paths
17+
18+
@pytest.fixture(scope="session")
19+
def bursts(test_paths):
20+
i_subswath = 3
21+
pol = 'vv'
22+
23+
orbit_path = f'{test_paths.orbit_dir}/{test_paths.orbit_file}'
24+
bursts = s1_reader.load_bursts(test_paths.safe, orbit_path, i_subswath,
25+
pol)
26+
27+
return bursts
2.21 MB
Binary file not shown.

0 commit comments

Comments
 (0)