Skip to content

Commit 5a774d6

Browse files
committed
add tests for matchups using formula
1 parent 2a4aea8 commit 5a774d6

4 files changed

Lines changed: 312 additions & 0 deletions

File tree

83 KB
Binary file not shown.

data/chl/obs_csv/chl_model_sum.csv

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
lon,lat,observation,year,month,day
2+
-9.88899,50.0005,0.046749987,2000,1,1
3+
-9.77788,50.0005,0.044747416,2000,1,1
4+
-9.88899,50.06717,0.042371966,2000,1,1
5+
-9.77788,50.06717,0.04151449,2000,1,1
6+
-9.88899,50.13384,0.043376923,2000,1,1
7+
-9.77788,50.13384,0.04473716,2000,1,1
8+
-9.88899,50.20051,0.04363613,2000,1,1
9+
-9.77788,50.20051,0.042882804,2000,1,1
10+
-9.88899,50.0005,0.04661999,2000,1,2
11+
-9.77788,50.0005,0.044164333,2000,1,2
12+
-9.88899,50.06717,0.04172278,2000,1,2
13+
-9.77788,50.06717,0.04014495,2000,1,2
14+
-9.88899,50.13384,0.041706443,2000,1,2
15+
-9.77788,50.13384,0.042641938,2000,1,2
16+
-9.88899,50.20051,0.04259894,2000,1,2
17+
-9.77788,50.20051,0.04167351,2000,1,2
18+
-9.88899,50.0005,0.043649297,2000,1,3
19+
-9.77788,50.0005,0.040971104,2000,1,3
20+
-9.88899,50.06717,0.03948892,2000,1,3
21+
-9.77788,50.06717,0.037623513,2000,1,3
22+
-9.88899,50.13384,0.039306957,2000,1,3
23+
-9.77788,50.13384,0.03979631,2000,1,3
24+
-9.88899,50.20051,0.04045161,2000,1,3
25+
-9.77788,50.20051,0.039134275,2000,1,3
26+
-9.88899,50.0005,0.040540542,2000,1,4
27+
-9.77788,50.0005,0.03761299,2000,1,4
28+
-9.88899,50.06717,0.037303533,2000,1,4
29+
-9.77788,50.06717,0.03539228,2000,1,4
30+
-9.88899,50.13384,0.037238494,2000,1,4
31+
-9.77788,50.13384,0.037528794,2000,1,4
32+
-9.88899,50.20051,0.03853065,2000,1,4
33+
-9.77788,50.20051,0.036989532,2000,1,4
34+
-9.88899,50.0005,0.039241813,2000,1,5
35+
-9.77788,50.0005,0.03613788,2000,1,5
36+
-9.88899,50.06717,0.036364194,2000,1,5
37+
-9.77788,50.06717,0.03391206,2000,1,5
38+
-9.88899,50.13384,0.03590578,2000,1,5
39+
-9.77788,50.13384,0.03567813,2000,1,5
40+
-9.88899,50.20051,0.037459753,2000,1,5
41+
-9.77788,50.20051,0.035663165,2000,1,5
42+
-9.88899,50.0005,0.03833156,2000,1,6
43+
-9.77788,50.0005,0.035012126,2000,1,6
44+
-9.88899,50.06717,0.035864897,2000,1,6
45+
-9.77788,50.06717,0.032875925,2000,1,6
46+
-9.88899,50.13384,0.03504757,2000,1,6
47+
-9.77788,50.13384,0.034218732,2000,1,6
48+
-9.88899,50.20051,0.036716774,2000,1,6
49+
-9.77788,50.20051,0.03469436,2000,1,6
50+
-9.88899,50.0005,0.037380356,2000,1,7
51+
-9.77788,50.0005,0.0339501,2000,1,7
52+
-9.88899,50.06717,0.035267163,2000,1,7
53+
-9.77788,50.06717,0.03169151,2000,1,7
54+
-9.88899,50.13384,0.034058787,2000,1,7
55+
-9.77788,50.13384,0.032392446,2000,1,7
56+
-9.88899,50.20051,0.03563703,2000,1,7
57+
-9.77788,50.20051,0.033384673,2000,1,7
58+
-9.88899,50.0005,0.0356784,2000,1,8
59+
-9.77788,50.0005,0.03202915,2000,1,8
60+
-9.88899,50.06717,0.034032658,2000,1,8
61+
-9.77788,50.06717,0.030377483,2000,1,8
62+
-9.88899,50.13384,0.03301529,2000,1,8
63+
-9.77788,50.13384,0.03105375,2000,1,8
64+
-9.88899,50.20051,0.03448561,2000,1,8
65+
-9.77788,50.20051,0.032104086,2000,1,8
66+
-9.88899,50.0005,0.03420616,2000,1,9
67+
-9.77788,50.0005,0.03050856,2000,1,9
68+
-9.88899,50.06717,0.032831624,2000,1,9
69+
-9.77788,50.06717,0.029254336,2000,1,9
70+
-9.88899,50.13384,0.03190738,2000,1,9
71+
-9.77788,50.13384,0.029960254,2000,1,9
72+
-9.88899,50.20051,0.03324737,2000,1,9
73+
-9.77788,50.20051,0.031006163,2000,1,9
74+
-9.88899,50.0005,0.033172,2000,1,10
75+
-9.77788,50.0005,0.029478062,2000,1,10
76+
-9.88899,50.06717,0.032025963,2000,1,10
77+
-9.77788,50.06717,0.028326022,2000,1,10
78+
-9.88899,50.13384,0.031210948,2000,1,10
79+
-9.77788,50.13384,0.028875263,2000,1,10
80+
-9.88899,50.20051,0.032425266,2000,1,10
81+
-9.77788,50.20051,0.029987501,2000,1,10
82+
-9.88899,50.0005,0.032093838,2000,1,11
83+
-9.77788,50.0005,0.028300567,2000,1,11
84+
-9.88899,50.06717,0.031242661,2000,1,11
85+
-9.77788,50.06717,0.02725218,2000,1,11
86+
-9.88899,50.13384,0.030689405,2000,1,11
87+
-9.77788,50.13384,0.02768278,2000,1,11
88+
-9.88899,50.20051,0.031871356,2000,1,11
89+
-9.77788,50.20051,0.028938696,2000,1,11
90+
-9.88899,50.0005,0.030783635,2000,1,12
91+
-9.77788,50.0005,0.02699982,2000,1,12
92+
-9.88899,50.06717,0.030453283,2000,1,12
93+
-9.77788,50.06717,0.026306663,2000,1,12
94+
-9.88899,50.13384,0.030271417,2000,1,12
95+
-9.77788,50.13384,0.026804209,2000,1,12
96+
-9.88899,50.20051,0.031415336,2000,1,12
97+
-9.77788,50.20051,0.028250223,2000,1,12
98+
-9.88899,50.0005,0.028036779,2000,1,13
99+
-9.77788,50.0005,0.024647053,2000,1,13
100+
-9.88899,50.06717,0.028412942,2000,1,13
101+
-9.77788,50.06717,0.02465749,2000,1,13
102+
-9.88899,50.13384,0.028544284,2000,1,13
103+
-9.77788,50.13384,0.025401397,2000,1,13
104+
-9.88899,50.20051,0.029634053,2000,1,13
105+
-9.77788,50.20051,0.026643684,2000,1,13
106+
-9.88899,50.0005,0.025722437,2000,1,14
107+
-9.77788,50.0005,0.023314307,2000,1,14
108+
-9.88899,50.06717,0.026501605,2000,1,14
109+
-9.77788,50.06717,0.023542443,2000,1,14
110+
-9.88899,50.13384,0.026877902,2000,1,14
111+
-9.77788,50.13384,0.024446275,2000,1,14
112+
-9.88899,50.20051,0.027977958,2000,1,14
113+
-9.77788,50.20051,0.025400069,2000,1,14
114+
-9.88899,50.0005,0.02377113,2000,1,15
115+
-9.77788,50.0005,0.023053505,2000,1,15
116+
-9.88899,50.06717,0.023853136,2000,1,15
117+
-9.77788,50.06717,0.023337768,2000,1,15
118+
-9.88899,50.13384,0.024555076,2000,1,15
119+
-9.77788,50.13384,0.023685584,2000,1,15
120+
-9.88899,50.20051,0.02552869,2000,1,15
121+
-9.77788,50.20051,0.024355404,2000,1,15
122+
-9.88899,50.0005,0.023236519,2000,1,16
123+
-9.77788,50.0005,0.023216814,2000,1,16
124+
-9.88899,50.06717,0.022426946,2000,1,16
125+
-9.77788,50.06717,0.023088692,2000,1,16
126+
-9.88899,50.13384,0.022732686,2000,1,16
127+
-9.77788,50.13384,0.023328708,2000,1,16
128+
-9.88899,50.20051,0.023786511,2000,1,16
129+
-9.77788,50.20051,0.02374949,2000,1,16
130+
-9.88899,50.0005,0.023680335,2000,1,17
131+
-9.77788,50.0005,0.023775155,2000,1,17
132+
-9.88899,50.06717,0.022077827,2000,1,17
133+
-9.77788,50.06717,0.022562841,2000,1,17
134+
-9.88899,50.13384,0.021644786,2000,1,17
135+
-9.77788,50.13384,0.022576442,2000,1,17
136+
-9.88899,50.20051,0.022579184,2000,1,17
137+
-9.77788,50.20051,0.022955619,2000,1,17
138+
-9.88899,50.0005,0.02393135,2000,1,18
139+
-9.77788,50.0005,0.024091406,2000,1,18
140+
-9.88899,50.06717,0.02195329,2000,1,18
141+
-9.77788,50.06717,0.022069294,2000,1,18
142+
-9.88899,50.13384,0.020968175,2000,1,18
143+
-9.77788,50.13384,0.02173297,2000,1,18
144+
-9.88899,50.20051,0.021497732,2000,1,18
145+
-9.77788,50.20051,0.021897942,2000,1,18
146+
-9.88899,50.0005,0.023753677,2000,1,19
147+
-9.77788,50.0005,0.024042599,2000,1,19
148+
-9.88899,50.06717,0.021653304,2000,1,19
149+
-9.77788,50.06717,0.021622144,2000,1,19
150+
-9.88899,50.13384,0.020427333,2000,1,19
151+
-9.77788,50.13384,0.02101457,2000,1,19
152+
-9.88899,50.20051,0.020451916,2000,1,19
153+
-9.77788,50.20051,0.020971848,2000,1,19
154+
-9.88899,50.0005,0.023014186,2000,1,20
155+
-9.77788,50.0005,0.023345111,2000,1,20
156+
-9.88899,50.06717,0.021046303,2000,1,20
157+
-9.77788,50.06717,0.020951623,2000,1,20
158+
-9.88899,50.13384,0.019924337,2000,1,20
159+
-9.77788,50.13384,0.020338746,2000,1,20
160+
-9.88899,50.20051,0.019730061,2000,1,20
161+
-9.77788,50.20051,0.020227587,2000,1,20
162+
-9.88899,50.0005,0.022046754,2000,1,21
163+
-9.77788,50.0005,0.022601277,2000,1,21
164+
-9.88899,50.06717,0.02019561,2000,1,21
165+
-9.77788,50.06717,0.020312436,2000,1,21
166+
-9.88899,50.13384,0.019222394,2000,1,21
167+
-9.77788,50.13384,0.019775981,2000,1,21
168+
-9.88899,50.20051,0.01896338,2000,1,21
169+
-9.77788,50.20051,0.019691879,2000,1,21
170+
-9.88899,50.0005,0.021088613,2000,1,22
171+
-9.77788,50.0005,0.021854576,2000,1,22
172+
-9.88899,50.06717,0.019402502,2000,1,22
173+
-9.77788,50.06717,0.019753741,2000,1,22
174+
-9.88899,50.13384,0.01860839,2000,1,22
175+
-9.77788,50.13384,0.019337274,2000,1,22
176+
-9.88899,50.20051,0.018396242,2000,1,22
177+
-9.77788,50.20051,0.019358724,2000,1,22
178+
-9.88899,50.0005,0.02019506,2000,1,23
179+
-9.77788,50.0005,0.021174274,2000,1,23
180+
-9.88899,50.06717,0.018639326,2000,1,23
181+
-9.77788,50.06717,0.01926465,2000,1,23
182+
-9.88899,50.13384,0.01800709,2000,1,23
183+
-9.77788,50.13384,0.018931206,2000,1,23
184+
-9.88899,50.20051,0.017869234,2000,1,23
185+
-9.77788,50.20051,0.019020092,2000,1,23
186+
-9.88899,50.0005,0.019637639,2000,1,24
187+
-9.77788,50.0005,0.020786688,2000,1,24
188+
-9.88899,50.06717,0.018126776,2000,1,24
189+
-9.77788,50.06717,0.018925728,2000,1,24
190+
-9.88899,50.13384,0.017553002,2000,1,24
191+
-9.77788,50.13384,0.018579347,2000,1,24
192+
-9.88899,50.20051,0.017372979,2000,1,24
193+
-9.77788,50.20051,0.018680068,2000,1,24
194+
-9.88899,50.0005,0.019408403,2000,1,25
195+
-9.77788,50.0005,0.02078402,2000,1,25
196+
-9.88899,50.06717,0.01776721,2000,1,25
197+
-9.77788,50.06717,0.018760217,2000,1,25
198+
-9.88899,50.13384,0.017126951,2000,1,25
199+
-9.77788,50.13384,0.018256892,2000,1,25
200+
-9.88899,50.20051,0.016842172,2000,1,25
201+
-9.77788,50.20051,0.018327912,2000,1,25
202+
-9.88899,50.0005,0.019696277,2000,1,26
203+
-9.77788,50.0005,0.021252368,2000,1,26
204+
-9.88899,50.06717,0.017786657,2000,1,26
205+
-9.77788,50.06717,0.018882323,2000,1,26
206+
-9.88899,50.13384,0.016915068,2000,1,26
207+
-9.77788,50.13384,0.017947271,2000,1,26
208+
-9.88899,50.20051,0.016414499,2000,1,26
209+
-9.77788,50.20051,0.017837932,2000,1,26
210+
-9.88899,50.0005,0.020378605,2000,1,27
211+
-9.77788,50.0005,0.022053005,2000,1,27
212+
-9.88899,50.06717,0.018230816,2000,1,27
213+
-9.77788,50.06717,0.019394709,2000,1,27
214+
-9.88899,50.13384,0.017091408,2000,1,27
215+
-9.77788,50.13384,0.01789114,2000,1,27
216+
-9.88899,50.20051,0.016259236,2000,1,27
217+
-9.77788,50.20051,0.017393358,2000,1,27
218+
-9.88899,50.0005,0.020153787,2000,1,28
219+
-9.77788,50.0005,0.021804113,2000,1,28
220+
-9.88899,50.06717,0.018064262,2000,1,28
221+
-9.77788,50.06717,0.0189905,2000,1,28
222+
-9.88899,50.13384,0.017041715,2000,1,28
223+
-9.77788,50.13384,0.01725531,2000,1,28
224+
-9.88899,50.20051,0.016162915,2000,1,28
225+
-9.77788,50.20051,0.016425302,2000,1,28
226+
-9.88899,50.0005,0.019067083,2000,1,29
227+
-9.77788,50.0005,0.020311395,2000,1,29
228+
-9.88899,50.06717,0.01723939,2000,1,29
229+
-9.77788,50.06717,0.017500281,2000,1,29
230+
-9.88899,50.13384,0.016726695,2000,1,29
231+
-9.77788,50.13384,0.01616898,2000,1,29
232+
-9.88899,50.20051,0.01615061,2000,1,29
233+
-9.77788,50.20051,0.015560067,2000,1,29
234+
-9.88899,50.0005,0.018814089,2000,1,30
235+
-9.77788,50.0005,0.019771926,2000,1,30
236+
-9.88899,50.06717,0.017058156,2000,1,30
237+
-9.77788,50.06717,0.016989289,2000,1,30
238+
-9.88899,50.13384,0.016791737,2000,1,30
239+
-9.77788,50.13384,0.015851717,2000,1,30
240+
-9.88899,50.20051,0.016337512,2000,1,30
241+
-9.77788,50.20051,0.015344841,2000,1,30
242+
-9.88899,50.0005,0.019560834,2000,1,31
243+
-9.77788,50.0005,0.020436037,2000,1,31
244+
-9.88899,50.06717,0.017642913,2000,1,31
245+
-9.77788,50.06717,0.017577363,2000,1,31
246+
-9.88899,50.13384,0.017534187,2000,1,31
247+
-9.77788,50.13384,0.01619311,2000,1,31
248+
-9.88899,50.20051,0.01748611,2000,1,31
249+
-9.77788,50.20051,0.015498722,2000,1,31

data/chl/simulation/chl_model.nc

253 KB
Binary file not shown.

tests/test_matchup_formula.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
2+
import oceanval
3+
import nctoolkit as nc
4+
import pickle
5+
6+
import numpy as np
7+
import pandas as pd
8+
import glob
9+
import os
10+
import shutil
11+
12+
13+
class TestFinal:
14+
15+
def test_gridded(self):
16+
17+
oceanval.definitions.reset()
18+
19+
oceanval.add_gridded_comparison(
20+
name = "chlorophyll",
21+
obs_path="data/chl/model_as_obs",
22+
source = "foo",
23+
model_variable = "P1_Chl+P2_Chl+P3_Chl+P4_Chl",
24+
obs_variable = "total",
25+
climatology = False,
26+
start = 2000,
27+
end = 2000
28+
)
29+
30+
oceanval.add_point_comparison(
31+
name = "chlorophyll",
32+
obs_path="data/chl/obs_csv",
33+
source = "foo",
34+
model_variable = "P1_Chl+P2_Chl+P3_Chl+P4_Chl",
35+
start = 2000,
36+
end = 2000
37+
)
38+
39+
oceanval.matchup(
40+
"data/chl/simulation",
41+
start = 2000,
42+
end = 2000,
43+
n_dirs_down = 0,
44+
ask = False
45+
)
46+
47+
ff = "oceanval_matchups/gridded/chlorophyll/foo_chlorophyll_surface.nc"
48+
assert os.path.exists(ff)
49+
50+
ds = nc.open_data(ff)
51+
df = ds.to_dataframe()
52+
# max diff
53+
diff = np.abs(df['model'] - df['observation'])
54+
max_diff = diff.max()
55+
assert max_diff < 1e-6
56+
57+
ff = "oceanval_matchups/point/surface/chlorophyll/foo/foo_surface_chlorophyll.csv"
58+
df = pd.read_csv(ff)
59+
diff = np.abs(df['model'] - df['observation'])
60+
max_diff = diff.max()
61+
assert max_diff < 1e-6
62+
63+

0 commit comments

Comments
 (0)