Skip to content

Commit

Permalink
add another unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jlmaurer committed Jan 18, 2024
1 parent c165467 commit 3c9c5dc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
31 changes: 30 additions & 1 deletion test/test_scenario_4.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import datetime
import os
import pytest
import xarray

import numpy as np
from pyproj import CRS

from RAiDER.delay import tropo_delay
from RAiDER.delay import tropo_delay, _get_delays_on_cube
from RAiDER.llreader import RasterRDR
from RAiDER.losreader import Zenith
from RAiDER.processWM import prepareWeatherModel
Expand Down Expand Up @@ -36,4 +38,31 @@ def test_aoi_without_xpts():
assert np.nanmean(zen_hydro) > 0


def test_get_delays_on_cube():

los = Zenith()
latfile = os.path.join(SCENARIO_DIR, 'lat.rdr')
lonfile = os.path.join(SCENARIO_DIR, 'lon.rdr')
hgtfile = os.path.join(SCENARIO_DIR, 'hgt.rdr')
aoi = RasterRDR(latfile, lonfile, hgtfile)
dt = datetime.datetime(2020,1,1)

wm = ERA5()
wm.set_latlon_bounds(aoi.bounds())
wm.setTime(dt)
f = prepareWeatherModel(wm, dt, aoi.bounds())

with xarray.load_dataset(f) as ds:
wm_levels = ds.z.values
wm_proj = CRS.from_wkt(ds['proj'].attrs['crs_wkt'])

zref = 10000

with pytest.raises(AttributeError):
aoi.xpts

ds = _get_delays_on_cube(dt, f, wm_proj, aoi, wm_levels, los, wm_proj, zref)

assert len(ds.x) > 0
assert ds.hydro.mean() > 0

5 changes: 3 additions & 2 deletions tools/RAiDER/delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ def tropo_delay(


#TODO: expose this as library function
ds = _get_delays_on_cube(dt, weather_model_file, wm_proj, aoi, height_levels,
los, crs, zref)
ds = _get_delays_on_cube(
dt, weather_model_file, wm_proj, aoi, height_levels, los, crs, zref
)

if (aoi.type() == 'bounding_box') or (aoi.type() == 'Geocube'):
return ds, None
Expand Down

0 comments on commit 3c9c5dc

Please sign in to comment.