Skip to content

Commit 8cc892e

Browse files
committed
add test of use of cache
1 parent 487f52d commit 8cc892e

1 file changed

Lines changed: 35 additions & 6 deletions

File tree

tests/test_matchup_formula.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,51 @@ def test_gridded(self):
1616

1717
oceanval.definitions.reset()
1818

19-
oceanval.add_gridded_comparison(
19+
20+
oceanval.add_point_comparison(
2021
name = "chlorophyll",
21-
obs_path="data/chl/model_as_obs",
22+
obs_path="data/chl/obs_csv",
2223
source = "foo",
2324
model_variable = "P1_Chl+P2_Chl+P3_Chl+P4_Chl",
24-
obs_variable = "total",
25-
climatology = False,
2625
start = 2000,
2726
end = 2000
2827
)
2928

30-
oceanval.add_point_comparison(
29+
oceanval.matchup(
30+
"data/chl/simulation",
31+
start = 2000,
32+
end = 2000,
33+
n_dirs_down = 0,
34+
ask = False,
35+
cache = True,
36+
cores = 1,
37+
require = "model",
38+
exclude = "bad"
39+
)
40+
41+
ff = "oceanval_matchups/point/surface/chlorophyll/foo/foo_surface_chlorophyll.csv"
42+
df = pd.read_csv(ff)
43+
diff = np.abs(df['model'] - df['observation'])
44+
max_diff = diff.max()
45+
assert max_diff < 1e-6
46+
47+
for ff in glob.glob(".cache_oceanval/output/*.pkl"):
48+
with open(ff, "rb") as f:
49+
df = pickle.load(f)
50+
51+
columns = ["lon", "lat", "year", "month", "day", "total"]
52+
for col in columns:
53+
assert col in df.columns
54+
assert len(df) == 248
55+
56+
57+
oceanval.add_gridded_comparison(
3158
name = "chlorophyll",
32-
obs_path="data/chl/obs_csv",
59+
obs_path="data/chl/model_as_obs",
3360
source = "foo",
3461
model_variable = "P1_Chl+P2_Chl+P3_Chl+P4_Chl",
62+
obs_variable = "total",
63+
climatology = False,
3564
start = 2000,
3665
end = 2000
3766
)

0 commit comments

Comments
 (0)