roms-tools 0.20__py3-none-any.whl → 1.0.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.
- ci/environment.yml +1 -0
- roms_tools/__init__.py +1 -2
- roms_tools/_version.py +1 -1
- roms_tools/setup/boundary_forcing.py +390 -344
- roms_tools/setup/datasets.py +838 -141
- roms_tools/setup/download.py +118 -0
- roms_tools/setup/initial_conditions.py +195 -166
- roms_tools/setup/mixins.py +395 -0
- roms_tools/setup/surface_forcing.py +596 -0
- roms_tools/setup/tides.py +76 -174
- roms_tools/setup/topography.py +1 -1
- roms_tools/setup/utils.py +190 -0
- roms_tools/tests/test_boundary_forcing.py +445 -71
- roms_tools/tests/test_datasets.py +73 -9
- roms_tools/tests/test_initial_conditions.py +252 -32
- roms_tools/tests/test_surface_forcing.py +2622 -0
- roms_tools/tests/test_tides.py +13 -14
- roms_tools/tests/test_utils.py +16 -0
- {roms_tools-0.20.dist-info → roms_tools-1.0.0.dist-info}/METADATA +7 -3
- roms_tools-1.0.0.dist-info/RECORD +31 -0
- {roms_tools-0.20.dist-info → roms_tools-1.0.0.dist-info}/WHEEL +1 -1
- roms_tools/setup/atmospheric_forcing.py +0 -935
- roms_tools/tests/test_atmospheric_forcing.py +0 -1645
- roms_tools-0.20.dist-info/RECORD +0 -28
- {roms_tools-0.20.dist-info → roms_tools-1.0.0.dist-info}/LICENSE +0 -0
- {roms_tools-0.20.dist-info → roms_tools-1.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
from roms_tools import BoundaryForcing, Grid, VerticalCoordinate
|
|
4
|
-
import xarray as xr
|
|
5
4
|
import numpy as np
|
|
6
5
|
import tempfile
|
|
7
6
|
import os
|
|
8
7
|
import textwrap
|
|
9
|
-
from roms_tools.setup.
|
|
8
|
+
from roms_tools.setup.download import download_test_data
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
@pytest.fixture
|
|
@@ -50,41 +49,81 @@ def boundary_forcing(example_grid, example_vertical_coordinate):
|
|
|
50
49
|
vertical_coordinate=example_vertical_coordinate,
|
|
51
50
|
start_time=datetime(2021, 6, 29),
|
|
52
51
|
end_time=datetime(2021, 6, 30),
|
|
53
|
-
|
|
54
|
-
filename=fname,
|
|
52
|
+
physics_source={"name": "GLORYS", "path": fname},
|
|
55
53
|
)
|
|
56
54
|
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
@pytest.fixture
|
|
57
|
+
def boundary_forcing_with_bgc_from_climatology(
|
|
58
|
+
example_grid, example_vertical_coordinate
|
|
59
|
+
):
|
|
60
|
+
"""
|
|
61
|
+
Fixture for creating a BoundaryForcing object.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
fname = download_test_data("GLORYS_test_data.nc")
|
|
65
|
+
fname_bgc = download_test_data("CESM_regional_test_data_climatology.nc")
|
|
66
|
+
|
|
67
|
+
return BoundaryForcing(
|
|
68
|
+
grid=example_grid,
|
|
69
|
+
vertical_coordinate=example_vertical_coordinate,
|
|
70
|
+
start_time=datetime(2021, 6, 29),
|
|
71
|
+
end_time=datetime(2021, 6, 30),
|
|
72
|
+
physics_source={"name": "GLORYS", "path": fname},
|
|
73
|
+
bgc_source={"path": fname_bgc, "name": "CESM_REGRIDDED", "climatology": True},
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@pytest.mark.parametrize(
|
|
78
|
+
"bdry_forcing_fixture",
|
|
79
|
+
[
|
|
80
|
+
"boundary_forcing",
|
|
81
|
+
"boundary_forcing_with_bgc_from_climatology",
|
|
82
|
+
],
|
|
83
|
+
)
|
|
84
|
+
def test_boundary_forcing_creation(bdry_forcing_fixture, request):
|
|
59
85
|
"""
|
|
60
86
|
Test the creation of the BoundaryForcing object.
|
|
61
87
|
"""
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
assert
|
|
88
|
+
|
|
89
|
+
bdry_forcing = request.getfixturevalue(bdry_forcing_fixture)
|
|
90
|
+
|
|
91
|
+
assert bdry_forcing.start_time == datetime(2021, 6, 29)
|
|
92
|
+
assert bdry_forcing.end_time == datetime(2021, 6, 30)
|
|
93
|
+
|
|
94
|
+
assert bdry_forcing.ds["physics"].physics_source == "GLORYS"
|
|
95
|
+
for direction in ["south", "east", "north", "west"]:
|
|
96
|
+
assert f"temp_{direction}" in bdry_forcing.ds["physics"]
|
|
97
|
+
assert f"salt_{direction}" in bdry_forcing.ds["physics"]
|
|
98
|
+
assert f"u_{direction}" in bdry_forcing.ds["physics"]
|
|
99
|
+
assert f"v_{direction}" in bdry_forcing.ds["physics"]
|
|
100
|
+
assert f"zeta_{direction}" in bdry_forcing.ds["physics"]
|
|
66
101
|
|
|
67
102
|
|
|
68
|
-
def
|
|
103
|
+
def test_boundary_forcing_creation_with_bgc(boundary_forcing_with_bgc_from_climatology):
|
|
69
104
|
"""
|
|
70
|
-
Test the
|
|
105
|
+
Test the creation of the BoundaryForcing object.
|
|
71
106
|
"""
|
|
72
|
-
|
|
107
|
+
|
|
108
|
+
assert (
|
|
109
|
+
boundary_forcing_with_bgc_from_climatology.ds["bgc"].bgc_source
|
|
110
|
+
== "CESM_REGRIDDED"
|
|
111
|
+
)
|
|
73
112
|
for direction in ["south", "east", "north", "west"]:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
113
|
+
for var in ["ALK", "PO4"]:
|
|
114
|
+
assert (
|
|
115
|
+
f"{var}_{direction}"
|
|
116
|
+
in boundary_forcing_with_bgc_from_climatology.ds["bgc"]
|
|
117
|
+
)
|
|
79
118
|
|
|
80
119
|
|
|
81
|
-
def test_boundary_forcing_data_consistency_plot_save(
|
|
120
|
+
def test_boundary_forcing_data_consistency_plot_save(
|
|
121
|
+
boundary_forcing_with_bgc_from_climatology,
|
|
122
|
+
):
|
|
82
123
|
"""
|
|
83
124
|
Test that the data within the BoundaryForcing object remains consistent.
|
|
84
125
|
Also test plot and save methods in the same test since we dask arrays are already computed.
|
|
85
126
|
"""
|
|
86
|
-
boundary_forcing.ds.load()
|
|
87
|
-
|
|
88
127
|
# Define the expected data
|
|
89
128
|
expected_zeta_south = np.array(
|
|
90
129
|
[[-0.30468762, -0.29416865, -0.30391693, -0.32985148]], dtype=np.float32
|
|
@@ -216,83 +255,418 @@ def test_boundary_forcing_data_consistency_plot_save(boundary_forcing):
|
|
|
216
255
|
dtype=np.float32,
|
|
217
256
|
)
|
|
218
257
|
|
|
219
|
-
expected_ubar_south = np.array([[0.0
|
|
258
|
+
expected_ubar_south = np.array([[0.0, 0.0, 0.0]], dtype=np.float32)
|
|
220
259
|
expected_ubar_east = np.array(
|
|
221
|
-
[[0.0
|
|
260
|
+
[[0.0, 0.0, 0.04028399, 0.02812303]], dtype=np.float32
|
|
222
261
|
)
|
|
223
262
|
expected_ubar_north = np.array(
|
|
224
|
-
[[0.03866891
|
|
263
|
+
[[0.03866891, 0.04446249, 0.02812303]], dtype=np.float32
|
|
225
264
|
)
|
|
226
|
-
expected_ubar_west = np.array([[0.0
|
|
265
|
+
expected_ubar_west = np.array([[0.0, 0.0, 0.0, 0.03866891]], dtype=np.float32)
|
|
227
266
|
|
|
228
|
-
expected_vbar_south = np.array([[0.0
|
|
229
|
-
expected_vbar_east = np.array([[0.0
|
|
267
|
+
expected_vbar_south = np.array([[0.0, 0.0, 0.0, 0.0]], dtype=np.float32)
|
|
268
|
+
expected_vbar_east = np.array([[0.0, 0.0, -0.09326097]], dtype=np.float32)
|
|
230
269
|
expected_vbar_north = np.array(
|
|
231
|
-
[[-0.01189703
|
|
270
|
+
[[-0.01189703, 0.0, 0.02102064, -0.09326097]], dtype=np.float32
|
|
271
|
+
)
|
|
272
|
+
expected_vbar_west = np.array([[0.0, 0.0, -0.01189703]], dtype=np.float32)
|
|
273
|
+
|
|
274
|
+
expected_alk_south = np.array(
|
|
275
|
+
[
|
|
276
|
+
[
|
|
277
|
+
[2352.1636, 2352.128, 2352.091],
|
|
278
|
+
[2333.1094, 2332.9932, 2332.8738],
|
|
279
|
+
[2308.618, 2308.4705, 2308.3032],
|
|
280
|
+
[2286.2327, 2286.0442, 2285.8623],
|
|
281
|
+
],
|
|
282
|
+
[
|
|
283
|
+
[2354.7297, 2354.6863, 2354.6414],
|
|
284
|
+
[2337.391, 2337.259, 2337.1223],
|
|
285
|
+
[2314.0232, 2313.8638, 2313.6616],
|
|
286
|
+
[2294.0876, 2293.8918, 2293.6626],
|
|
287
|
+
],
|
|
288
|
+
[
|
|
289
|
+
[2355.02, 2354.9158, 2354.817],
|
|
290
|
+
[2336.321, 2336.117, 2335.9214],
|
|
291
|
+
[2312.7905, 2312.4849, 2312.2444],
|
|
292
|
+
[2292.2637, 2291.8752, 2291.6702],
|
|
293
|
+
],
|
|
294
|
+
[
|
|
295
|
+
[2355.2583, 2355.052, 2354.9163],
|
|
296
|
+
[2334.3098, 2333.913, 2333.651],
|
|
297
|
+
[2309.5273, 2308.292, 2307.8772],
|
|
298
|
+
[2287.4226, 2285.5466, 2285.0479],
|
|
299
|
+
],
|
|
300
|
+
[
|
|
301
|
+
[2354.1216, 2353.7737, 2353.6316],
|
|
302
|
+
[2330.6604, 2329.948, 2329.6023],
|
|
303
|
+
[2304.88, 2302.105, 2301.4136],
|
|
304
|
+
[2280.6, 2276.278, 2275.2761],
|
|
305
|
+
],
|
|
306
|
+
[
|
|
307
|
+
[2346.881, 2345.7993, 2345.4675],
|
|
308
|
+
[2322.218, 2320.3225, 2319.691],
|
|
309
|
+
[2301.2046, 2291.6438, 2290.308],
|
|
310
|
+
[2279.729, 2265.0488, 2263.0654],
|
|
311
|
+
],
|
|
312
|
+
[
|
|
313
|
+
[2336.2632, 2335.273, 2334.9324],
|
|
314
|
+
[2312.938, 2310.7412, 2310.055],
|
|
315
|
+
[2293.6711, 2279.314, 2277.593],
|
|
316
|
+
[2272.6418, 2250.8848, 2248.0718],
|
|
317
|
+
],
|
|
318
|
+
[
|
|
319
|
+
[2333.8801, 2333.265, 2333.0667],
|
|
320
|
+
[2311.3232, 2309.5337, 2309.034],
|
|
321
|
+
[2289.1548, 2276.1438, 2274.885],
|
|
322
|
+
[2266.9172, 2246.1714, 2244.1096],
|
|
323
|
+
],
|
|
324
|
+
[
|
|
325
|
+
[2336.8193, 2336.5115, 2336.4402],
|
|
326
|
+
[2314.2544, 2313.1343, 2312.9004],
|
|
327
|
+
[2288.887, 2280.0654, 2279.546],
|
|
328
|
+
[2263.7944, 2249.8926, 2249.0842],
|
|
329
|
+
],
|
|
330
|
+
[
|
|
331
|
+
[2341.18, 2341.0679, 2341.025],
|
|
332
|
+
[2317.8801, 2317.4556, 2317.3325],
|
|
333
|
+
[2289.4714, 2286.2214, 2285.9263],
|
|
334
|
+
[2262.6213, 2257.4502, 2256.9663],
|
|
335
|
+
],
|
|
336
|
+
[
|
|
337
|
+
[2344.9026, 2344.86, 2344.8218],
|
|
338
|
+
[2323.6404, 2323.5337, 2323.442],
|
|
339
|
+
[2297.1284, 2296.8164, 2296.6846],
|
|
340
|
+
[2273.7996, 2273.2507, 2273.0938],
|
|
341
|
+
],
|
|
342
|
+
[
|
|
343
|
+
[2349.1636, 2349.1338, 2349.1035],
|
|
344
|
+
[2329.3665, 2329.2893, 2329.2102],
|
|
345
|
+
[2304.1536, 2304.0178, 2303.9006],
|
|
346
|
+
[2281.6301, 2281.4062, 2281.269],
|
|
347
|
+
],
|
|
348
|
+
],
|
|
349
|
+
dtype=np.float32,
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
expected_alk_east = np.array(
|
|
353
|
+
[
|
|
354
|
+
[
|
|
355
|
+
[2286.2327, 2286.0442, 2285.8623],
|
|
356
|
+
[2268.2373, 2268.162, 2268.0366],
|
|
357
|
+
[2297.2825, 2296.5747, 2296.2695],
|
|
358
|
+
[2349.247, 2349.1697, 2349.0938],
|
|
359
|
+
],
|
|
360
|
+
[
|
|
361
|
+
[2294.0876, 2293.8918, 2293.6626],
|
|
362
|
+
[2272.6245, 2272.5269, 2272.3384],
|
|
363
|
+
[2301.072, 2300.6504, 2300.4255],
|
|
364
|
+
[2352.814, 2352.756, 2352.6907],
|
|
365
|
+
],
|
|
366
|
+
[
|
|
367
|
+
[2292.2637, 2291.8752, 2291.6702],
|
|
368
|
+
[2272.901, 2272.7153, 2272.5413],
|
|
369
|
+
[2304.492, 2303.8516, 2303.6313],
|
|
370
|
+
[2352.8616, 2352.795, 2352.7444],
|
|
371
|
+
],
|
|
372
|
+
[
|
|
373
|
+
[2287.4226, 2285.5466, 2285.0479],
|
|
374
|
+
[2269.8926, 2269.2112, 2268.8284],
|
|
375
|
+
[2310.2466, 2307.2576, 2306.0806],
|
|
376
|
+
[2350.9084, 2350.3499, 2350.0247],
|
|
377
|
+
],
|
|
378
|
+
[
|
|
379
|
+
[2280.6, 2276.278, 2275.2761],
|
|
380
|
+
[2266.4937, 2264.7148, 2263.8596],
|
|
381
|
+
[2309.5537, 2297.2288, 2293.6697],
|
|
382
|
+
[2350.1707, 2348.5422, 2347.7415],
|
|
383
|
+
],
|
|
384
|
+
[
|
|
385
|
+
[2279.729, 2265.0488, 2263.0654],
|
|
386
|
+
[2263.0278, 2254.806, 2253.1594],
|
|
387
|
+
[2311.0305, 2290.098, 2284.9631],
|
|
388
|
+
[2350.3872, 2345.0693, 2342.4902],
|
|
389
|
+
],
|
|
390
|
+
[
|
|
391
|
+
[2272.6418, 2250.8848, 2248.0718],
|
|
392
|
+
[2256.4866, 2239.6753, 2237.9412],
|
|
393
|
+
[2309.7383, 2284.9133, 2277.729],
|
|
394
|
+
[2349.7207, 2339.6501, 2335.4924],
|
|
395
|
+
],
|
|
396
|
+
[
|
|
397
|
+
[2266.9172, 2246.1714, 2244.1096],
|
|
398
|
+
[2249.1013, 2234.224, 2232.722],
|
|
399
|
+
[2307.639, 2275.4429, 2266.299],
|
|
400
|
+
[2347.7605, 2330.1702, 2325.427],
|
|
401
|
+
],
|
|
402
|
+
[
|
|
403
|
+
[2263.7944, 2249.8926, 2249.0842],
|
|
404
|
+
[2246.2002, 2236.0933, 2235.4578],
|
|
405
|
+
[2301.0461, 2269.4448, 2263.889],
|
|
406
|
+
[2338.5127, 2321.7393, 2316.971],
|
|
407
|
+
],
|
|
408
|
+
[
|
|
409
|
+
[2262.6213, 2257.4502, 2256.9663],
|
|
410
|
+
[2244.3662, 2241.8052, 2241.589],
|
|
411
|
+
[2292.1316, 2274.763, 2272.2124],
|
|
412
|
+
[2331.162, 2322.5522, 2320.8901],
|
|
413
|
+
],
|
|
414
|
+
[
|
|
415
|
+
[2273.7996, 2273.2507, 2273.0938],
|
|
416
|
+
[2254.6848, 2254.4407, 2254.3308],
|
|
417
|
+
[2290.5637, 2286.885, 2286.088],
|
|
418
|
+
[2333.583, 2332.7646, 2332.3955],
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
[2281.6301, 2281.4062, 2281.269],
|
|
422
|
+
[2262.4211, 2262.3313, 2262.2532],
|
|
423
|
+
[2296.095, 2293.6157, 2293.1213],
|
|
424
|
+
[2340.852, 2340.6072, 2340.4978],
|
|
425
|
+
],
|
|
426
|
+
],
|
|
427
|
+
dtype=np.float32,
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
expected_alk_north = np.array(
|
|
431
|
+
[
|
|
432
|
+
[
|
|
433
|
+
[2376.7993, 2376.7961, 2376.7932],
|
|
434
|
+
[2375.0688, 2375.0647, 2375.0596],
|
|
435
|
+
[2372.2307, 2372.2188, 2372.201],
|
|
436
|
+
[2349.247, 2349.1697, 2349.0938],
|
|
437
|
+
],
|
|
438
|
+
[
|
|
439
|
+
[2376.757, 2376.7537, 2376.7478],
|
|
440
|
+
[2374.8325, 2374.8286, 2374.825],
|
|
441
|
+
[2371.8342, 2371.8257, 2371.814],
|
|
442
|
+
[2352.814, 2352.756, 2352.6907],
|
|
443
|
+
],
|
|
444
|
+
[
|
|
445
|
+
[2377.0188, 2377.0137, 2377.0073],
|
|
446
|
+
[2374.9753, 2374.9707, 2374.9666],
|
|
447
|
+
[2371.7104, 2371.7085, 2371.707],
|
|
448
|
+
[2352.8616, 2352.795, 2352.7444],
|
|
449
|
+
],
|
|
450
|
+
[
|
|
451
|
+
[2377.3914, 2377.383, 2377.3792],
|
|
452
|
+
[2375.5757, 2375.5718, 2375.57],
|
|
453
|
+
[2371.869, 2371.8706, 2371.8743],
|
|
454
|
+
[2350.9084, 2350.3499, 2350.0247],
|
|
455
|
+
],
|
|
456
|
+
[
|
|
457
|
+
[2378.4722, 2378.5, 2378.5017],
|
|
458
|
+
[2377.151, 2377.2292, 2377.2666],
|
|
459
|
+
[2373.7805, 2373.9, 2374.0066],
|
|
460
|
+
[2350.1707, 2348.5422, 2347.7415],
|
|
461
|
+
],
|
|
462
|
+
[
|
|
463
|
+
[2381.3555, 2383.3838, 2383.9692],
|
|
464
|
+
[2380.8108, 2382.6125, 2383.3374],
|
|
465
|
+
[2378.7131, 2379.7717, 2380.4094],
|
|
466
|
+
[2350.3872, 2345.0693, 2342.4902],
|
|
467
|
+
],
|
|
468
|
+
[
|
|
469
|
+
[2388.7502, 2389.4453, 2389.6758],
|
|
470
|
+
[2387.0815, 2388.0613, 2388.3323],
|
|
471
|
+
[2381.9631, 2383.4429, 2383.521],
|
|
472
|
+
[2349.7207, 2339.6501, 2335.4924],
|
|
473
|
+
],
|
|
474
|
+
[
|
|
475
|
+
[2386.29, 2385.9524, 2385.863],
|
|
476
|
+
[2383.9194, 2383.5654, 2383.4429],
|
|
477
|
+
[2380.237, 2377.2883, 2376.6057],
|
|
478
|
+
[2347.7605, 2330.1702, 2325.427],
|
|
479
|
+
],
|
|
480
|
+
[
|
|
481
|
+
[2375.1409, 2373.7124, 2373.2695],
|
|
482
|
+
[2370.7205, 2368.2014, 2367.7415],
|
|
483
|
+
[2371.8071, 2365.7, 2365.1226],
|
|
484
|
+
[2338.5127, 2321.7393, 2316.971],
|
|
485
|
+
],
|
|
486
|
+
[
|
|
487
|
+
[2371.951, 2371.8308, 2371.786],
|
|
488
|
+
[2365.2358, 2364.598, 2364.4639],
|
|
489
|
+
[2365.8464, 2362.7102, 2362.5464],
|
|
490
|
+
[2331.162, 2322.5522, 2320.8901],
|
|
491
|
+
],
|
|
492
|
+
[
|
|
493
|
+
[2373.2239, 2373.2004, 2373.1711],
|
|
494
|
+
[2370.007, 2369.9714, 2369.9507],
|
|
495
|
+
[2367.3286, 2367.2654, 2367.2217],
|
|
496
|
+
[2333.583, 2332.7646, 2332.3955],
|
|
497
|
+
],
|
|
498
|
+
[
|
|
499
|
+
[2374.99, 2374.9817, 2374.9717],
|
|
500
|
+
[2373.9058, 2373.8901, 2373.8748],
|
|
501
|
+
[2370.9688, 2370.9421, 2370.907],
|
|
502
|
+
[2340.852, 2340.6072, 2340.4978],
|
|
503
|
+
],
|
|
504
|
+
],
|
|
505
|
+
dtype=np.float32,
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
expected_alk_west = np.array(
|
|
509
|
+
[
|
|
510
|
+
[
|
|
511
|
+
[2352.1636, 2352.128, 2352.091],
|
|
512
|
+
[2335.311, 2335.1162, 2334.924],
|
|
513
|
+
[2362.5132, 2362.5088, 2362.4663],
|
|
514
|
+
[2376.7993, 2376.7961, 2376.7932],
|
|
515
|
+
],
|
|
516
|
+
[
|
|
517
|
+
[2354.7297, 2354.6863, 2354.6414],
|
|
518
|
+
[2335.165, 2334.9695, 2334.78],
|
|
519
|
+
[2363.018, 2363.0068, 2362.965],
|
|
520
|
+
[2376.757, 2376.7537, 2376.7478],
|
|
521
|
+
],
|
|
522
|
+
[
|
|
523
|
+
[2355.02, 2354.9158, 2354.817],
|
|
524
|
+
[2334.8015, 2334.5276, 2334.272],
|
|
525
|
+
[2365.7913, 2365.8025, 2365.7432],
|
|
526
|
+
[2377.0188, 2377.0137, 2377.0073],
|
|
527
|
+
],
|
|
528
|
+
[
|
|
529
|
+
[2355.2583, 2355.052, 2354.9163],
|
|
530
|
+
[2335.5789, 2335.267, 2335.0227],
|
|
531
|
+
[2370.7808, 2370.754, 2370.6836],
|
|
532
|
+
[2377.3914, 2377.383, 2377.3792],
|
|
533
|
+
],
|
|
534
|
+
[
|
|
535
|
+
[2354.1216, 2353.7737, 2353.6316],
|
|
536
|
+
[2335.7122, 2335.1372, 2334.8125],
|
|
537
|
+
[2375.5793, 2375.3132, 2375.1387],
|
|
538
|
+
[2378.4722, 2378.5, 2378.5017],
|
|
539
|
+
],
|
|
540
|
+
[
|
|
541
|
+
[2346.881, 2345.7993, 2345.4675],
|
|
542
|
+
[2332.2158, 2331.5295, 2331.2346],
|
|
543
|
+
[2378.4954, 2376.4001, 2375.9187],
|
|
544
|
+
[2381.3555, 2383.3838, 2383.9692],
|
|
545
|
+
],
|
|
546
|
+
[
|
|
547
|
+
[2336.2632, 2335.273, 2334.9324],
|
|
548
|
+
[2328.7188, 2327.8726, 2327.576],
|
|
549
|
+
[2374.763, 2370.0576, 2369.491],
|
|
550
|
+
[2388.7502, 2389.4453, 2389.6758],
|
|
551
|
+
],
|
|
552
|
+
[
|
|
553
|
+
[2333.8801, 2333.265, 2333.0667],
|
|
554
|
+
[2326.699, 2326.0037, 2325.771],
|
|
555
|
+
[2356.8801, 2352.0618, 2351.4526],
|
|
556
|
+
[2386.29, 2385.9524, 2385.863],
|
|
557
|
+
],
|
|
558
|
+
[
|
|
559
|
+
[2336.8193, 2336.5115, 2336.4402],
|
|
560
|
+
[2325.9893, 2325.512, 2325.2942],
|
|
561
|
+
[2346.735, 2344.9722, 2344.6653],
|
|
562
|
+
[2375.1409, 2373.7124, 2373.2695],
|
|
563
|
+
],
|
|
564
|
+
[
|
|
565
|
+
[2341.18, 2341.0679, 2341.025],
|
|
566
|
+
[2328.2231, 2327.9817, 2327.8281],
|
|
567
|
+
[2352.159, 2351.6226, 2351.4314],
|
|
568
|
+
[2371.951, 2371.8308, 2371.786],
|
|
569
|
+
],
|
|
570
|
+
[
|
|
571
|
+
[2344.9026, 2344.86, 2344.8218],
|
|
572
|
+
[2331.0703, 2330.9097, 2330.7537],
|
|
573
|
+
[2356.0095, 2355.9424, 2355.8538],
|
|
574
|
+
[2373.2239, 2373.2004, 2373.1711],
|
|
575
|
+
],
|
|
576
|
+
[
|
|
577
|
+
[2349.1636, 2349.1338, 2349.1035],
|
|
578
|
+
[2334.3328, 2334.043, 2333.749],
|
|
579
|
+
[2359.3823, 2359.3276, 2359.2634],
|
|
580
|
+
[2374.99, 2374.9817, 2374.9717],
|
|
581
|
+
],
|
|
582
|
+
],
|
|
583
|
+
dtype=np.float32,
|
|
232
584
|
)
|
|
233
|
-
|
|
585
|
+
|
|
586
|
+
ds = boundary_forcing_with_bgc_from_climatology.ds["physics"]
|
|
587
|
+
ds_bgc = boundary_forcing_with_bgc_from_climatology.ds["bgc"]
|
|
234
588
|
|
|
235
589
|
# Check the values in the dataset
|
|
236
|
-
assert np.allclose(
|
|
237
|
-
assert np.allclose(
|
|
238
|
-
assert np.allclose(
|
|
239
|
-
assert np.allclose(
|
|
240
|
-
assert np.allclose(
|
|
241
|
-
assert np.allclose(
|
|
242
|
-
assert np.allclose(
|
|
243
|
-
assert np.allclose(
|
|
244
|
-
assert np.allclose(
|
|
245
|
-
assert np.allclose(
|
|
246
|
-
assert np.allclose(
|
|
247
|
-
assert np.allclose(
|
|
248
|
-
assert np.allclose(
|
|
249
|
-
assert np.allclose(
|
|
250
|
-
assert np.allclose(
|
|
251
|
-
assert np.allclose(
|
|
252
|
-
assert np.allclose(
|
|
253
|
-
assert np.allclose(
|
|
254
|
-
assert np.allclose(
|
|
255
|
-
assert np.allclose(
|
|
256
|
-
assert np.allclose(
|
|
257
|
-
assert np.allclose(
|
|
258
|
-
assert np.allclose(
|
|
259
|
-
assert np.allclose(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
590
|
+
assert np.allclose(ds["zeta_south"].values, expected_zeta_south)
|
|
591
|
+
assert np.allclose(ds["zeta_east"].values, expected_zeta_east)
|
|
592
|
+
assert np.allclose(ds["zeta_north"].values, expected_zeta_north)
|
|
593
|
+
assert np.allclose(ds["zeta_west"].values, expected_zeta_west)
|
|
594
|
+
assert np.allclose(ds["temp_south"].values, expected_temp_south)
|
|
595
|
+
assert np.allclose(ds["temp_east"].values, expected_temp_east)
|
|
596
|
+
assert np.allclose(ds["temp_north"].values, expected_temp_north)
|
|
597
|
+
assert np.allclose(ds["temp_west"].values, expected_temp_west)
|
|
598
|
+
assert np.allclose(ds["u_south"].values, expected_u_south)
|
|
599
|
+
assert np.allclose(ds["u_east"].values, expected_u_east)
|
|
600
|
+
assert np.allclose(ds["u_north"].values, expected_u_north)
|
|
601
|
+
assert np.allclose(ds["u_west"].values, expected_u_west)
|
|
602
|
+
assert np.allclose(ds["v_south"].values, expected_v_south)
|
|
603
|
+
assert np.allclose(ds["v_east"].values, expected_v_east)
|
|
604
|
+
assert np.allclose(ds["v_north"].values, expected_v_north)
|
|
605
|
+
assert np.allclose(ds["v_west"].values, expected_v_west)
|
|
606
|
+
assert np.allclose(ds["ubar_south"].values, expected_ubar_south)
|
|
607
|
+
assert np.allclose(ds["ubar_east"].values, expected_ubar_east)
|
|
608
|
+
assert np.allclose(ds["ubar_north"].values, expected_ubar_north)
|
|
609
|
+
assert np.allclose(ds["ubar_west"].values, expected_ubar_west)
|
|
610
|
+
assert np.allclose(ds["vbar_south"].values, expected_vbar_south)
|
|
611
|
+
assert np.allclose(ds["vbar_east"].values, expected_vbar_east)
|
|
612
|
+
assert np.allclose(ds["vbar_north"].values, expected_vbar_north)
|
|
613
|
+
assert np.allclose(ds["vbar_west"].values, expected_vbar_west)
|
|
614
|
+
assert np.allclose(ds_bgc["ALK_south"].values, expected_alk_south)
|
|
615
|
+
assert np.allclose(ds_bgc["ALK_east"].values, expected_alk_east)
|
|
616
|
+
assert np.allclose(ds_bgc["ALK_north"].values, expected_alk_north)
|
|
617
|
+
assert np.allclose(ds_bgc["ALK_west"].values, expected_alk_west)
|
|
618
|
+
|
|
619
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="temp_south")
|
|
620
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="temp_east")
|
|
621
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="temp_north")
|
|
622
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="temp_west")
|
|
623
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="zeta_south")
|
|
624
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="zeta_east")
|
|
625
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="zeta_north")
|
|
626
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="zeta_west")
|
|
627
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="ALK_south")
|
|
628
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="ALK_east")
|
|
629
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="ALK_north")
|
|
630
|
+
boundary_forcing_with_bgc_from_climatology.plot(varname="ALK_west")
|
|
269
631
|
|
|
270
632
|
# Create a temporary file
|
|
271
|
-
with tempfile.NamedTemporaryFile(delete=
|
|
633
|
+
with tempfile.NamedTemporaryFile(delete=True) as tmpfile:
|
|
272
634
|
filepath = tmpfile.name
|
|
273
635
|
|
|
274
|
-
|
|
275
|
-
|
|
636
|
+
boundary_forcing_with_bgc_from_climatology.save(filepath)
|
|
637
|
+
physics_filepath = filepath + "_physics_20210629-29.nc"
|
|
638
|
+
bgc_filepath = filepath + "_bgc_clim.nc"
|
|
276
639
|
|
|
277
640
|
try:
|
|
278
|
-
assert os.path.exists(
|
|
641
|
+
assert os.path.exists(physics_filepath)
|
|
642
|
+
assert os.path.exists(bgc_filepath)
|
|
279
643
|
finally:
|
|
280
|
-
os.remove(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
644
|
+
os.remove(physics_filepath)
|
|
645
|
+
os.remove(bgc_filepath)
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
@pytest.mark.parametrize(
|
|
649
|
+
"bdry_forcing_fixture",
|
|
650
|
+
[
|
|
651
|
+
"boundary_forcing",
|
|
652
|
+
"boundary_forcing_with_bgc_from_climatology",
|
|
653
|
+
],
|
|
654
|
+
)
|
|
655
|
+
def test_roundtrip_yaml(bdry_forcing_fixture, request):
|
|
284
656
|
"""Test that creating a BoundaryForcing object, saving its parameters to yaml file, and re-opening yaml file creates the same object."""
|
|
285
657
|
|
|
658
|
+
bdry_forcing = request.getfixturevalue(bdry_forcing_fixture)
|
|
659
|
+
|
|
286
660
|
# Create a temporary file
|
|
287
661
|
with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
|
|
288
662
|
filepath = tmpfile.name
|
|
289
663
|
|
|
290
664
|
try:
|
|
291
|
-
|
|
665
|
+
bdry_forcing.to_yaml(filepath)
|
|
292
666
|
|
|
293
667
|
boundary_forcing_from_file = BoundaryForcing.from_yaml(filepath)
|
|
294
668
|
|
|
295
|
-
assert
|
|
669
|
+
assert bdry_forcing == boundary_forcing_from_file
|
|
296
670
|
|
|
297
671
|
finally:
|
|
298
672
|
os.remove(filepath)
|