Skip to content

Commit

Permalink
Merge pull request #585 from jlmaurer/fix_cli
Browse files Browse the repository at this point in the history
tighter control flow logic for calcDelays
  • Loading branch information
jlmaurer authored Sep 29, 2023
2 parents d9fbf91 + d09c9bb commit d541e63
Show file tree
Hide file tree
Showing 13 changed files with 362 additions and 165 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* Fixes tests for checking availability of HRRR due Issue #596 (above).

## [0.4.4]

## Fixes
* For s1-azimuth-time interpolation, overlapping orbits when one orbit does not cover entire GUNW product errors out. We now ensure state-vectors are both unique and in order before creating a orbit object in ISCE3.

## [0.4.3]
+ Bug fixes, unit tests, docstrings
+ Prevent ray tracing integration from occuring at exactly top of weather model
+ Properly expose z_ref (max integration height) parameter, and dont allow higher than weather model
+ Min version for sentineleof for obtaining restituted orbits.
Expand Down
6 changes: 3 additions & 3 deletions test/test_GUNW.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import json
import os
import shutil
import subprocess
import unittest
from pathlib import Path

Expand All @@ -23,6 +22,7 @@
check_weather_model_availability
)
from RAiDER.cli.raider import calcDelaysGUNW
from RAiDER.models.customExceptions import *


def compute_transform(lats, lons):
Expand Down Expand Up @@ -517,7 +517,7 @@ def test_GUNW_workflow_fails_if_a_download_fails(gunw_azimuth_test, orbit_dict_f
'-interp', 'azimuth_time_grid'
]

with pytest.raises(ValueError):
with pytest.raises(RuntimeError):
calcDelaysGUNW(iargs_1)
RAiDER.s1_azimuth_timing.get_s1_azimuth_time_grid.assert_not_called()

Expand All @@ -536,6 +536,6 @@ def test_value_error_for_file_inputs_when_no_data_available(mocker):
'-interp', 'azimuth_time_grid'
]

with pytest.raises(ValueError):
with pytest.raises(NoWeatherModelData):
calcDelaysGUNW(iargs)
RAiDER.aria.prepFromGUNW.main.assert_not_called()
37 changes: 37 additions & 0 deletions test/test_llreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pandas as pd

from test import GEOM_DIR, TEST_DIR
from pyproj import CRS

from RAiDER.cli.raider import calcDelays

Expand Down Expand Up @@ -41,6 +42,31 @@ def test_latlon_reader_2():
RasterRDR(lat_file='doesnotexist.rdr', lon_file='doesnotexist.rdr')


def test_aoi_epsg():
bbox = [20, 27, -115, -104]
r = BoundingBox(bbox)
r.set_output_spacing(ll_res=0.05)
test = r.get_output_spacing(4978)
assert test == 0.05 * 1e5


def test_set_output_dir():
bbox = [20, 27, -115, -104]
r = BoundingBox(bbox)
r.set_output_directory('dummy_directory')
assert r._output_directory == 'dummy_directory'


def test_set_xygrid():
bbox = [20, 27, -115, -104]
crs = CRS.from_epsg(4326)
r = BoundingBox(bbox)
r.set_output_spacing(ll_res=0.1)
r.set_output_xygrid(dst_crs=4978)
r.set_output_xygrid(dst_crs=crs)
assert True


def test_latlon_reader():
latfile = os.path.join(GEOM_DIR, 'lat.rdr')
lonfile = os.path.join(GEOM_DIR, 'lon.rdr')
Expand All @@ -60,6 +86,17 @@ def test_latlon_reader():
assert all([np.allclose(b, t, rtol=1e-4) for b, t in zip(query.bounds(), bounds_true)])


def test_badllfiles(station_file):
latfile = os.path.join(GEOM_DIR, 'lat.rdr')
lonfile = os.path.join(GEOM_DIR, 'lon_dummy.rdr')
station_file = station_file
with pytest.raises(ValueError):
RasterRDR(lat_file=latfile, lon_file=lonfile)
with pytest.raises(ValueError):
RasterRDR(lat_file=latfile, lon_file=station_file)
with pytest.raises(ValueError):
RasterRDR(lat_file=station_file, lon_file=lonfile)

def test_read_bbox():
bbox = [20, 27, -115, -104]
query = BoundingBox(bbox)
Expand Down
2 changes: 1 addition & 1 deletion test/test_losreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_get_sv_3(svs):
def test_get_sv_4(svs):
true_svs = svs
filename = os.path.join(ORB_DIR, 'no_exist.txt')
with pytest.raises(FileNotFoundError):
with pytest.raises(ValueError):
get_sv(filename, true_svs[0][0], pad=3*60)


Expand Down
11 changes: 5 additions & 6 deletions test/test_weather_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from RAiDER.models.gmao import GMAO
from RAiDER.models.merra2 import MERRA2
from RAiDER.models.ncmr import NCMR
from RAiDER.models.customExceptions import *


_LON0 = 0
Expand Down Expand Up @@ -156,12 +157,12 @@ def test_weatherModel_basic1(model: MockWeatherModel):
wm.setTime('19720229', fmt='%Y%m%d') # test a leap year
assert wm._time == datetime.datetime(1972, 2, 29, 0, 0, 0)

with pytest.raises(RuntimeError):
with pytest.raises(DatetimeOutsideRange):
wm.checkTime(datetime.datetime(1950, 1, 1))

wm.checkTime(datetime.datetime(2000, 1, 1))

with pytest.raises(RuntimeError):
with pytest.raises(DatetimeOutsideRange):
wm.checkTime(datetime.datetime.now())


Expand Down Expand Up @@ -309,7 +310,7 @@ def test_hrrr(hrrr: HRRR):
assert wm._Name == 'HRRR'
assert wm._valid_range[0] == datetime.datetime(2016, 7, 15)
assert wm._proj.to_epsg() is None
with pytest.raises(RuntimeError):
with pytest.raises(DatetimeOutsideRange):
wm.checkTime(datetime.datetime(2010, 7, 15))
wm.checkTime(datetime.datetime(2018, 7, 12))

Expand All @@ -329,7 +330,7 @@ def test_hrrrak(hrrrak: HRRRAK):
with pytest.raises(ValueError):
wm.checkValidBounds([15, 20, 265, 270])

with pytest.raises(RuntimeError):
with pytest.raises(DatetimeOutsideRange):
wm.checkTime(datetime.datetime(2018, 7, 12))

wm.checkTime(datetime.datetime(2018, 7, 15))
Expand Down Expand Up @@ -431,7 +432,6 @@ def test_hrrr_badloc(wm:hrrr=HRRR):
with pytest.raises(ValueError):
wm._fetch('dummy_filename')


def test_hrrrak_dl(tmp_path: Path, wm:hrrrak=HRRRAK):
wm = wm()
d = tmp_path / "files"
Expand All @@ -443,7 +443,6 @@ def test_hrrrak_dl(tmp_path: Path, wm:hrrrak=HRRRAK):
wm._fetch(fname)
assert True


def test_hrrrak_dl2(tmp_path: Path, wm:hrrrak=HRRRAK):
# test the international date line crossing
wm = wm()
Expand Down
9 changes: 8 additions & 1 deletion tools/RAiDER/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ def main():

sys.argv = [args.process, *unknowns]

from RAiDER.cli.raider import calcDelays, downloadGNSS, calcDelaysGUNW
if args.process == 'calcDelays':
from RAiDER.cli.raider import calcDelays
elif args.process == 'downloadGNSS':
from RAiDER.cli.raider import downloadGNSS
elif args.process == 'calcDelaysGUNW':
from RAiDER.cli.raider import calcDelaysGUNW
else:
raise NotImplementedError(f'Process {args.process} has not been fully implemented')

try:
# python >=3.10 interface
Expand Down
Loading

0 comments on commit d541e63

Please sign in to comment.