Skip to content

Commit

Permalink
mock orbit download from prepGUNW
Browse files Browse the repository at this point in the history
  • Loading branch information
cmarshak committed Aug 14, 2023
1 parent e74c638 commit 89a2bbb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions test/test_GUNW.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import unittest
from pathlib import Path

import eof.download
import hyp3lib
import jsonschema
import numpy as np
Expand Down Expand Up @@ -136,7 +137,7 @@ def test_azimuth_timing_against_interpolation(weather_model_name: str,
6 hours apart and a the azimuth time is changing the interpolation weights for a given pixel at the order
of seconds and thus these two approaches are quite similar.
Effectively, this mocks the following CL script
Effectively, this mocks the following CL script and then compares the output:
```
cmd = f'raider.py ++process calcDelaysGUNW -f {out_path_0} -m {weather_model_name} -interp center_time'
Expand All @@ -146,7 +147,8 @@ def test_azimuth_timing_against_interpolation(weather_model_name: str,
subprocess.run(cmd.split(), stdout=subprocess.PIPE, universal_newlines=True)
```
Getting weather model file names requires patience. For HRRR and center time, here are the calls:
Getting weather model file names requires patience. We mock API requests.
For HRRR and center time, here are the calls:
```
wfile_0 = prepareWeatherModel(model, datetime.datetime(2021, 7, 23, 1, 0), [33.45, 35.45, -119.15, -115.95])
Expand Down Expand Up @@ -194,6 +196,18 @@ def test_azimuth_timing_against_interpolation(weather_model_name: str,
(orbit_dict_for_azimuth_time_test['secondary'], ''),
]
)

# For prepGUNW
side_effect = [
# center-time
orbit_dict_for_azimuth_time_test['reference'],
# azimuth-time
orbit_dict_for_azimuth_time_test['reference'],
]
side_effect = list(map(str, side_effect))
mocker.patch('eof.download.download_eofs',
side_effect=side_effect)

mocker.patch('RAiDER.s1_azimuth_timing.get_slc_id_from_point_and_time',
return_value=[
# Center_time
Expand Down Expand Up @@ -226,6 +240,8 @@ def test_azimuth_timing_against_interpolation(weather_model_name: str,
assert RAiDER.processWM.prepareWeatherModel.call_count == 10
# Only calls for azimuth timing for reference and secondary
assert hyp3lib.get_orb.downloadSentinelOrbitFile.call_count == 2
# Once for center-time and azimuth-time each
assert eof.download.download_eofs.call_count == 2

for ifg_type in ['reference', 'secondary']:
for var in ['troposphereHydrostatic', 'troposphereWet']:
Expand Down
4 changes: 2 additions & 2 deletions tools/RAiDER/aria/prepFromGUNW.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
from datetime import datetime
import numpy as np
import eof.download
import xarray as xr
import rasterio
import geopandas as gpd
Expand All @@ -24,7 +25,6 @@
from RAiDER.logger import logger
from RAiDER.models import credentials
from RAiDER.models.hrrr import HRRR_CONUS_COVERAGE_POLYGON, AK_GEO
from eof.download import download_eofs

## cube spacing in degrees for each model
DCT_POSTING = {'HRRR': 0.05, 'HRES': 0.10, 'GMAO': 0.10, 'ERA5': 0.10, 'ERA5T': 0.10}
Expand Down Expand Up @@ -235,7 +235,7 @@ def get_orbit_file(self):
sat = slc.split('_')[0]
dt = datetime.strptime(f'{self.dates[0]}T{self.mid_time}', '%Y%m%dT%H:%M:%S')

path_orb = download_eofs([dt], [sat], save_dir=orbit_dir)
path_orb = eof.download.download_eofs([dt], [sat], save_dir=orbit_dir)

return path_orb

Expand Down

0 comments on commit 89a2bbb

Please sign in to comment.