Skip to content

Commit 174f29d

Browse files
committed
update tests
1 parent b795ebe commit 174f29d

File tree

10 files changed

+89
-5
lines changed

10 files changed

+89
-5
lines changed

tests/expedition/expedition_dir/input_data/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
!ship_uv.nc
88
!drifter_t.nc
99
!drifter_uv.nc
10+
!ctd_bgc_*.nc
51 Bytes
Binary file not shown.
22.8 KB
Binary file not shown.
51 Bytes
Binary file not shown.
22.7 KB
Binary file not shown.
22.8 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

tests/instruments/test_ctd_bgc.py

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,24 @@ def test_simulate_ctd_bgcs(tmpdir) -> None:
4545
"surface": {
4646
"o2": 9,
4747
"chl": 10,
48+
"no3": 13,
49+
"po4": 14,
50+
"ph": 8.1,
51+
"phyc": 15,
52+
"zooc": 16,
53+
"nppv": 17,
4854
"lat": ctd_bgcs[0].spacetime.location.lat,
4955
"lon": ctd_bgcs[0].spacetime.location.lon,
5056
},
5157
"maxdepth": {
5258
"o2": 11,
5359
"chl": 12,
60+
"no3": 18,
61+
"po4": 19,
62+
"ph": 8.0,
63+
"phyc": 20,
64+
"zooc": 21,
65+
"nppv": 22,
5466
"lat": ctd_bgcs[0].spacetime.location.lat,
5567
"lon": ctd_bgcs[0].spacetime.location.lon,
5668
},
@@ -59,12 +71,24 @@ def test_simulate_ctd_bgcs(tmpdir) -> None:
5971
"surface": {
6072
"o2": 9,
6173
"chl": 10,
74+
"no3": 13,
75+
"po4": 14,
76+
"ph": 8.1,
77+
"phyc": 15,
78+
"zooc": 16,
79+
"nppv": 17,
6280
"lat": ctd_bgcs[1].spacetime.location.lat,
6381
"lon": ctd_bgcs[1].spacetime.location.lon,
6482
},
6583
"maxdepth": {
6684
"o2": 11,
6785
"chl": 12,
86+
"no3": 18,
87+
"po4": 19,
88+
"ph": 8.0,
89+
"phyc": 20,
90+
"zooc": 21,
91+
"nppv": 22,
6892
"lat": ctd_bgcs[1].spacetime.location.lat,
6993
"lon": ctd_bgcs[1].spacetime.location.lon,
7094
},
@@ -75,9 +99,16 @@ def test_simulate_ctd_bgcs(tmpdir) -> None:
7599
# indices are time, depth, latitude, longitude
76100
u = np.zeros((2, 2, 2, 2))
77101
v = np.zeros((2, 2, 2, 2))
78-
o2 = np.zeros((2, 2, 2, 2)) # o2 field
79-
chl = np.zeros((2, 2, 2, 2)) # chl field
80-
102+
o2 = np.zeros((2, 2, 2, 2))
103+
chl = np.zeros((2, 2, 2, 2))
104+
no3 = np.zeros((2, 2, 2, 2))
105+
po4 = np.zeros((2, 2, 2, 2))
106+
ph = np.zeros((2, 2, 2, 2))
107+
phytoplankton = np.zeros((2, 2, 2, 2))
108+
zooplankton = np.zeros((2, 2, 2, 2))
109+
primary_production = np.zeros((2, 2, 2, 2))
110+
111+
# Fill fields for both CTDs at surface and maxdepth
81112
o2[:, 1, 0, 1] = ctd_bgc_exp[0]["surface"]["o2"]
82113
o2[:, 0, 0, 1] = ctd_bgc_exp[0]["maxdepth"]["o2"]
83114
o2[:, 1, 1, 0] = ctd_bgc_exp[1]["surface"]["o2"]
@@ -88,8 +119,49 @@ def test_simulate_ctd_bgcs(tmpdir) -> None:
88119
chl[:, 1, 1, 0] = ctd_bgc_exp[1]["surface"]["chl"]
89120
chl[:, 0, 1, 0] = ctd_bgc_exp[1]["maxdepth"]["chl"]
90121

122+
no3[:, 1, 0, 1] = ctd_bgc_exp[0]["surface"]["no3"]
123+
no3[:, 0, 0, 1] = ctd_bgc_exp[0]["maxdepth"]["no3"]
124+
no3[:, 1, 1, 0] = ctd_bgc_exp[1]["surface"]["no3"]
125+
no3[:, 0, 1, 0] = ctd_bgc_exp[1]["maxdepth"]["no3"]
126+
127+
po4[:, 1, 0, 1] = ctd_bgc_exp[0]["surface"]["po4"]
128+
po4[:, 0, 0, 1] = ctd_bgc_exp[0]["maxdepth"]["po4"]
129+
po4[:, 1, 1, 0] = ctd_bgc_exp[1]["surface"]["po4"]
130+
po4[:, 0, 1, 0] = ctd_bgc_exp[1]["maxdepth"]["po4"]
131+
132+
ph[:, 1, 0, 1] = ctd_bgc_exp[0]["surface"]["ph"]
133+
ph[:, 0, 0, 1] = ctd_bgc_exp[0]["maxdepth"]["ph"]
134+
ph[:, 1, 1, 0] = ctd_bgc_exp[1]["surface"]["ph"]
135+
ph[:, 0, 1, 0] = ctd_bgc_exp[1]["maxdepth"]["ph"]
136+
137+
phytoplankton[:, 1, 0, 1] = ctd_bgc_exp[0]["surface"]["phyc"]
138+
phytoplankton[:, 0, 0, 1] = ctd_bgc_exp[0]["maxdepth"]["phyc"]
139+
phytoplankton[:, 1, 1, 0] = ctd_bgc_exp[1]["surface"]["phyc"]
140+
phytoplankton[:, 0, 1, 0] = ctd_bgc_exp[1]["maxdepth"]["phyc"]
141+
142+
zooplankton[:, 1, 0, 1] = ctd_bgc_exp[0]["surface"]["zooc"]
143+
zooplankton[:, 0, 0, 1] = ctd_bgc_exp[0]["maxdepth"]["zooc"]
144+
zooplankton[:, 1, 1, 0] = ctd_bgc_exp[1]["surface"]["zooc"]
145+
zooplankton[:, 0, 1, 0] = ctd_bgc_exp[1]["maxdepth"]["zooc"]
146+
147+
primary_production[:, 1, 0, 1] = ctd_bgc_exp[0]["surface"]["nppv"]
148+
primary_production[:, 0, 0, 1] = ctd_bgc_exp[0]["maxdepth"]["nppv"]
149+
primary_production[:, 1, 1, 0] = ctd_bgc_exp[1]["surface"]["nppv"]
150+
primary_production[:, 0, 1, 0] = ctd_bgc_exp[1]["maxdepth"]["nppv"]
151+
91152
fieldset = FieldSet.from_data(
92-
{"V": v, "U": u, "o2": o2, "chl": chl},
153+
{
154+
"V": v,
155+
"U": u,
156+
"o2": o2,
157+
"chl": chl,
158+
"no3": no3,
159+
"po4": po4,
160+
"ph": ph,
161+
"phytoplankton": phytoplankton,
162+
"zooplankton": zooplankton,
163+
"primary_production": primary_production,
164+
},
93165
{
94166
"time": [
95167
np.datetime64(base_time + datetime.timedelta(hours=0)),
@@ -129,7 +201,18 @@ def test_simulate_ctd_bgcs(tmpdir) -> None:
129201
(obs_maxdepth, "maxdepth"),
130202
]:
131203
exp = exp_bothloc[loc]
132-
for var in ["o2", "chl", "lat", "lon"]:
204+
for var in [
205+
"o2",
206+
"chl",
207+
"no3",
208+
"po4",
209+
"ph",
210+
"phyc",
211+
"zooc",
212+
"nppv",
213+
"lat",
214+
"lon",
215+
]:
133216
obs_value = obs[var].values.item()
134217
exp_value = exp[var]
135218
assert np.isclose(obs_value, exp_value), (

0 commit comments

Comments
 (0)