Skip to content

Commit fd6de36

Browse files
committed
small modifications with config files and unit test
1 parent 6890b46 commit fd6de36

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

grdwindinversion/data_config.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#'ecmwf_0100_1h': '../ecmwf/forecast/hourly/0100deg/netcdf_light_REPRO_tree/%Y/%j/ECMWF_FORECAST_0100_%Y%m%d%H%M_10U_10V.nc'
2-
#'ecmwf_0125_1h': '../ecmwf/0.125deg/1h/forecasts/%Y/%j/ecmwf_%Y%m%d%H%M.nc'
1+
'ecmwf_0100_1h': '../ecmwf/forecast/hourly/0100deg/netcdf_light_REPRO_tree/%Y/%j/ECMWF_FORECAST_0100_%Y%m%d%H%M_10U_10V.nc'
2+
'ecmwf_0125_1h': '../ecmwf/0.125deg/1h/forecasts/%Y/%j/ecmwf_%Y%m%d%H%M.nc'
3+
4+
5+
unit_test_s1_product: './sentinel-1a/L1/IW/S1A_IW_GRDH_1S/2021/252/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE'
6+
unit_test_rcm_product: './l1/rcm/rcm-1/sclnd/2023/273/RCM1_OK2767220_PK2769320_1_SCLND_20230930_214014_VV_VH_GRD'
7+
unit_test_rs2_product: './L1/VV_VH/2022/247/RS2_OK141302_PK1242223_DK1208537_SCWA_20220904_093402_VV_VH_SGF'
38

4-
'ecmwf_0100_1h': '/home/datawork-cersat-public/provider/ecmwf/forecast/hourly/0100deg/netcdf_light_REPRO_tree/%Y/%j/ECMWF_FORECAST_0100_%Y%m%d%H%M_10U_10V.nc'
5-
'ecmwf_0125_1h': '/home/datawork-cersat-intranet/project/ecmwf/0.125deg/1h/forecasts/%Y/%j/ecmwf_%Y%m%d%H%M.nc'

grdwindinversion/load_config.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import os
44
import grdwindinversion
55
from yaml import CLoader as Loader
6-
local_config_potential_path = os.path.expanduser(
6+
local_config_potential_path1 = os.path.expanduser(
77
'~/.grdwindinversion/data_config.yaml')
8-
9-
if os.path.exists(local_config_potential_path):
10-
config_path = local_config_potential_path
8+
local_config_potential_path2 = os.path.join(os.path.dirname(
9+
grdwindinversion.__file__), 'local_data_config.yaml')
10+
if os.path.exists(local_config_potential_path1):
11+
config_path = local_config_potential_path1
12+
elif os.path.exists(local_config_potential_path2):
13+
config_path = local_config_potential_path2
1114
else:
1215
config_path = os.path.join(os.path.dirname(
1316
grdwindinversion.__file__), 'data_config.yaml')

tests/test_grdwindinversion_ci.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import os
33
import urllib.request
44
from grdwindinversion.inversion import makeL2
5+
import xsar
6+
from grdwindinversion.load_config import getConf
57

68
# What must be done by the tests:
79
# - Download L1 data
@@ -13,12 +15,15 @@
1315
# - For recal : download auxiliary files
1416
#
1517

16-
18+
S1_path = getConf()['unit_test_s1_product']
19+
rcm_path = getConf()['unit_test_rcm_product']
20+
rs2_path = getConf()['unit_test_rs2_product']
21+
print('S1_path',S1_path)
1722
def test_makeL2_generation():
1823
l1_files = [
19-
"./test_data/L1/S1A_IW_GRDH_1SDV_20210909T130650_20210909T130715_039605_04AE83_C34F.SAFE",
20-
"./test_data/L1/RCM1_OK2767220_PK2769320_1_SCLND_20230930_214014_VV_VH_GRD",
21-
"./test_data/L1/RS2_OK141302_PK1242223_DK1208537_SCWA_20220904_093402_VV_VH_SGF"
24+
xsar.get_test_file(S1_path),
25+
xsar.get_test_file(rcm_path),
26+
xsar.get_test_file(rs2_path)
2227
]
2328

2429
# l1_files = [
@@ -52,3 +57,6 @@ def test_makeL2_generation():
5257
assert (
5358
"owiWindSpeed" in dataset.variables
5459
), "Expected variable 'owiWindSpeed' missing in the dataset"
60+
61+
if __name__ == '__main__':
62+
test_makeL2_generation()

0 commit comments

Comments
 (0)