• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dbekaert / RAiDER / 4f753398-e5bc-44cd-96d0-6e7eb936a270

29 Jun 2025 03:46AM UTC coverage: 94.756% (+0.5%) from 94.207%
4f753398-e5bc-44cd-96d0-6e7eb936a270

Pull #745

circleci

garlic-os
Update CHANGELOG.md for #745
Pull Request #745: Run tests in parallel, use temp directories for all test artifacts

425 of 516 new or added lines in 24 files covered. (82.36%)

2 existing lines in 2 files now uncovered.

3198 of 3375 relevant lines covered (94.76%)

0.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.29
/test/test_intersect.py
1
from pathlib import Path
1✔
2

3
import numpy as np
1✔
4
import pandas as pd
1✔
5
import pytest
1✔
6
import rasterio
1✔
7
from scipy.interpolate import griddata
1✔
8

9
from RAiDER.cli.raider import calcDelays
1✔
10
from RAiDER.utilFcns import write_yaml
1✔
11
from test import TEST_DIR, WM_DIR
1✔
12

13

14
SCENARIO_DIR = TEST_DIR / 'scenario_6'
1✔
15

16

17
@pytest.mark.skip(reason='The lats/lons in scenario_6 are all offshore and there is no DEM')
1✔
18
@pytest.mark.parametrize('wm', 'ERA5'.split())
1✔
19
def test_cube_intersect(tmp_path: Path, wm: str) -> None:
1✔
20
    """Test the intersection of lat/lon files with the DEM (model height levels?)."""
NEW
21
    outdir = tmp_path / 'output'
×
22
    ## make the lat lon grid
23
    # S, N, W, E = 33.5, 34, -118.0, -117.5
NEW
24
    date = 20200130
×
NEW
25
    time = '13:52:45'
×
26
    # f_lat, f_lon = makeLatLonGrid([S, N, W, E], 'LA', SCENARIO_DIR, 0.25)
27

28
    ## make the run config file
NEW
29
    grp = {
×
30
        'date_group': {'date_start': date},
31
        'time_group': {'time': time, 'interpolate_time': 'none'},
32
        'weather_model': wm,
33
        'aoi_group': {
34
            'lat_file': str(SCENARIO_DIR / 'lat.rdr'),
35
            'lon_file': str(SCENARIO_DIR / 'lon.rdr'),
36
        },
37
        'runtime_group': {
38
            'output_directory': outdir,
39
            'weather_model_directory': WM_DIR,
40
        },
41
        'verbose': False,
42
    }
43

44
    ## generate the default run config file and overwrite it with new parms
NEW
45
    cfg = write_yaml(grp, tmp_path / 'temp.yaml')
×
46

47
    ## run raider and intersect
NEW
48
    calcDelays([str(cfg)])
×
49

50
    ## hard code what it should be and check it matches
NEW
51
    gold = {'ERA5': 2.2787, 'GMAO': np.nan, 'HRRR': np.nan}
×
52

NEW
53
    path_delays = outdir / f'{wm}_hydro_{date}T{time.replace(":", "")}_ztd.tiff'
×
NEW
54
    latf = SCENARIO_DIR / 'lat.rdr'
×
NEW
55
    lonf = SCENARIO_DIR / 'lon.rdr'
×
56

NEW
57
    hyd = rasterio.open(path_delays).read(1)
×
NEW
58
    lats = rasterio.open(latf).read(1)
×
NEW
59
    lons = rasterio.open(lonf).read(1)
×
NEW
60
    hyd = griddata(
×
61
        np.stack([lons.flatten(), lats.flatten()], axis=-1),
62
        hyd.flatten(),
63
        (-100.6, 16.15),
64
        method='nearest',
65
    )
66

NEW
67
    np.testing.assert_almost_equal(hyd, gold[wm], decimal=4)
×
68

69

70
@pytest.mark.parametrize('wm', 'ERA5'.split())
1✔
71
def test_gnss_intersect(tmp_path: Path, wm: str) -> None:
1✔
72
    gnss_file = SCENARIO_DIR / 'stations.csv'
1✔
73
    outdir = tmp_path / 'output'
1✔
74

75
    id = 'TORP'
1✔
76

77
    date = 20200130
1✔
78
    time = '13:52:45'
1✔
79

80
    ## make the run config file
81
    grp = {
1✔
82
        'date_group': {'date_start': date},
83
        'time_group': {'time': time, 'interpolate_time': 'none'},
84
        'weather_model': wm,
85
        'aoi_group': {'station_file': str(gnss_file)},
86
        'runtime_group': {
87
            'output_directory': outdir,
88
            'weather_model_directory': WM_DIR,
89
        },
90
        'verbose': False,
91
    }
92

93
    ## generate the default run config file and overwrite it with new parms
94
    cfg = write_yaml(grp, tmp_path / 'temp.yaml')
1✔
95

96
    ## run raider and intersect
97
    calcDelays([str(cfg)])
1✔
98

99
    gold = {'ERA5': 2.34514, 'GMAO': np.nan, 'HRRR': np.nan}
1✔
100
    df = pd.read_csv(outdir / f'{wm}_Delay_{date}T{time.replace(":", "")}_ztd.csv')
1✔
101
    td = df['totalDelay'][df['ID'] == id].values
1✔
102

103
    # test for equality with golden data
104
    np.testing.assert_almost_equal(td.item(), gold[wm], decimal=4)
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc