-
Notifications
You must be signed in to change notification settings - Fork 39
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 #461 from dbekaert/dev
Release v0.4.0
- Loading branch information
Showing
30 changed files
with
846 additions
and
308 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
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
Binary file added
BIN
+51.3 MB
test/S1-GUNW-D-R-071-tops-20200130_20200124-135156-34956N_32979N-PP-913f-v2_0_4.nc
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
File renamed without changes.
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 |
---|---|---|
|
@@ -16,3 +16,4 @@ los_group: | |
runtime_group: | ||
output_projection: 4326 | ||
cube_spacing_in_m: 5000.0 | ||
output_directory: test/scenario_3 |
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 |
---|---|---|
|
@@ -16,3 +16,4 @@ los_group: | |
runtime_group: | ||
output_projection: 4326 | ||
cube_spacing_in_m: 5000.0 | ||
output_directory: test/scenario_3 |
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,64 @@ | ||
import os | ||
import shutil | ||
import numpy as np | ||
import pytest | ||
import shutil | ||
import subprocess | ||
import xarray as xr | ||
import rasterio as rio | ||
|
||
from test import TEST_DIR | ||
|
||
|
||
def test_GUNW(): | ||
## eventually to be implemented | ||
# home = os.path.expanduser('~') | ||
# netrc = os.path.join(home, '.netrc') | ||
# | ||
# ## make netrc | ||
# if not os.path.exists(netrc): | ||
# name, passw = os.getenv('URSname'), os.getenv('URSpass') | ||
# cmd = f'echo "machine urs.earthdata.nasa.gov login {name} password {passw}" > ~/.netrc' | ||
# subprocess.run(cmd.split()) | ||
# | ||
# cmd = f'chmod 600 {netrc}' | ||
# subprocess.run(cmd.split()) | ||
# | ||
SCENARIO_DIR = os.path.join(TEST_DIR, "GUNW") | ||
os.makedirs(SCENARIO_DIR, exist_ok=True) | ||
GUNW = 'S1-GUNW-D-R-071-tops-20200130_20200124-135156-34956N_32979N-PP-913f-v2_0_4.nc' | ||
orig_GUNW = os.path.join(TEST_DIR, GUNW) | ||
updated_GUNW = os.path.join(SCENARIO_DIR, GUNW) | ||
shutil.copy(orig_GUNW, updated_GUNW) | ||
|
||
|
||
# cmd = f'wget https://grfn.asf.alaska.edu/door/download/{GUNW}' | ||
# proc = subprocess.run(cmd.split(), stdout=subprocess.PIPE, universal_newlines=True) | ||
# assert np.isclose(proc.returncode, 0) | ||
|
||
cmd = f'raider.py ++process calcDelaysGUNW {updated_GUNW} -m GMAO -o {SCENARIO_DIR}' | ||
proc = subprocess.run(cmd.split(), stdout=subprocess.PIPE, universal_newlines=True) | ||
assert np.isclose(proc.returncode, 0) | ||
|
||
## check the CRS and affine are written correctly | ||
epsg = 4326 | ||
transform = (0.1, 0.0, -119.35, 0, -0.1, 35.05) | ||
group = 'science/grids/corrections/external/troposphere' | ||
for v in 'troposphereWet troposphereHydrostatic'.split(): | ||
with rio.open(f'netcdf:{updated_GUNW}:{group}/{v}') as ds: | ||
assert np.isclose(ds.crs.to_epsg(), epsg), 'CRS incorrect' | ||
assert ds.transform.almost_equals(transform), 'Affine Transform incorrect' | ||
|
||
with xr.open_dataset(updated_GUNW, group=group) as ds: | ||
for v in 'troposphereWet troposphereHydrostatic'.split(): | ||
da = ds[v] | ||
assert da.rio.transform().almost_equals(transform), 'Affine Transform incorrect' | ||
|
||
crs = rio.crs.CRS.from_wkt(ds['crs'].crs_wkt) | ||
assert np.isclose(crs.to_epsg(), epsg), 'CRS incorrect' | ||
|
||
|
||
# Clean up files | ||
shutil.rmtree(SCENARIO_DIR) | ||
os.remove('GUNW_20200130-20200124.yaml') | ||
return |
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,86 @@ | ||
import os | ||
import glob | ||
import pytest | ||
import subprocess | ||
import shutil | ||
import yaml | ||
import numpy as np | ||
from test import TEST_DIR | ||
|
||
|
||
def test_datelist(): | ||
SCENARIO_DIR = os.path.join(TEST_DIR, 'datelist') | ||
os.makedirs(SCENARIO_DIR, exist_ok=True) | ||
dates = ['20200124', '20200130'] | ||
|
||
dct_group = { | ||
'aoi_group': {'bounding_box': [28, 39, -123, -112]}, | ||
'date_group': {'date_list': dates}, | ||
'time_group': {'time': '00:00:00'}, | ||
'weather_model': 'GMAO', | ||
'runtime_group': { | ||
'output_directory': SCENARIO_DIR, | ||
'weather_model_directory': os.path.join(SCENARIO_DIR, 'weather_files') | ||
} | ||
} | ||
|
||
params = dct_group | ||
dst = os.path.join(SCENARIO_DIR, 'temp.yaml') | ||
|
||
with open(dst, 'w') as fh: | ||
yaml.dump(params, fh, default_flow_style=False) | ||
|
||
|
||
## run raider on new file (two dates) | ||
cmd = f'raider.py {dst}' | ||
proc = subprocess.run(cmd.split(), stdout=subprocess.PIPE, universal_newlines=True) | ||
assert np.isclose(proc.returncode, 0) | ||
|
||
## check that four files (2x date) were created | ||
n_files = len(glob.glob(os.path.join(SCENARIO_DIR, 'weather_files/*.nc'))) | ||
n_dates = len(dates) | ||
assert np.isclose(n_files, n_dates*2), 'Incorrect number of files produced' | ||
|
||
## clean up | ||
shutil.rmtree(SCENARIO_DIR) | ||
|
||
return dst | ||
|
||
|
||
def test_datestep(): | ||
SCENARIO_DIR = os.path.join(TEST_DIR, 'datelist') | ||
os.makedirs(SCENARIO_DIR, exist_ok=True) | ||
st, en, step = '20200124', '20200130', 3 | ||
n_dates = 3 | ||
|
||
dct_group = { | ||
'aoi_group': {'bounding_box': [28, 39, -123, -112]}, | ||
'date_group': {'date_start': st, 'date_end': en, 'date_step': step}, | ||
'time_group': {'time': '00:00:00'}, | ||
'weather_model': 'GMAO', | ||
'runtime_group': { | ||
'output_directory': SCENARIO_DIR, | ||
'weather_model_directory': os.path.join(SCENARIO_DIR, 'weather_files') | ||
} | ||
} | ||
|
||
params = dct_group | ||
dst = os.path.join(SCENARIO_DIR, 'temp.yaml') | ||
|
||
with open(dst, 'w') as fh: | ||
yaml.dump(params, fh, default_flow_style=False) | ||
|
||
|
||
## run raider on new file (two dates) | ||
cmd = f'raider.py {dst}' | ||
proc = subprocess.run(cmd.split(), stdout=subprocess.PIPE, universal_newlines=True) | ||
assert np.isclose(proc.returncode, 0) | ||
|
||
## check that four files (2x date) were created | ||
n_files = len(glob.glob(os.path.join(SCENARIO_DIR, 'weather_files/*.nc'))) | ||
assert np.isclose(n_files, n_dates*2), 'Incorrect number of files produced' | ||
|
||
## clean up | ||
shutil.rmtree(SCENARIO_DIR) | ||
|
||
return dst |
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
Oops, something went wrong.