roms-tools 1.0.1__py3-none-any.whl → 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- roms_tools/__init__.py +0 -1
- roms_tools/_version.py +1 -1
- roms_tools/setup/boundary_forcing.py +58 -148
- roms_tools/setup/datasets.py +22 -2
- roms_tools/setup/grid.py +478 -227
- roms_tools/setup/initial_conditions.py +89 -58
- roms_tools/setup/mixins.py +60 -59
- roms_tools/setup/plot.py +5 -47
- roms_tools/setup/surface_forcing.py +19 -5
- roms_tools/setup/tides.py +77 -69
- roms_tools/setup/topography.py +44 -13
- roms_tools/setup/vertical_coordinate.py +5 -377
- roms_tools/tests/test_boundary_forcing.py +208 -256
- roms_tools/tests/test_grid.py +188 -11
- roms_tools/tests/test_initial_conditions.py +87 -117
- roms_tools/tests/test_surface_forcing.py +25 -7
- roms_tools/tests/test_topography.py +8 -6
- roms_tools/tests/test_vertical_coordinate.py +167 -222
- {roms_tools-1.0.1.dist-info → roms_tools-1.2.0.dist-info}/METADATA +2 -3
- roms_tools-1.2.0.dist-info/RECORD +31 -0
- {roms_tools-1.0.1.dist-info → roms_tools-1.2.0.dist-info}/WHEEL +1 -1
- roms_tools-1.0.1.dist-info/RECORD +0 -31
- {roms_tools-1.0.1.dist-info → roms_tools-1.2.0.dist-info}/LICENSE +0 -0
- {roms_tools-1.0.1.dist-info → roms_tools-1.2.0.dist-info}/top_level.txt +0 -0
roms_tools/tests/test_grid.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
import numpy as np
|
|
3
3
|
import numpy.testing as npt
|
|
4
|
+
import xarray as xr
|
|
4
5
|
from roms_tools import Grid
|
|
5
6
|
import os
|
|
6
7
|
import tempfile
|
|
@@ -8,9 +9,44 @@ import importlib.metadata
|
|
|
8
9
|
import textwrap
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
@pytest.fixture
|
|
13
|
+
def simple_grid():
|
|
14
|
+
|
|
12
15
|
grid = Grid(nx=1, ny=1, size_x=100, size_y=100, center_lon=-20, center_lat=0, rot=0)
|
|
13
16
|
|
|
17
|
+
return grid
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_grid_creation(simple_grid):
|
|
21
|
+
|
|
22
|
+
assert simple_grid.nx == 1
|
|
23
|
+
assert simple_grid.ny == 1
|
|
24
|
+
assert simple_grid.size_x == 100
|
|
25
|
+
assert simple_grid.size_y == 100
|
|
26
|
+
assert simple_grid.center_lon == -20
|
|
27
|
+
assert simple_grid.center_lat == 0
|
|
28
|
+
assert simple_grid.rot == 0
|
|
29
|
+
assert isinstance(simple_grid.ds, xr.Dataset)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_plot_save_methods(simple_grid, tmp_path):
|
|
33
|
+
|
|
34
|
+
simple_grid.plot(bathymetry=True)
|
|
35
|
+
filepath = tmp_path / "grid.nc"
|
|
36
|
+
simple_grid.save(filepath)
|
|
37
|
+
assert filepath.exists()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.fixture
|
|
41
|
+
def simple_grid_that_straddles_dateline():
|
|
42
|
+
|
|
43
|
+
grid = Grid(nx=1, ny=1, size_x=100, size_y=100, center_lon=0, center_lat=0, rot=20)
|
|
44
|
+
|
|
45
|
+
return grid
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_simple_regression(simple_grid):
|
|
49
|
+
|
|
14
50
|
expected_lat = np.array(
|
|
15
51
|
[
|
|
16
52
|
[-8.99249453e-01, -8.99249453e-01, -8.99249453e-01],
|
|
@@ -26,9 +62,158 @@ def test_simple_regression():
|
|
|
26
62
|
]
|
|
27
63
|
)
|
|
28
64
|
|
|
65
|
+
expected_lat_u = np.array(
|
|
66
|
+
[
|
|
67
|
+
[-8.99249453e-01, -8.99249453e-01],
|
|
68
|
+
[-2.39610306e-15, -2.28602368e-15],
|
|
69
|
+
[8.99249453e-01, 8.99249453e-01],
|
|
70
|
+
]
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
expected_lon_u = np.array(
|
|
74
|
+
[
|
|
75
|
+
[339.55036143, 340.44963857],
|
|
76
|
+
[339.55036143, 340.44963857],
|
|
77
|
+
[339.55036143, 340.44963857],
|
|
78
|
+
]
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
expected_lat_v = np.array(
|
|
82
|
+
[[-0.44962473, -0.44962473, -0.44962473], [0.44962473, 0.44962473, 0.44962473]]
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
expected_lon_v = np.array(
|
|
86
|
+
[[339.10072286, 340.0, 340.89927714], [339.10072286, 340.0, 340.89927714]]
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
expected_lat_coarse = np.array(
|
|
90
|
+
[[-1.34887418, -1.34887418], [1.34887418, 1.34887418]]
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
expected_lon_coarse = np.array(
|
|
94
|
+
[[338.65108429, 341.34891571], [338.65108429, 341.34891571]]
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
expected_angle = np.array(
|
|
98
|
+
[
|
|
99
|
+
[0.00000000e00, 0.00000000e00, 0.00000000e00],
|
|
100
|
+
[-3.83707366e-17, -3.83707366e-17, -3.83707366e-17],
|
|
101
|
+
[0.00000000e00, 0.00000000e00, 0.00000000e00],
|
|
102
|
+
]
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
expected_angle_coarse = np.array(
|
|
106
|
+
[[1.91853683e-17, 1.91853683e-17], [1.91853683e-17, 1.91853683e-17]]
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# TODO: adapt tolerances according to order of magnitude of respective fields
|
|
110
|
+
npt.assert_allclose(simple_grid.ds["lat_rho"], expected_lat, atol=1e-8)
|
|
111
|
+
npt.assert_allclose(simple_grid.ds["lon_rho"], expected_lon, atol=1e-8)
|
|
112
|
+
npt.assert_allclose(simple_grid.ds["lat_u"], expected_lat_u, atol=1e-8)
|
|
113
|
+
npt.assert_allclose(simple_grid.ds["lon_u"], expected_lon_u, atol=1e-8)
|
|
114
|
+
npt.assert_allclose(simple_grid.ds["lat_v"], expected_lat_v, atol=1e-8)
|
|
115
|
+
npt.assert_allclose(simple_grid.ds["lon_v"], expected_lon_v, atol=1e-8)
|
|
116
|
+
npt.assert_allclose(simple_grid.ds["lat_coarse"], expected_lat_coarse, atol=1e-8)
|
|
117
|
+
npt.assert_allclose(simple_grid.ds["lon_coarse"], expected_lon_coarse, atol=1e-8)
|
|
118
|
+
npt.assert_allclose(simple_grid.ds["angle"], expected_angle, atol=1e-8)
|
|
119
|
+
npt.assert_allclose(
|
|
120
|
+
simple_grid.ds["angle_coarse"], expected_angle_coarse, atol=1e-8
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def test_simple_regression_dateline(simple_grid_that_straddles_dateline):
|
|
125
|
+
|
|
126
|
+
expected_lat = np.array(
|
|
127
|
+
[
|
|
128
|
+
[-1.15258151e00, -8.45014017e-01, -5.37470876e-01],
|
|
129
|
+
[-3.07559747e-01, -2.14815958e-15, 3.07559747e-01],
|
|
130
|
+
[5.37470876e-01, 8.45014017e-01, 1.15258151e00],
|
|
131
|
+
]
|
|
132
|
+
)
|
|
133
|
+
expected_lon = np.array(
|
|
134
|
+
[
|
|
135
|
+
[3.59462527e02, 3.07583728e-01, 1.15258257e00],
|
|
136
|
+
[3.59154948e02, 7.81866146e-16, 8.45052212e-01],
|
|
137
|
+
[3.58847417e02, 3.59692416e02, 5.37473154e-01],
|
|
138
|
+
]
|
|
139
|
+
)
|
|
140
|
+
expected_lat_u = np.array(
|
|
141
|
+
[
|
|
142
|
+
[-0.99879776, -0.69124245],
|
|
143
|
+
[-0.15377987, 0.15377987],
|
|
144
|
+
[0.69124245, 0.99879776],
|
|
145
|
+
]
|
|
146
|
+
)
|
|
147
|
+
expected_lon_u = np.array(
|
|
148
|
+
[
|
|
149
|
+
[3.59885055e02, 7.30083149e-01],
|
|
150
|
+
[3.59577474e02, 4.22526106e-01],
|
|
151
|
+
[3.59269917e02, 1.14944713e-01],
|
|
152
|
+
]
|
|
153
|
+
)
|
|
154
|
+
expected_lat_v = np.array(
|
|
155
|
+
[[-0.73007063, -0.42250701, -0.11495556], [0.11495556, 0.42250701, 0.73007063]]
|
|
156
|
+
)
|
|
157
|
+
expected_lon_v = np.array(
|
|
158
|
+
[
|
|
159
|
+
[3.59308737e02, 1.53791864e-01, 9.98817391e-01],
|
|
160
|
+
[3.59001183e02, 3.59846208e02, 6.91262683e-01],
|
|
161
|
+
]
|
|
162
|
+
)
|
|
163
|
+
expected_lat_coarse = np.array(
|
|
164
|
+
[[-1.72887807, -0.80621877], [0.80621877, 1.72887807]]
|
|
165
|
+
)
|
|
166
|
+
expected_lon_coarse = np.array(
|
|
167
|
+
[[359.19378677, 1.72883383], [358.27116617, 0.80621323]]
|
|
168
|
+
)
|
|
169
|
+
expected_angle = np.array(
|
|
170
|
+
[
|
|
171
|
+
[0.34910175, 0.34910175, 0.34910175],
|
|
172
|
+
[0.34906217, 0.34906217, 0.34906217],
|
|
173
|
+
[0.34910175, 0.34910175, 0.34910175],
|
|
174
|
+
]
|
|
175
|
+
)
|
|
176
|
+
expected_angle_coarse = np.array(
|
|
177
|
+
[[0.34912155, 0.34912155], [0.34912155, 0.34912155]]
|
|
178
|
+
)
|
|
179
|
+
|
|
29
180
|
# TODO: adapt tolerances according to order of magnitude of respective fields
|
|
30
|
-
npt.assert_allclose(
|
|
31
|
-
|
|
181
|
+
npt.assert_allclose(
|
|
182
|
+
simple_grid_that_straddles_dateline.ds["lat_rho"], expected_lat, atol=1e-8
|
|
183
|
+
)
|
|
184
|
+
npt.assert_allclose(
|
|
185
|
+
simple_grid_that_straddles_dateline.ds["lon_rho"], expected_lon, atol=1e-8
|
|
186
|
+
)
|
|
187
|
+
npt.assert_allclose(
|
|
188
|
+
simple_grid_that_straddles_dateline.ds["lat_u"], expected_lat_u, atol=1e-8
|
|
189
|
+
)
|
|
190
|
+
npt.assert_allclose(
|
|
191
|
+
simple_grid_that_straddles_dateline.ds["lon_u"], expected_lon_u, atol=1e-8
|
|
192
|
+
)
|
|
193
|
+
npt.assert_allclose(
|
|
194
|
+
simple_grid_that_straddles_dateline.ds["lat_v"], expected_lat_v, atol=1e-8
|
|
195
|
+
)
|
|
196
|
+
npt.assert_allclose(
|
|
197
|
+
simple_grid_that_straddles_dateline.ds["lon_v"], expected_lon_v, atol=1e-8
|
|
198
|
+
)
|
|
199
|
+
npt.assert_allclose(
|
|
200
|
+
simple_grid_that_straddles_dateline.ds["lat_coarse"],
|
|
201
|
+
expected_lat_coarse,
|
|
202
|
+
atol=1e-8,
|
|
203
|
+
)
|
|
204
|
+
npt.assert_allclose(
|
|
205
|
+
simple_grid_that_straddles_dateline.ds["lon_coarse"],
|
|
206
|
+
expected_lon_coarse,
|
|
207
|
+
atol=1e-8,
|
|
208
|
+
)
|
|
209
|
+
npt.assert_allclose(
|
|
210
|
+
simple_grid_that_straddles_dateline.ds["angle"], expected_angle, atol=1e-8
|
|
211
|
+
)
|
|
212
|
+
npt.assert_allclose(
|
|
213
|
+
simple_grid_that_straddles_dateline.ds["angle_coarse"],
|
|
214
|
+
expected_angle_coarse,
|
|
215
|
+
atol=1e-8,
|
|
216
|
+
)
|
|
32
217
|
|
|
33
218
|
|
|
34
219
|
def test_raise_if_domain_too_large():
|
|
@@ -85,9 +270,7 @@ def test_roundtrip_netcdf():
|
|
|
85
270
|
center_lat=0.0,
|
|
86
271
|
rot=0.0,
|
|
87
272
|
topography_source="ETOPO5",
|
|
88
|
-
smooth_factor=2,
|
|
89
273
|
hmin=5.0,
|
|
90
|
-
rmax=0.2,
|
|
91
274
|
)
|
|
92
275
|
|
|
93
276
|
# Create a temporary file
|
|
@@ -121,9 +304,7 @@ def test_roundtrip_yaml():
|
|
|
121
304
|
center_lat=0.0,
|
|
122
305
|
rot=0.0,
|
|
123
306
|
topography_source="ETOPO5",
|
|
124
|
-
smooth_factor=2,
|
|
125
307
|
hmin=5.0,
|
|
126
|
-
rmax=0.2,
|
|
127
308
|
)
|
|
128
309
|
|
|
129
310
|
# Create a temporary file
|
|
@@ -155,9 +336,7 @@ def test_from_yaml_missing_version():
|
|
|
155
336
|
center_lat: 61
|
|
156
337
|
rot: -20
|
|
157
338
|
topography_source: ETOPO5
|
|
158
|
-
smooth_factor: 8
|
|
159
339
|
hmin: 5.0
|
|
160
|
-
rmax: 0.2
|
|
161
340
|
"""
|
|
162
341
|
)
|
|
163
342
|
with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
|
|
@@ -206,9 +385,7 @@ def test_from_yaml_version_mismatch():
|
|
|
206
385
|
center_lat: 61
|
|
207
386
|
rot: -20
|
|
208
387
|
topography_source: ETOPO5
|
|
209
|
-
smooth_factor: 8
|
|
210
388
|
hmin: 5.0
|
|
211
|
-
rmax: 0.2
|
|
212
389
|
"""
|
|
213
390
|
)
|
|
214
391
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from datetime import datetime
|
|
3
|
-
from roms_tools import InitialConditions, Grid
|
|
3
|
+
from roms_tools import InitialConditions, Grid
|
|
4
4
|
import xarray as xr
|
|
5
5
|
import numpy as np
|
|
6
6
|
import tempfile
|
|
@@ -16,30 +16,24 @@ def example_grid():
|
|
|
16
16
|
Fixture for creating a Grid object.
|
|
17
17
|
"""
|
|
18
18
|
grid = Grid(
|
|
19
|
-
nx=2,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def example_vertical_coordinate(example_grid):
|
|
27
|
-
"""
|
|
28
|
-
Fixture for creating a VerticalCoordinate object.
|
|
29
|
-
"""
|
|
30
|
-
vertical_coordinate = VerticalCoordinate(
|
|
31
|
-
grid=example_grid,
|
|
19
|
+
nx=2,
|
|
20
|
+
ny=2,
|
|
21
|
+
size_x=500,
|
|
22
|
+
size_y=1000,
|
|
23
|
+
center_lon=0,
|
|
24
|
+
center_lat=55,
|
|
25
|
+
rot=10,
|
|
32
26
|
N=3, # number of vertical levels
|
|
33
27
|
theta_s=5.0, # surface control parameter
|
|
34
28
|
theta_b=2.0, # bottom control parameter
|
|
35
29
|
hc=250.0, # critical depth
|
|
36
30
|
)
|
|
37
31
|
|
|
38
|
-
return
|
|
32
|
+
return grid
|
|
39
33
|
|
|
40
34
|
|
|
41
35
|
@pytest.fixture
|
|
42
|
-
def initial_conditions(example_grid
|
|
36
|
+
def initial_conditions(example_grid):
|
|
43
37
|
"""
|
|
44
38
|
Fixture for creating a dummy InitialConditions object.
|
|
45
39
|
"""
|
|
@@ -48,14 +42,13 @@ def initial_conditions(example_grid, example_vertical_coordinate):
|
|
|
48
42
|
|
|
49
43
|
return InitialConditions(
|
|
50
44
|
grid=example_grid,
|
|
51
|
-
vertical_coordinate=example_vertical_coordinate,
|
|
52
45
|
ini_time=datetime(2021, 6, 29),
|
|
53
46
|
physics_source={"path": fname, "name": "GLORYS"},
|
|
54
47
|
)
|
|
55
48
|
|
|
56
49
|
|
|
57
50
|
@pytest.fixture
|
|
58
|
-
def initial_conditions_with_bgc(example_grid
|
|
51
|
+
def initial_conditions_with_bgc(example_grid):
|
|
59
52
|
"""
|
|
60
53
|
Fixture for creating a dummy InitialConditions object.
|
|
61
54
|
"""
|
|
@@ -65,7 +58,6 @@ def initial_conditions_with_bgc(example_grid, example_vertical_coordinate):
|
|
|
65
58
|
|
|
66
59
|
return InitialConditions(
|
|
67
60
|
grid=example_grid,
|
|
68
|
-
vertical_coordinate=example_vertical_coordinate,
|
|
69
61
|
ini_time=datetime(2021, 6, 29),
|
|
70
62
|
physics_source={"path": fname, "name": "GLORYS"},
|
|
71
63
|
bgc_source={"path": fname_bgc, "name": "CESM_REGRIDDED"},
|
|
@@ -73,9 +65,7 @@ def initial_conditions_with_bgc(example_grid, example_vertical_coordinate):
|
|
|
73
65
|
|
|
74
66
|
|
|
75
67
|
@pytest.fixture
|
|
76
|
-
def initial_conditions_with_bgc_from_climatology(
|
|
77
|
-
example_grid, example_vertical_coordinate
|
|
78
|
-
):
|
|
68
|
+
def initial_conditions_with_bgc_from_climatology(example_grid):
|
|
79
69
|
"""
|
|
80
70
|
Fixture for creating a dummy InitialConditions object.
|
|
81
71
|
"""
|
|
@@ -85,7 +75,6 @@ def initial_conditions_with_bgc_from_climatology(
|
|
|
85
75
|
|
|
86
76
|
return InitialConditions(
|
|
87
77
|
grid=example_grid,
|
|
88
|
-
vertical_coordinate=example_vertical_coordinate,
|
|
89
78
|
ini_time=datetime(2021, 6, 29),
|
|
90
79
|
physics_source={"path": fname, "name": "GLORYS"},
|
|
91
80
|
bgc_source={
|
|
@@ -126,33 +115,27 @@ def test_initial_conditions_creation(ic_fixture, request):
|
|
|
126
115
|
|
|
127
116
|
|
|
128
117
|
# Test initialization with missing 'name' in physics_source
|
|
129
|
-
def test_initial_conditions_missing_physics_name(
|
|
130
|
-
example_grid, example_vertical_coordinate
|
|
131
|
-
):
|
|
118
|
+
def test_initial_conditions_missing_physics_name(example_grid):
|
|
132
119
|
with pytest.raises(ValueError, match="`physics_source` must include a 'name'."):
|
|
133
120
|
InitialConditions(
|
|
134
121
|
grid=example_grid,
|
|
135
|
-
vertical_coordinate=example_vertical_coordinate,
|
|
136
122
|
ini_time=datetime(2021, 6, 29),
|
|
137
123
|
physics_source={"path": "physics_data.nc"},
|
|
138
124
|
)
|
|
139
125
|
|
|
140
126
|
|
|
141
127
|
# Test initialization with missing 'path' in physics_source
|
|
142
|
-
def test_initial_conditions_missing_physics_path(
|
|
143
|
-
example_grid, example_vertical_coordinate
|
|
144
|
-
):
|
|
128
|
+
def test_initial_conditions_missing_physics_path(example_grid):
|
|
145
129
|
with pytest.raises(ValueError, match="`physics_source` must include a 'path'."):
|
|
146
130
|
InitialConditions(
|
|
147
131
|
grid=example_grid,
|
|
148
|
-
vertical_coordinate=example_vertical_coordinate,
|
|
149
132
|
ini_time=datetime(2021, 6, 29),
|
|
150
133
|
physics_source={"name": "GLORYS"},
|
|
151
134
|
)
|
|
152
135
|
|
|
153
136
|
|
|
154
137
|
# Test initialization with missing 'name' in bgc_source
|
|
155
|
-
def test_initial_conditions_missing_bgc_name(example_grid
|
|
138
|
+
def test_initial_conditions_missing_bgc_name(example_grid):
|
|
156
139
|
|
|
157
140
|
fname = download_test_data("GLORYS_test_data.nc")
|
|
158
141
|
with pytest.raises(
|
|
@@ -160,7 +143,6 @@ def test_initial_conditions_missing_bgc_name(example_grid, example_vertical_coor
|
|
|
160
143
|
):
|
|
161
144
|
InitialConditions(
|
|
162
145
|
grid=example_grid,
|
|
163
|
-
vertical_coordinate=example_vertical_coordinate,
|
|
164
146
|
ini_time=datetime(2021, 6, 29),
|
|
165
147
|
physics_source={"name": "GLORYS", "path": fname},
|
|
166
148
|
bgc_source={"path": "bgc_data.nc"},
|
|
@@ -168,7 +150,7 @@ def test_initial_conditions_missing_bgc_name(example_grid, example_vertical_coor
|
|
|
168
150
|
|
|
169
151
|
|
|
170
152
|
# Test initialization with missing 'path' in bgc_source
|
|
171
|
-
def test_initial_conditions_missing_bgc_path(example_grid
|
|
153
|
+
def test_initial_conditions_missing_bgc_path(example_grid):
|
|
172
154
|
|
|
173
155
|
fname = download_test_data("GLORYS_test_data.nc")
|
|
174
156
|
with pytest.raises(
|
|
@@ -176,7 +158,6 @@ def test_initial_conditions_missing_bgc_path(example_grid, example_vertical_coor
|
|
|
176
158
|
):
|
|
177
159
|
InitialConditions(
|
|
178
160
|
grid=example_grid,
|
|
179
|
-
vertical_coordinate=example_vertical_coordinate,
|
|
180
161
|
ini_time=datetime(2021, 6, 29),
|
|
181
162
|
physics_source={"name": "GLORYS", "path": fname},
|
|
182
163
|
bgc_source={"name": "CESM_REGRIDDED"},
|
|
@@ -184,15 +165,12 @@ def test_initial_conditions_missing_bgc_path(example_grid, example_vertical_coor
|
|
|
184
165
|
|
|
185
166
|
|
|
186
167
|
# Test default climatology value
|
|
187
|
-
def test_initial_conditions_default_climatology(
|
|
188
|
-
example_grid, example_vertical_coordinate
|
|
189
|
-
):
|
|
168
|
+
def test_initial_conditions_default_climatology(example_grid):
|
|
190
169
|
|
|
191
170
|
fname = download_test_data("GLORYS_test_data.nc")
|
|
192
171
|
|
|
193
172
|
initial_conditions = InitialConditions(
|
|
194
173
|
grid=example_grid,
|
|
195
|
-
vertical_coordinate=example_vertical_coordinate,
|
|
196
174
|
ini_time=datetime(2021, 6, 29),
|
|
197
175
|
physics_source={"name": "GLORYS", "path": fname},
|
|
198
176
|
)
|
|
@@ -201,16 +179,13 @@ def test_initial_conditions_default_climatology(
|
|
|
201
179
|
assert initial_conditions.bgc_source is None
|
|
202
180
|
|
|
203
181
|
|
|
204
|
-
def test_initial_conditions_default_bgc_climatology(
|
|
205
|
-
example_grid, example_vertical_coordinate
|
|
206
|
-
):
|
|
182
|
+
def test_initial_conditions_default_bgc_climatology(example_grid):
|
|
207
183
|
|
|
208
184
|
fname = download_test_data("GLORYS_test_data.nc")
|
|
209
185
|
fname_bgc = download_test_data("CESM_regional_test_data_one_time_slice.nc")
|
|
210
186
|
|
|
211
187
|
initial_conditions = InitialConditions(
|
|
212
188
|
grid=example_grid,
|
|
213
|
-
vertical_coordinate=example_vertical_coordinate,
|
|
214
189
|
ini_time=datetime(2021, 6, 29),
|
|
215
190
|
physics_source={"name": "GLORYS", "path": fname},
|
|
216
191
|
bgc_source={"name": "CESM_REGRIDDED", "path": fname_bgc},
|
|
@@ -255,59 +230,48 @@ def test_initial_conditions_data_consistency_plot_save(
|
|
|
255
230
|
[
|
|
256
231
|
[
|
|
257
232
|
[
|
|
258
|
-
[16.84414,
|
|
259
|
-
[
|
|
260
|
-
[
|
|
261
|
-
[
|
|
233
|
+
[16.84414, 18.088203, 18.431192, 19.294329],
|
|
234
|
+
[12.639833, 15.712767, 13.02848, 18.633307],
|
|
235
|
+
[11.027701, 12.302642, 8.143677, 8.710737],
|
|
236
|
+
[10.233599, 10.147332, 10.458557, 9.20282],
|
|
262
237
|
],
|
|
263
238
|
[
|
|
264
|
-
[
|
|
265
|
-
[
|
|
266
|
-
[
|
|
267
|
-
[
|
|
239
|
+
[16.905312, 18.121834, 18.496748, 19.30358],
|
|
240
|
+
[13.479691, 15.920951, 14.5227165, 18.637077],
|
|
241
|
+
[11.650267, 12.646921, 11.435992, 11.25943],
|
|
242
|
+
[10.546486, 10.502733, 11.209945, 10.667074],
|
|
268
243
|
],
|
|
269
244
|
[
|
|
270
|
-
[
|
|
271
|
-
[
|
|
272
|
-
[
|
|
273
|
-
[
|
|
274
|
-
],
|
|
275
|
-
[
|
|
276
|
-
[10.233599, 10.546486, 10.671082],
|
|
277
|
-
[10.147331, 10.502733, 10.68275],
|
|
278
|
-
[10.458557, 11.209945, 11.377164],
|
|
279
|
-
[9.20282, 10.667074, 11.752404],
|
|
245
|
+
[16.967817, 18.315424, 18.718002, 19.439777],
|
|
246
|
+
[14.426711, 16.10028, 15.05175, 18.667465],
|
|
247
|
+
[12.200586, 13.150708, 13.356925, 13.111585],
|
|
248
|
+
[10.671082, 10.68275, 11.377164, 11.752404],
|
|
280
249
|
],
|
|
281
250
|
]
|
|
282
251
|
],
|
|
283
252
|
dtype=np.float32,
|
|
284
253
|
)
|
|
254
|
+
|
|
285
255
|
expected_salt = np.array(
|
|
286
256
|
[
|
|
287
257
|
[
|
|
288
258
|
[
|
|
289
|
-
[33.832672,
|
|
290
|
-
[
|
|
291
|
-
[
|
|
292
|
-
[
|
|
259
|
+
[33.832672, 32.50002, 30.922323, 28.337738],
|
|
260
|
+
[34.8002, 32.43797, 34.885834, 29.237692],
|
|
261
|
+
[34.046825, 33.892323, 34.964134, 34.975933],
|
|
262
|
+
[35.21593, 35.224304, 35.299217, 34.25124],
|
|
293
263
|
],
|
|
294
264
|
[
|
|
295
|
-
[
|
|
296
|
-
[
|
|
297
|
-
[
|
|
298
|
-
[
|
|
265
|
+
[33.77759, 32.48105, 30.909824, 28.335176],
|
|
266
|
+
[34.691143, 32.369576, 34.82964, 29.232145],
|
|
267
|
+
[33.950684, 33.84102, 34.91892, 34.48586],
|
|
268
|
+
[35.209476, 35.209522, 35.31244, 33.828175],
|
|
299
269
|
],
|
|
300
270
|
[
|
|
301
|
-
[
|
|
302
|
-
[
|
|
303
|
-
[
|
|
304
|
-
[
|
|
305
|
-
],
|
|
306
|
-
[
|
|
307
|
-
[35.21593, 35.209476, 35.20767],
|
|
308
|
-
[35.224304, 35.209522, 35.20715],
|
|
309
|
-
[35.299217, 35.31244, 35.31555],
|
|
310
|
-
[34.25124, 33.828175, 33.234303],
|
|
271
|
+
[33.633846, 32.154694, 30.508572, 28.067144],
|
|
272
|
+
[34.382282, 32.027843, 34.775684, 29.09444],
|
|
273
|
+
[33.87148, 33.69169, 34.91941, 32.729057],
|
|
274
|
+
[35.20767, 35.20715, 35.31555, 33.234303],
|
|
311
275
|
],
|
|
312
276
|
]
|
|
313
277
|
],
|
|
@@ -329,17 +293,23 @@ def test_initial_conditions_data_consistency_plot_save(
|
|
|
329
293
|
expected_u = np.array(
|
|
330
294
|
[
|
|
331
295
|
[
|
|
332
|
-
[[-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [0.0, -0.0, -0.0]],
|
|
333
|
-
[[0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0]],
|
|
334
296
|
[
|
|
335
|
-
[0.0, 0.0,
|
|
336
|
-
[0.0, 0.0, -0.0],
|
|
337
|
-
[0.
|
|
297
|
+
[-0.0, -0.0, 0.0],
|
|
298
|
+
[0.0, -0.0, -0.0],
|
|
299
|
+
[0.0, 0.0, 0.06979556],
|
|
300
|
+
[0.04268532, 0.04645353, 0.0211786],
|
|
338
301
|
],
|
|
339
302
|
[
|
|
340
|
-
[0.
|
|
341
|
-
[0.
|
|
342
|
-
[0.
|
|
303
|
+
[-0.0, -0.0, -0.0],
|
|
304
|
+
[-0.0, -0.0, -0.0],
|
|
305
|
+
[0.0, 0.0, 0.06167743],
|
|
306
|
+
[0.03889201, 0.04914769, 0.03679834],
|
|
307
|
+
],
|
|
308
|
+
[
|
|
309
|
+
[-0.0, -0.0, -0.0],
|
|
310
|
+
[-0.0, -0.0, -0.0],
|
|
311
|
+
[-0.0, -0.0, -0.02247071],
|
|
312
|
+
[0.03351666, 0.03673013, 0.0274788],
|
|
343
313
|
],
|
|
344
314
|
]
|
|
345
315
|
],
|
|
@@ -350,22 +320,19 @@ def test_initial_conditions_data_consistency_plot_save(
|
|
|
350
320
|
[
|
|
351
321
|
[
|
|
352
322
|
[
|
|
353
|
-
[0.0, 0.0, 0.0],
|
|
354
|
-
[0.0, 0.0, -0.0],
|
|
355
|
-
[-0.
|
|
356
|
-
[-0.0, -0.0, -0.0],
|
|
323
|
+
[0.0, 0.0, -0.0, -0.0],
|
|
324
|
+
[-0.0, -0.0, -0.03831354, -0.0],
|
|
325
|
+
[-0.00951457, -0.0, 0.01915873, -0.06720348],
|
|
357
326
|
],
|
|
358
327
|
[
|
|
359
|
-
[
|
|
360
|
-
[-0.0, -0.0, -0.0],
|
|
361
|
-
[-0.
|
|
362
|
-
[-0.0, -0.0, -0.0],
|
|
328
|
+
[0.0, 0.0, -0.0, -0.0],
|
|
329
|
+
[-0.0, -0.0, -0.02400788, -0.0],
|
|
330
|
+
[-0.00576979, -0.0, 0.02625698, -0.08354441],
|
|
363
331
|
],
|
|
364
332
|
[
|
|
365
|
-
[-0.
|
|
366
|
-
[-0.0, -0.0, -0.0],
|
|
367
|
-
[0.
|
|
368
|
-
[-0.06720348, -0.08354441, -0.13835917],
|
|
333
|
+
[0.0, -0.0, -0.0, -0.0],
|
|
334
|
+
[-0.0, -0.0, -0.03179555, -0.0],
|
|
335
|
+
[-0.02147919, -0.0, 0.01757628, -0.13835917],
|
|
369
336
|
],
|
|
370
337
|
]
|
|
371
338
|
],
|
|
@@ -399,28 +366,22 @@ def test_initial_conditions_data_consistency_plot_save(
|
|
|
399
366
|
[
|
|
400
367
|
[
|
|
401
368
|
[
|
|
402
|
-
[2341.926,
|
|
403
|
-
[2317.
|
|
404
|
-
[
|
|
405
|
-
[
|
|
369
|
+
[2341.926, 2317.8875, 2297.689, 2276.4216],
|
|
370
|
+
[2330.5837, 2317.878, 2278.9314, 2259.975],
|
|
371
|
+
[2376.7534, 2362.5308, 2350.3384, 2310.4275],
|
|
372
|
+
[2384.8064, 2383.737, 2380.2297, 2350.0762],
|
|
406
373
|
],
|
|
407
374
|
[
|
|
408
|
-
[
|
|
409
|
-
[
|
|
410
|
-
[
|
|
411
|
-
[
|
|
375
|
+
[2340.8894, 2315.86, 2285.8933, 2258.4436],
|
|
376
|
+
[2329.8225, 2316.6787, 2269.464, 2247.7456],
|
|
377
|
+
[2373.4402, 2360.5066, 2344.3135, 2287.6785],
|
|
378
|
+
[2386.2126, 2385.1553, 2381.4849, 2342.5403],
|
|
412
379
|
],
|
|
413
380
|
[
|
|
414
|
-
[
|
|
415
|
-
[
|
|
416
|
-
[
|
|
417
|
-
[
|
|
418
|
-
],
|
|
419
|
-
[
|
|
420
|
-
[2384.8064, 2386.2126, 2386.632],
|
|
421
|
-
[2383.737, 2385.1553, 2385.6685],
|
|
422
|
-
[2380.2297, 2381.4849, 2381.8616],
|
|
423
|
-
[2350.0762, 2342.5403, 2339.2244],
|
|
381
|
+
[2340.557, 2315.2148, 2284.404, 2256.1062],
|
|
382
|
+
[2329.5264, 2316.3088, 2268.904, 2246.0632],
|
|
383
|
+
[2372.9192, 2360.2224, 2343.6768, 2281.5872],
|
|
384
|
+
[2386.632, 2385.6685, 2381.8616, 2339.2244],
|
|
424
385
|
],
|
|
425
386
|
]
|
|
426
387
|
],
|
|
@@ -454,6 +415,15 @@ def test_initial_conditions_data_consistency_plot_save(
|
|
|
454
415
|
)
|
|
455
416
|
|
|
456
417
|
initial_conditions_with_bgc_from_climatology.plot(varname="temp", s=0)
|
|
418
|
+
initial_conditions_with_bgc_from_climatology.plot(
|
|
419
|
+
varname="temp", s=0, depth_contours=True
|
|
420
|
+
)
|
|
421
|
+
initial_conditions_with_bgc_from_climatology.plot(
|
|
422
|
+
varname="temp", eta=0, layer_contours=True
|
|
423
|
+
)
|
|
424
|
+
initial_conditions_with_bgc_from_climatology.plot(
|
|
425
|
+
varname="temp", xi=0, layer_contours=True
|
|
426
|
+
)
|
|
457
427
|
initial_conditions_with_bgc_from_climatology.plot(varname="temp", eta=0)
|
|
458
428
|
initial_conditions_with_bgc_from_climatology.plot(varname="temp", xi=0)
|
|
459
429
|
initial_conditions_with_bgc_from_climatology.plot(varname="temp", s=0, xi=0)
|