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
|
@@ -193,8 +193,26 @@ def test_successful_initialization_with_regional_data(grid_fixture, request):
|
|
|
193
193
|
)
|
|
194
194
|
|
|
195
195
|
assert sfc_forcing.ds is not None
|
|
196
|
+
assert "uwnd" in sfc_forcing.ds["physics"]
|
|
197
|
+
assert "vwnd" in sfc_forcing.ds["physics"]
|
|
198
|
+
assert "swrad" in sfc_forcing.ds["physics"]
|
|
199
|
+
assert "lwrad" in sfc_forcing.ds["physics"]
|
|
200
|
+
assert "Tair" in sfc_forcing.ds["physics"]
|
|
201
|
+
assert "qair" in sfc_forcing.ds["physics"]
|
|
202
|
+
assert "rain" in sfc_forcing.ds["physics"]
|
|
203
|
+
|
|
204
|
+
assert sfc_forcing.start_time == start_time
|
|
205
|
+
assert sfc_forcing.end_time == end_time
|
|
206
|
+
assert sfc_forcing.physics_source == {
|
|
207
|
+
"name": "ERA5",
|
|
208
|
+
"path": fname,
|
|
209
|
+
"climatology": False,
|
|
210
|
+
}
|
|
211
|
+
assert not sfc_forcing.use_coarse_grid
|
|
196
212
|
|
|
197
|
-
|
|
213
|
+
sfc_forcing.plot("uwnd", time=0)
|
|
214
|
+
sfc_forcing.plot("vwnd", time=0)
|
|
215
|
+
sfc_forcing.plot("rain", time=0)
|
|
198
216
|
|
|
199
217
|
sfc_forcing = SurfaceForcing(
|
|
200
218
|
grid=grid,
|
|
@@ -204,6 +222,7 @@ def test_successful_initialization_with_regional_data(grid_fixture, request):
|
|
|
204
222
|
physics_source={"name": "ERA5", "path": fname},
|
|
205
223
|
)
|
|
206
224
|
|
|
225
|
+
assert sfc_forcing.ds is not None
|
|
207
226
|
assert "uwnd" in sfc_forcing.ds["physics"]
|
|
208
227
|
assert "vwnd" in sfc_forcing.ds["physics"]
|
|
209
228
|
assert "swrad" in sfc_forcing.ds["physics"]
|
|
@@ -219,6 +238,11 @@ def test_successful_initialization_with_regional_data(grid_fixture, request):
|
|
|
219
238
|
"path": fname,
|
|
220
239
|
"climatology": False,
|
|
221
240
|
}
|
|
241
|
+
assert sfc_forcing.use_coarse_grid
|
|
242
|
+
|
|
243
|
+
sfc_forcing.plot("uwnd", time=0)
|
|
244
|
+
sfc_forcing.plot("vwnd", time=0)
|
|
245
|
+
sfc_forcing.plot("rain", time=0)
|
|
222
246
|
|
|
223
247
|
|
|
224
248
|
@pytest.mark.parametrize(
|
|
@@ -250,8 +274,6 @@ def test_nan_detection_initialization_with_regional_data(grid_fixture, request):
|
|
|
250
274
|
physics_source={"name": "ERA5", "path": fname},
|
|
251
275
|
)
|
|
252
276
|
|
|
253
|
-
grid.coarsen()
|
|
254
|
-
|
|
255
277
|
with pytest.raises(ValueError, match="NaN values found"):
|
|
256
278
|
SurfaceForcing(
|
|
257
279
|
grid=grid,
|
|
@@ -286,8 +308,6 @@ def test_no_longitude_intersection_initialization_with_regional_data(
|
|
|
286
308
|
physics_source={"name": "ERA5", "path": fname},
|
|
287
309
|
)
|
|
288
310
|
|
|
289
|
-
grid_that_straddles_180_degree_meridian.coarsen()
|
|
290
|
-
|
|
291
311
|
with pytest.raises(
|
|
292
312
|
ValueError, match="Selected longitude range does not intersect with dataset"
|
|
293
313
|
):
|
|
@@ -350,8 +370,6 @@ def test_successful_initialization_with_global_data(grid_fixture, request):
|
|
|
350
370
|
assert "rain" in sfc_forcing.ds["physics"]
|
|
351
371
|
assert sfc_forcing.ds["physics"].attrs["physics_source"] == "ERA5"
|
|
352
372
|
|
|
353
|
-
grid.coarsen()
|
|
354
|
-
|
|
355
373
|
sfc_forcing = SurfaceForcing(
|
|
356
374
|
grid=grid,
|
|
357
375
|
use_coarse_grid=True,
|
|
@@ -31,12 +31,10 @@ def test_rmax_criterion():
|
|
|
31
31
|
center_lon=30,
|
|
32
32
|
center_lat=61,
|
|
33
33
|
rot=20,
|
|
34
|
-
smooth_factor=4,
|
|
35
|
-
rmax=0.2,
|
|
36
34
|
)
|
|
37
35
|
r_eta, r_xi = _compute_rfactor(grid.ds.h)
|
|
38
36
|
rmax0 = np.max([r_eta.max(), r_xi.max()])
|
|
39
|
-
npt.assert_array_less(rmax0,
|
|
37
|
+
npt.assert_array_less(rmax0, 0.2)
|
|
40
38
|
|
|
41
39
|
|
|
42
40
|
def test_hmin_criterion():
|
|
@@ -48,11 +46,15 @@ def test_hmin_criterion():
|
|
|
48
46
|
center_lon=30,
|
|
49
47
|
center_lat=61,
|
|
50
48
|
rot=20,
|
|
51
|
-
|
|
52
|
-
rmax=0.2,
|
|
53
|
-
hmin=5,
|
|
49
|
+
hmin=5.0,
|
|
54
50
|
)
|
|
55
51
|
|
|
52
|
+
assert grid.hmin == 5.0
|
|
53
|
+
assert np.less_equal(grid.hmin, grid.ds.h.min())
|
|
54
|
+
|
|
55
|
+
grid.update_topography_and_mask(hmin=10.0)
|
|
56
|
+
|
|
57
|
+
assert grid.hmin == 10.0
|
|
56
58
|
assert np.less_equal(grid.hmin, grid.ds.h.min())
|
|
57
59
|
|
|
58
60
|
|
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
import numpy as np
|
|
3
|
-
import
|
|
4
|
-
import os
|
|
5
|
-
from roms_tools import Grid, VerticalCoordinate
|
|
6
|
-
import textwrap
|
|
3
|
+
from roms_tools import Grid
|
|
7
4
|
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
def example_grid():
|
|
11
|
-
"""
|
|
12
|
-
Fixture for creating a Grid object.
|
|
13
|
-
"""
|
|
14
|
-
grid = Grid(
|
|
15
|
-
nx=2, ny=2, size_x=500, size_y=1000, center_lon=0, center_lat=55, rot=10
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
return grid
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_invalid_theta_s_value(example_grid):
|
|
6
|
+
def test_invalid_theta_s_value():
|
|
22
7
|
"""
|
|
23
8
|
Test the validation of the theta_s value.
|
|
24
9
|
"""
|
|
25
10
|
with pytest.raises(ValueError):
|
|
26
11
|
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
Grid(
|
|
13
|
+
nx=2,
|
|
14
|
+
ny=2,
|
|
15
|
+
size_x=500,
|
|
16
|
+
size_y=1000,
|
|
17
|
+
center_lon=0,
|
|
18
|
+
center_lat=55,
|
|
19
|
+
rot=10,
|
|
29
20
|
N=3,
|
|
30
21
|
theta_s=11.0, # Invalid value, should be 0 < theta_s <= 10
|
|
31
22
|
theta_b=2.0,
|
|
@@ -33,14 +24,19 @@ def test_invalid_theta_s_value(example_grid):
|
|
|
33
24
|
)
|
|
34
25
|
|
|
35
26
|
|
|
36
|
-
def test_invalid_theta_b_value(
|
|
27
|
+
def test_invalid_theta_b_value():
|
|
37
28
|
"""
|
|
38
29
|
Test the validation of the theta_b value.
|
|
39
30
|
"""
|
|
40
31
|
with pytest.raises(ValueError):
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
Grid(
|
|
33
|
+
nx=2,
|
|
34
|
+
ny=2,
|
|
35
|
+
size_x=500,
|
|
36
|
+
size_y=1000,
|
|
37
|
+
center_lon=0,
|
|
38
|
+
center_lat=55,
|
|
39
|
+
rot=10,
|
|
44
40
|
N=3,
|
|
45
41
|
theta_s=5.0,
|
|
46
42
|
theta_b=5.0, # Invalid value, should be 0 < theta_b <= 4
|
|
@@ -48,47 +44,68 @@ def test_invalid_theta_b_value(example_grid):
|
|
|
48
44
|
)
|
|
49
45
|
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
def vertical_coordinate(example_grid):
|
|
47
|
+
def test_update_vertical_coordinate():
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
grid = Grid(
|
|
50
|
+
nx=2, ny=2, size_x=500, size_y=1000, center_lon=0, center_lat=55, rot=10
|
|
56
51
|
)
|
|
57
52
|
|
|
53
|
+
assert grid.N == 100
|
|
54
|
+
assert grid.theta_s == 5.0
|
|
55
|
+
assert grid.theta_b == 2.0
|
|
56
|
+
assert grid.hc == 300.0
|
|
57
|
+
assert len(grid.ds.s_rho) == 100
|
|
58
|
+
|
|
59
|
+
grid.update_vertical_coordinate(N=3, theta_s=10.0, theta_b=1.0, hc=400.0)
|
|
60
|
+
|
|
61
|
+
assert grid.N == 3
|
|
62
|
+
assert grid.theta_s == 10.0
|
|
63
|
+
assert grid.theta_b == 1.0
|
|
64
|
+
assert grid.hc == 400.0
|
|
65
|
+
assert len(grid.ds.s_rho) == 3
|
|
66
|
+
|
|
58
67
|
|
|
59
|
-
def test_vertical_coordinate_data_consistency(
|
|
68
|
+
def test_vertical_coordinate_data_consistency():
|
|
60
69
|
"""
|
|
61
70
|
Test that the data within the VerticalCoordinate object remains consistent.
|
|
62
71
|
"""
|
|
63
72
|
|
|
73
|
+
grid = Grid(
|
|
74
|
+
nx=2,
|
|
75
|
+
ny=2,
|
|
76
|
+
size_x=500,
|
|
77
|
+
size_y=1000,
|
|
78
|
+
center_lon=0,
|
|
79
|
+
center_lat=55,
|
|
80
|
+
rot=10,
|
|
81
|
+
N=3,
|
|
82
|
+
theta_s=5.0,
|
|
83
|
+
theta_b=2.0,
|
|
84
|
+
hc=250.0,
|
|
85
|
+
)
|
|
86
|
+
|
|
64
87
|
# Define the expected data
|
|
65
88
|
expected_sc_r = np.array([-0.8333333, -0.5, -0.16666667], dtype=np.float32)
|
|
66
89
|
expected_Cs_r = np.array([-0.6641397, -0.15129805, -0.01156188], dtype=np.float32)
|
|
67
90
|
expected_layer_depth_rho = np.array(
|
|
68
91
|
[
|
|
69
92
|
[
|
|
70
|
-
[17.235603,
|
|
71
|
-
[17.235603,
|
|
72
|
-
[
|
|
73
|
-
[
|
|
93
|
+
[17.235603, 17.235603, 24.206884, 24.206884],
|
|
94
|
+
[17.235603, 17.235603, 24.206884, 24.206884],
|
|
95
|
+
[25.667452, 25.667452, 35.966946, 35.966946],
|
|
96
|
+
[25.667452, 25.667452, 35.966946, 35.966946],
|
|
74
97
|
],
|
|
75
98
|
[
|
|
76
|
-
[
|
|
77
|
-
[
|
|
78
|
-
[
|
|
79
|
-
[
|
|
99
|
+
[9.938617, 9.938617, 13.7451725, 13.7451725],
|
|
100
|
+
[9.938617, 9.938617, 13.7451725, 13.7451725],
|
|
101
|
+
[14.528268, 14.528268, 19.916193, 19.916193],
|
|
102
|
+
[14.528268, 14.528268, 19.916193, 19.916193],
|
|
80
103
|
],
|
|
81
104
|
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
],
|
|
87
|
-
[
|
|
88
|
-
[25.667452, 14.528268, 4.7055993],
|
|
89
|
-
[25.667452, 14.528268, 4.7055993],
|
|
90
|
-
[35.966946, 19.916193, 6.377065],
|
|
91
|
-
[35.966946, 19.916193, 6.377065],
|
|
105
|
+
[3.2495391, 3.2495391, 4.4592304, 4.4592304],
|
|
106
|
+
[3.2495391, 3.2495391, 4.4592304, 4.4592304],
|
|
107
|
+
[4.7055993, 4.7055993, 6.377065, 6.377065],
|
|
108
|
+
[4.7055993, 4.7055993, 6.377065, 6.377065],
|
|
92
109
|
],
|
|
93
110
|
],
|
|
94
111
|
dtype=np.float32,
|
|
@@ -96,24 +113,22 @@ def test_vertical_coordinate_data_consistency(vertical_coordinate, tmp_path):
|
|
|
96
113
|
expected_layer_depth_u = np.array(
|
|
97
114
|
[
|
|
98
115
|
[
|
|
99
|
-
[17.235603,
|
|
100
|
-
[
|
|
101
|
-
[
|
|
102
|
-
|
|
103
|
-
[
|
|
104
|
-
[17.235603, 9.938617, 3.2495391],
|
|
105
|
-
[20.721243, 11.841895, 3.854385],
|
|
106
|
-
[24.206884, 13.7451725, 4.4592304],
|
|
116
|
+
[17.235603, 20.721243, 24.206884],
|
|
117
|
+
[17.235603, 20.721243, 24.206884],
|
|
118
|
+
[25.667452, 30.817198, 35.966946],
|
|
119
|
+
[25.667452, 30.817198, 35.966946],
|
|
107
120
|
],
|
|
108
121
|
[
|
|
109
|
-
[
|
|
110
|
-
[
|
|
111
|
-
[
|
|
122
|
+
[9.938617, 11.841895, 13.7451725],
|
|
123
|
+
[9.938617, 11.841895, 13.7451725],
|
|
124
|
+
[14.528268, 17.22223, 19.916193],
|
|
125
|
+
[14.528268, 17.22223, 19.916193],
|
|
112
126
|
],
|
|
113
127
|
[
|
|
114
|
-
[
|
|
115
|
-
[
|
|
116
|
-
[
|
|
128
|
+
[3.2495391, 3.854385, 4.4592304],
|
|
129
|
+
[3.2495391, 3.854385, 4.4592304],
|
|
130
|
+
[4.7055993, 5.5413322, 6.377065],
|
|
131
|
+
[4.7055993, 5.5413322, 6.377065],
|
|
117
132
|
],
|
|
118
133
|
],
|
|
119
134
|
dtype=np.float32,
|
|
@@ -121,22 +136,19 @@ def test_vertical_coordinate_data_consistency(vertical_coordinate, tmp_path):
|
|
|
121
136
|
expected_layer_depth_v = np.array(
|
|
122
137
|
[
|
|
123
138
|
[
|
|
124
|
-
[17.235603,
|
|
125
|
-
[
|
|
126
|
-
[
|
|
127
|
-
[24.206884, 13.7451725, 4.4592304],
|
|
139
|
+
[17.235603, 17.235603, 24.206884, 24.206884],
|
|
140
|
+
[21.451529, 21.451529, 30.086914, 30.086914],
|
|
141
|
+
[25.667452, 25.667452, 35.966946, 35.966946],
|
|
128
142
|
],
|
|
129
143
|
[
|
|
130
|
-
[
|
|
131
|
-
[
|
|
132
|
-
[
|
|
133
|
-
[30.086914, 16.830683, 5.418148],
|
|
144
|
+
[9.938617, 9.938617, 13.7451725, 13.7451725],
|
|
145
|
+
[12.233442, 12.233442, 16.830683, 16.830683],
|
|
146
|
+
[14.528268, 14.528268, 19.916193, 19.916193],
|
|
134
147
|
],
|
|
135
148
|
[
|
|
136
|
-
[
|
|
137
|
-
[
|
|
138
|
-
[
|
|
139
|
-
[35.966946, 19.916193, 6.377065],
|
|
149
|
+
[3.2495391, 3.2495391, 4.4592304, 4.4592304],
|
|
150
|
+
[3.977569, 3.977569, 5.418148, 5.418148],
|
|
151
|
+
[4.7055993, 4.7055993, 6.377065, 6.377065],
|
|
140
152
|
],
|
|
141
153
|
],
|
|
142
154
|
dtype=np.float32,
|
|
@@ -144,28 +156,28 @@ def test_vertical_coordinate_data_consistency(vertical_coordinate, tmp_path):
|
|
|
144
156
|
expected_interface_depth_rho = np.array(
|
|
145
157
|
[
|
|
146
158
|
[
|
|
147
|
-
[21.013529,
|
|
148
|
-
[21.013529,
|
|
149
|
-
[
|
|
150
|
-
[
|
|
159
|
+
[21.013529, 21.013529, 29.688076, 29.688076],
|
|
160
|
+
[21.013529, 21.013529, 29.688076, 29.688076],
|
|
161
|
+
[31.51735, 31.51735, 44.52708, 44.52708],
|
|
162
|
+
[31.51735, 31.51735, 44.52708, 44.52708],
|
|
151
163
|
],
|
|
152
164
|
[
|
|
153
|
-
[
|
|
154
|
-
[
|
|
155
|
-
[
|
|
156
|
-
[
|
|
165
|
+
[13.487298, 13.487298, 18.78298, 18.78298],
|
|
166
|
+
[13.487298, 13.487298, 18.78298, 18.78298],
|
|
167
|
+
[19.881702, 19.881702, 27.529188, 27.529188],
|
|
168
|
+
[19.881702, 19.881702, 27.529188, 27.529188],
|
|
157
169
|
],
|
|
158
170
|
[
|
|
159
|
-
[
|
|
160
|
-
[
|
|
161
|
-
[
|
|
162
|
-
[
|
|
171
|
+
[6.5489607, 6.5489607, 9.014939, 9.014939],
|
|
172
|
+
[6.5489607, 6.5489607, 9.014939, 9.014939],
|
|
173
|
+
[9.519225, 9.519225, 12.960222, 12.960222],
|
|
174
|
+
[9.519225, 9.519225, 12.960222, 12.960222],
|
|
163
175
|
],
|
|
164
176
|
[
|
|
165
|
-
[
|
|
166
|
-
[
|
|
167
|
-
[
|
|
168
|
-
[
|
|
177
|
+
[-0.0, -0.0, -0.0, -0.0],
|
|
178
|
+
[-0.0, -0.0, -0.0, -0.0],
|
|
179
|
+
[-0.0, -0.0, -0.0, -0.0],
|
|
180
|
+
[-0.0, -0.0, -0.0, -0.0],
|
|
169
181
|
],
|
|
170
182
|
],
|
|
171
183
|
dtype=np.float32,
|
|
@@ -173,24 +185,28 @@ def test_vertical_coordinate_data_consistency(vertical_coordinate, tmp_path):
|
|
|
173
185
|
expected_interface_depth_u = np.array(
|
|
174
186
|
[
|
|
175
187
|
[
|
|
176
|
-
[21.013529,
|
|
177
|
-
[
|
|
178
|
-
[
|
|
188
|
+
[21.013529, 25.350803, 29.688076],
|
|
189
|
+
[21.013529, 25.350803, 29.688076],
|
|
190
|
+
[31.51735, 38.022217, 44.52708],
|
|
191
|
+
[31.51735, 38.022217, 44.52708],
|
|
179
192
|
],
|
|
180
193
|
[
|
|
181
|
-
[
|
|
182
|
-
[
|
|
183
|
-
[
|
|
194
|
+
[13.487298, 16.13514, 18.78298],
|
|
195
|
+
[13.487298, 16.13514, 18.78298],
|
|
196
|
+
[19.881702, 23.705446, 27.529188],
|
|
197
|
+
[19.881702, 23.705446, 27.529188],
|
|
184
198
|
],
|
|
185
199
|
[
|
|
186
|
-
[
|
|
187
|
-
[
|
|
188
|
-
[
|
|
200
|
+
[6.5489607, 7.78195, 9.014939],
|
|
201
|
+
[6.5489607, 7.78195, 9.014939],
|
|
202
|
+
[9.519225, 11.239724, 12.960222],
|
|
203
|
+
[9.519225, 11.239724, 12.960222],
|
|
189
204
|
],
|
|
190
205
|
[
|
|
191
|
-
[
|
|
192
|
-
[
|
|
193
|
-
[
|
|
206
|
+
[-0.0, -0.0, -0.0],
|
|
207
|
+
[-0.0, -0.0, -0.0],
|
|
208
|
+
[-0.0, -0.0, -0.0],
|
|
209
|
+
[-0.0, -0.0, -0.0],
|
|
194
210
|
],
|
|
195
211
|
],
|
|
196
212
|
dtype=np.float32,
|
|
@@ -198,140 +214,69 @@ def test_vertical_coordinate_data_consistency(vertical_coordinate, tmp_path):
|
|
|
198
214
|
expected_interface_depth_v = np.array(
|
|
199
215
|
[
|
|
200
216
|
[
|
|
201
|
-
[21.013529,
|
|
202
|
-
[
|
|
203
|
-
[
|
|
204
|
-
[29.688076, 18.78298, 9.014939, -0.0],
|
|
217
|
+
[21.013529, 21.013529, 29.688076, 29.688076],
|
|
218
|
+
[26.26544, 26.26544, 37.10758, 37.10758],
|
|
219
|
+
[31.51735, 31.51735, 44.52708, 44.52708],
|
|
205
220
|
],
|
|
206
221
|
[
|
|
207
|
-
[
|
|
208
|
-
[
|
|
209
|
-
[
|
|
210
|
-
[37.10758, 23.156084, 10.987581, -0.0],
|
|
222
|
+
[13.487298, 13.487298, 18.78298, 18.78298],
|
|
223
|
+
[16.684502, 16.684502, 23.156084, 23.156084],
|
|
224
|
+
[19.881702, 19.881702, 27.529188, 27.529188],
|
|
211
225
|
],
|
|
212
226
|
[
|
|
213
|
-
[
|
|
214
|
-
[
|
|
215
|
-
[
|
|
216
|
-
|
|
227
|
+
[6.5489607, 6.5489607, 9.014939, 9.014939],
|
|
228
|
+
[8.034093, 8.034093, 10.987581, 10.987581],
|
|
229
|
+
[9.519225, 9.519225, 12.960222, 12.960222],
|
|
230
|
+
],
|
|
231
|
+
[
|
|
232
|
+
[-0.0, -0.0, -0.0, -0.0],
|
|
233
|
+
[-0.0, -0.0, -0.0, -0.0],
|
|
234
|
+
[-0.0, -0.0, -0.0, -0.0],
|
|
217
235
|
],
|
|
218
236
|
],
|
|
219
237
|
dtype=np.float32,
|
|
220
238
|
)
|
|
239
|
+
|
|
221
240
|
# Check the values in the dataset
|
|
222
|
-
assert np.allclose(
|
|
223
|
-
assert np.allclose(
|
|
224
|
-
assert np.allclose(
|
|
225
|
-
|
|
226
|
-
)
|
|
227
|
-
assert np.allclose(
|
|
228
|
-
vertical_coordinate.ds["layer_depth_u"].values, expected_layer_depth_u
|
|
229
|
-
)
|
|
241
|
+
assert np.allclose(grid.ds["sc_r"].values, expected_sc_r)
|
|
242
|
+
assert np.allclose(grid.ds["Cs_r"].values, expected_Cs_r)
|
|
243
|
+
assert np.allclose(grid.ds["layer_depth_rho"].values, expected_layer_depth_rho)
|
|
244
|
+
assert np.allclose(grid.ds["layer_depth_u"].values, expected_layer_depth_u)
|
|
245
|
+
assert np.allclose(grid.ds["layer_depth_v"].values, expected_layer_depth_v)
|
|
230
246
|
assert np.allclose(
|
|
231
|
-
|
|
232
|
-
)
|
|
233
|
-
assert np.allclose(
|
|
234
|
-
vertical_coordinate.ds["interface_depth_rho"].values,
|
|
247
|
+
grid.ds["interface_depth_rho"].values,
|
|
235
248
|
expected_interface_depth_rho,
|
|
236
249
|
)
|
|
237
|
-
assert np.allclose(
|
|
238
|
-
|
|
239
|
-
)
|
|
240
|
-
assert np.allclose(
|
|
241
|
-
vertical_coordinate.ds["interface_depth_v"].values, expected_interface_depth_v
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
def test_plot(vertical_coordinate):
|
|
246
|
-
vertical_coordinate.plot("layer_depth_u", s=0)
|
|
247
|
-
vertical_coordinate.plot("layer_depth_rho", s=-1)
|
|
248
|
-
vertical_coordinate.plot("interface_depth_v", s=-1)
|
|
249
|
-
vertical_coordinate.plot("layer_depth_rho", eta=0)
|
|
250
|
-
vertical_coordinate.plot("layer_depth_u", eta=0)
|
|
251
|
-
vertical_coordinate.plot("layer_depth_v", eta=0)
|
|
252
|
-
vertical_coordinate.plot("interface_depth_rho", eta=0)
|
|
253
|
-
vertical_coordinate.plot("interface_depth_u", eta=0)
|
|
254
|
-
vertical_coordinate.plot("interface_depth_v", eta=0)
|
|
255
|
-
vertical_coordinate.plot("layer_depth_rho", xi=0)
|
|
256
|
-
vertical_coordinate.plot("layer_depth_u", xi=0)
|
|
257
|
-
vertical_coordinate.plot("layer_depth_v", xi=0)
|
|
258
|
-
vertical_coordinate.plot("interface_depth_rho", xi=0)
|
|
259
|
-
vertical_coordinate.plot("interface_depth_u", xi=0)
|
|
260
|
-
vertical_coordinate.plot("interface_depth_v", xi=0)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
def test_save(vertical_coordinate, tmp_path):
|
|
264
|
-
filepath = tmp_path / "vertical_coordinate.nc"
|
|
265
|
-
vertical_coordinate.save(filepath)
|
|
266
|
-
assert filepath.exists()
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
def test_roundtrip(vertical_coordinate):
|
|
270
|
-
"""Test that creating a vertical_coordinate, saving it to file, and re-opening it is the same as just creating it."""
|
|
271
|
-
|
|
272
|
-
# Create a temporary file
|
|
273
|
-
with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
|
|
274
|
-
filepath = tmpfile.name
|
|
275
|
-
|
|
276
|
-
try:
|
|
277
|
-
vertical_coordinate.save(filepath)
|
|
250
|
+
assert np.allclose(grid.ds["interface_depth_u"].values, expected_interface_depth_u)
|
|
251
|
+
assert np.allclose(grid.ds["interface_depth_v"].values, expected_interface_depth_v)
|
|
278
252
|
|
|
279
|
-
vertical_coordinate_from_file = VerticalCoordinate.from_file(filepath)
|
|
280
253
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
try:
|
|
295
|
-
vertical_coordinate.to_yaml(filepath)
|
|
296
|
-
|
|
297
|
-
vertical_coordinate_from_file = VerticalCoordinate.from_yaml(filepath)
|
|
298
|
-
|
|
299
|
-
assert vertical_coordinate == vertical_coordinate_from_file
|
|
300
|
-
|
|
301
|
-
finally:
|
|
302
|
-
os.remove(filepath)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
def test_from_yaml_missing_vertical_coordinate():
|
|
306
|
-
yaml_content = textwrap.dedent(
|
|
307
|
-
"""\
|
|
308
|
-
---
|
|
309
|
-
roms_tools_version: 0.0.0
|
|
310
|
-
---
|
|
311
|
-
Grid:
|
|
312
|
-
nx: 100
|
|
313
|
-
ny: 100
|
|
314
|
-
size_x: 1800
|
|
315
|
-
size_y: 2400
|
|
316
|
-
center_lon: -10
|
|
317
|
-
center_lat: 61
|
|
318
|
-
rot: -20
|
|
319
|
-
topography_source: ETOPO5
|
|
320
|
-
smooth_factor: 8
|
|
321
|
-
hmin: 5.0
|
|
322
|
-
rmax: 0.2
|
|
323
|
-
"""
|
|
254
|
+
def test_plot():
|
|
255
|
+
grid = Grid(
|
|
256
|
+
nx=2,
|
|
257
|
+
ny=2,
|
|
258
|
+
size_x=500,
|
|
259
|
+
size_y=1000,
|
|
260
|
+
center_lon=0,
|
|
261
|
+
center_lat=55,
|
|
262
|
+
rot=10,
|
|
263
|
+
N=3,
|
|
264
|
+
theta_s=5.0,
|
|
265
|
+
theta_b=2.0,
|
|
266
|
+
hc=250.0,
|
|
324
267
|
)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
268
|
+
grid.plot_vertical_coordinate("layer_depth_u", s=0)
|
|
269
|
+
grid.plot_vertical_coordinate("layer_depth_rho", s=-1)
|
|
270
|
+
grid.plot_vertical_coordinate("interface_depth_v", s=-1)
|
|
271
|
+
grid.plot_vertical_coordinate("layer_depth_rho", eta=0)
|
|
272
|
+
grid.plot_vertical_coordinate("layer_depth_u", eta=0)
|
|
273
|
+
grid.plot_vertical_coordinate("layer_depth_v", eta=0)
|
|
274
|
+
grid.plot_vertical_coordinate("interface_depth_rho", eta=0)
|
|
275
|
+
grid.plot_vertical_coordinate("interface_depth_u", eta=0)
|
|
276
|
+
grid.plot_vertical_coordinate("interface_depth_v", eta=0)
|
|
277
|
+
grid.plot_vertical_coordinate("layer_depth_rho", xi=0)
|
|
278
|
+
grid.plot_vertical_coordinate("layer_depth_u", xi=0)
|
|
279
|
+
grid.plot_vertical_coordinate("layer_depth_v", xi=0)
|
|
280
|
+
grid.plot_vertical_coordinate("interface_depth_rho", xi=0)
|
|
281
|
+
grid.plot_vertical_coordinate("interface_depth_u", xi=0)
|
|
282
|
+
grid.plot_vertical_coordinate("interface_depth_v", xi=0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: roms-tools
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Tools for running and analysing UCLA-ROMS simulations
|
|
5
5
|
Author-email: Nora Loose <nora.loose@gmail.com>, Thomas Nicholas <tom@cworthy.org>
|
|
6
6
|
License: Apache-2
|
|
@@ -31,8 +31,7 @@ Requires-Dist: gcm-filters
|
|
|
31
31
|
Requires-Dist: numba
|
|
32
32
|
|
|
33
33
|
# ROMS-Tools
|
|
34
|
-
|
|
35
|
-
[](https://badge.fury.io/py/roms-tools)
|
|
34
|
+
[](https://pypi.org/project/roms-tools/)
|
|
36
35
|
[](https://codecov.io/gh/CWorthy-ocean/roms-tools)
|
|
37
36
|
[](https://roms-tools.readthedocs.io/en/latest/?badge=latest)
|
|
38
37
|

|