roms-tools 1.4.1__py3-none-any.whl → 1.4.2__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/_version.py +1 -1
- roms_tools/setup/boundary_forcing.py +77 -70
- roms_tools/setup/datasets.py +38 -59
- roms_tools/setup/download.py +3 -6
- roms_tools/setup/fill.py +8 -16
- roms_tools/setup/grid.py +74 -113
- roms_tools/setup/initial_conditions.py +43 -36
- roms_tools/setup/mixins.py +10 -14
- roms_tools/setup/surface_forcing.py +35 -33
- roms_tools/setup/tides.py +37 -41
- roms_tools/setup/topography.py +9 -17
- roms_tools/setup/utils.py +19 -40
- roms_tools/setup/vertical_coordinate.py +4 -6
- roms_tools/tests/test_setup/test_boundary_forcing.py +6 -13
- roms_tools/tests/test_setup/test_data/grid.zarr/.zattrs +2 -2
- roms_tools/tests/test_setup/test_data/grid.zarr/.zmetadata +2 -62
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zattrs +2 -2
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/.zmetadata +2 -62
- roms_tools/tests/test_setup/test_datasets.py +8 -18
- roms_tools/tests/test_setup/test_grid.py +9 -9
- roms_tools/tests/test_setup/test_initial_conditions.py +4 -7
- roms_tools/tests/test_setup/test_surface_forcing.py +56 -56
- roms_tools/tests/test_setup/test_tides.py +6 -10
- roms_tools/tests/test_setup/test_topography.py +2 -4
- roms_tools/tests/test_setup/test_vertical_coordinate.py +2 -6
- roms_tools/tests/test_utils.py +30 -30
- roms_tools/utils.py +6 -7
- {roms_tools-1.4.1.dist-info → roms_tools-1.4.2.dist-info}/METADATA +1 -1
- {roms_tools-1.4.1.dist-info → roms_tools-1.4.2.dist-info}/RECORD +32 -44
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/.zarray +0 -22
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/.zattrs +0 -8
- roms_tools/tests/test_setup/test_data/grid.zarr/lat_psi/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/.zarray +0 -22
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/.zattrs +0 -8
- roms_tools/tests/test_setup/test_data/grid.zarr/lon_psi/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/.zarray +0 -22
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/.zattrs +0 -8
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lat_psi/0.0 +0 -0
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/.zarray +0 -22
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/.zattrs +0 -8
- roms_tools/tests/test_setup/test_data/grid_that_straddles_dateline.zarr/lon_psi/0.0 +0 -0
- {roms_tools-1.4.1.dist-info → roms_tools-1.4.2.dist-info}/LICENSE +0 -0
- {roms_tools-1.4.1.dist-info → roms_tools-1.4.2.dist-info}/WHEEL +0 -0
- {roms_tools-1.4.1.dist-info → roms_tools-1.4.2.dist-info}/top_level.txt +0 -0
|
@@ -8,9 +8,7 @@ from pathlib import Path
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def test_boundary_forcing_creation(boundary_forcing):
|
|
11
|
-
"""
|
|
12
|
-
Test the creation of the BoundaryForcing object.
|
|
13
|
-
"""
|
|
11
|
+
"""Test the creation of the BoundaryForcing object."""
|
|
14
12
|
|
|
15
13
|
fname = download_test_data("GLORYS_coarse_test_data.nc")
|
|
16
14
|
|
|
@@ -43,9 +41,7 @@ def test_boundary_forcing_creation(boundary_forcing):
|
|
|
43
41
|
|
|
44
42
|
|
|
45
43
|
def test_boundary_forcing_creation_with_bgc(bgc_boundary_forcing_from_climatology):
|
|
46
|
-
"""
|
|
47
|
-
Test the creation of the BoundaryForcing object.
|
|
48
|
-
"""
|
|
44
|
+
"""Test the creation of the BoundaryForcing object."""
|
|
49
45
|
|
|
50
46
|
fname_bgc = download_test_data("CESM_regional_coarse_test_data_climatology.nc")
|
|
51
47
|
|
|
@@ -80,9 +76,7 @@ def test_boundary_forcing_creation_with_bgc(bgc_boundary_forcing_from_climatolog
|
|
|
80
76
|
|
|
81
77
|
|
|
82
78
|
def test_boundary_forcing_plot_save(boundary_forcing, tmp_path):
|
|
83
|
-
"""
|
|
84
|
-
Test plot and save methods.
|
|
85
|
-
"""
|
|
79
|
+
"""Test plot and save methods."""
|
|
86
80
|
|
|
87
81
|
boundary_forcing.plot(varname="temp_south", layer_contours=True)
|
|
88
82
|
boundary_forcing.plot(varname="temp_east", layer_contours=True)
|
|
@@ -128,9 +122,7 @@ def test_boundary_forcing_plot_save(boundary_forcing, tmp_path):
|
|
|
128
122
|
def test_bgc_boundary_forcing_plot_save(
|
|
129
123
|
bgc_boundary_forcing_from_climatology, tmp_path
|
|
130
124
|
):
|
|
131
|
-
"""
|
|
132
|
-
Test plot and save methods.
|
|
133
|
-
"""
|
|
125
|
+
"""Test plot and save methods."""
|
|
134
126
|
|
|
135
127
|
bgc_boundary_forcing_from_climatology.plot(varname="ALK_south")
|
|
136
128
|
bgc_boundary_forcing_from_climatology.plot(varname="ALK_east")
|
|
@@ -176,7 +168,8 @@ def test_bgc_boundary_forcing_plot_save(
|
|
|
176
168
|
],
|
|
177
169
|
)
|
|
178
170
|
def test_roundtrip_yaml(bdry_forcing_fixture, request, tmp_path, use_dask):
|
|
179
|
-
"""Test that creating a BoundaryForcing object, saving its parameters to yaml file,
|
|
171
|
+
"""Test that creating a BoundaryForcing object, saving its parameters to yaml file,
|
|
172
|
+
and re-opening yaml file creates the same object."""
|
|
180
173
|
|
|
181
174
|
bdry_forcing = request.getfixturevalue(bdry_forcing_fixture)
|
|
182
175
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"center_lat": 0,
|
|
3
3
|
"center_lon": -20,
|
|
4
|
-
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v
|
|
4
|
+
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v layer_depth_rho layer_depth_u layer_depth_v",
|
|
5
5
|
"hc": 300.0,
|
|
6
6
|
"hmin": 5.0,
|
|
7
|
-
"roms_tools_version": "0.1.
|
|
7
|
+
"roms_tools_version": "0.1.dev157+dirty",
|
|
8
8
|
"rot": 0,
|
|
9
9
|
"size_x": 100,
|
|
10
10
|
"size_y": 100,
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
".zattrs": {
|
|
4
4
|
"center_lat": 0,
|
|
5
5
|
"center_lon": -20,
|
|
6
|
-
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v
|
|
6
|
+
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v layer_depth_rho layer_depth_u layer_depth_v",
|
|
7
7
|
"hc": 300.0,
|
|
8
8
|
"hmin": 5.0,
|
|
9
|
-
"roms_tools_version": "0.1.
|
|
9
|
+
"roms_tools_version": "0.1.dev157+dirty",
|
|
10
10
|
"rot": 0,
|
|
11
11
|
"size_x": 100,
|
|
12
12
|
"size_y": 100,
|
|
@@ -325,36 +325,6 @@
|
|
|
325
325
|
"long_name": "latitude of rho-points on coarsened grid",
|
|
326
326
|
"units": "degrees North"
|
|
327
327
|
},
|
|
328
|
-
"lat_psi/.zarray": {
|
|
329
|
-
"chunks": [
|
|
330
|
-
4,
|
|
331
|
-
4
|
|
332
|
-
],
|
|
333
|
-
"compressor": {
|
|
334
|
-
"blocksize": 0,
|
|
335
|
-
"clevel": 5,
|
|
336
|
-
"cname": "lz4",
|
|
337
|
-
"id": "blosc",
|
|
338
|
-
"shuffle": 1
|
|
339
|
-
},
|
|
340
|
-
"dtype": "<f8",
|
|
341
|
-
"fill_value": "NaN",
|
|
342
|
-
"filters": null,
|
|
343
|
-
"order": "C",
|
|
344
|
-
"shape": [
|
|
345
|
-
4,
|
|
346
|
-
4
|
|
347
|
-
],
|
|
348
|
-
"zarr_format": 2
|
|
349
|
-
},
|
|
350
|
-
"lat_psi/.zattrs": {
|
|
351
|
-
"_ARRAY_DIMENSIONS": [
|
|
352
|
-
"eta_psi",
|
|
353
|
-
"xi_psi"
|
|
354
|
-
],
|
|
355
|
-
"long_name": "latitude of psi-points",
|
|
356
|
-
"units": "degrees North"
|
|
357
|
-
},
|
|
358
328
|
"lat_rho/.zarray": {
|
|
359
329
|
"chunks": [
|
|
360
330
|
3,
|
|
@@ -574,36 +544,6 @@
|
|
|
574
544
|
"long_name": "longitude of rho-points on coarsened grid",
|
|
575
545
|
"units": "degrees East"
|
|
576
546
|
},
|
|
577
|
-
"lon_psi/.zarray": {
|
|
578
|
-
"chunks": [
|
|
579
|
-
4,
|
|
580
|
-
4
|
|
581
|
-
],
|
|
582
|
-
"compressor": {
|
|
583
|
-
"blocksize": 0,
|
|
584
|
-
"clevel": 5,
|
|
585
|
-
"cname": "lz4",
|
|
586
|
-
"id": "blosc",
|
|
587
|
-
"shuffle": 1
|
|
588
|
-
},
|
|
589
|
-
"dtype": "<f8",
|
|
590
|
-
"fill_value": "NaN",
|
|
591
|
-
"filters": null,
|
|
592
|
-
"order": "C",
|
|
593
|
-
"shape": [
|
|
594
|
-
4,
|
|
595
|
-
4
|
|
596
|
-
],
|
|
597
|
-
"zarr_format": 2
|
|
598
|
-
},
|
|
599
|
-
"lon_psi/.zattrs": {
|
|
600
|
-
"_ARRAY_DIMENSIONS": [
|
|
601
|
-
"eta_psi",
|
|
602
|
-
"xi_psi"
|
|
603
|
-
],
|
|
604
|
-
"long_name": "longitude of psi-points",
|
|
605
|
-
"units": "degrees East"
|
|
606
|
-
},
|
|
607
547
|
"lon_rho/.zarray": {
|
|
608
548
|
"chunks": [
|
|
609
549
|
3,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"center_lat": 0,
|
|
3
3
|
"center_lon": 0,
|
|
4
|
-
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v
|
|
4
|
+
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v layer_depth_rho layer_depth_u layer_depth_v",
|
|
5
5
|
"hc": 300.0,
|
|
6
6
|
"hmin": 5.0,
|
|
7
|
-
"roms_tools_version": "0.1.
|
|
7
|
+
"roms_tools_version": "0.1.dev157+dirty",
|
|
8
8
|
"rot": 20,
|
|
9
9
|
"size_x": 100,
|
|
10
10
|
"size_y": 100,
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
".zattrs": {
|
|
4
4
|
"center_lat": 0,
|
|
5
5
|
"center_lon": 0,
|
|
6
|
-
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v
|
|
6
|
+
"coordinates": "interface_depth_rho interface_depth_u interface_depth_v layer_depth_rho layer_depth_u layer_depth_v",
|
|
7
7
|
"hc": 300.0,
|
|
8
8
|
"hmin": 5.0,
|
|
9
|
-
"roms_tools_version": "0.1.
|
|
9
|
+
"roms_tools_version": "0.1.dev157+dirty",
|
|
10
10
|
"rot": 20,
|
|
11
11
|
"size_x": 100,
|
|
12
12
|
"size_y": 100,
|
|
@@ -325,36 +325,6 @@
|
|
|
325
325
|
"long_name": "latitude of rho-points on coarsened grid",
|
|
326
326
|
"units": "degrees North"
|
|
327
327
|
},
|
|
328
|
-
"lat_psi/.zarray": {
|
|
329
|
-
"chunks": [
|
|
330
|
-
4,
|
|
331
|
-
4
|
|
332
|
-
],
|
|
333
|
-
"compressor": {
|
|
334
|
-
"blocksize": 0,
|
|
335
|
-
"clevel": 5,
|
|
336
|
-
"cname": "lz4",
|
|
337
|
-
"id": "blosc",
|
|
338
|
-
"shuffle": 1
|
|
339
|
-
},
|
|
340
|
-
"dtype": "<f8",
|
|
341
|
-
"fill_value": "NaN",
|
|
342
|
-
"filters": null,
|
|
343
|
-
"order": "C",
|
|
344
|
-
"shape": [
|
|
345
|
-
4,
|
|
346
|
-
4
|
|
347
|
-
],
|
|
348
|
-
"zarr_format": 2
|
|
349
|
-
},
|
|
350
|
-
"lat_psi/.zattrs": {
|
|
351
|
-
"_ARRAY_DIMENSIONS": [
|
|
352
|
-
"eta_psi",
|
|
353
|
-
"xi_psi"
|
|
354
|
-
],
|
|
355
|
-
"long_name": "latitude of psi-points",
|
|
356
|
-
"units": "degrees North"
|
|
357
|
-
},
|
|
358
328
|
"lat_rho/.zarray": {
|
|
359
329
|
"chunks": [
|
|
360
330
|
3,
|
|
@@ -574,36 +544,6 @@
|
|
|
574
544
|
"long_name": "longitude of rho-points on coarsened grid",
|
|
575
545
|
"units": "degrees East"
|
|
576
546
|
},
|
|
577
|
-
"lon_psi/.zarray": {
|
|
578
|
-
"chunks": [
|
|
579
|
-
4,
|
|
580
|
-
4
|
|
581
|
-
],
|
|
582
|
-
"compressor": {
|
|
583
|
-
"blocksize": 0,
|
|
584
|
-
"clevel": 5,
|
|
585
|
-
"cname": "lz4",
|
|
586
|
-
"id": "blosc",
|
|
587
|
-
"shuffle": 1
|
|
588
|
-
},
|
|
589
|
-
"dtype": "<f8",
|
|
590
|
-
"fill_value": "NaN",
|
|
591
|
-
"filters": null,
|
|
592
|
-
"order": "C",
|
|
593
|
-
"shape": [
|
|
594
|
-
4,
|
|
595
|
-
4
|
|
596
|
-
],
|
|
597
|
-
"zarr_format": 2
|
|
598
|
-
},
|
|
599
|
-
"lon_psi/.zattrs": {
|
|
600
|
-
"_ARRAY_DIMENSIONS": [
|
|
601
|
-
"eta_psi",
|
|
602
|
-
"xi_psi"
|
|
603
|
-
],
|
|
604
|
-
"long_name": "longitude of psi-points",
|
|
605
|
-
"units": "degrees East"
|
|
606
|
-
},
|
|
607
547
|
"lon_rho/.zarray": {
|
|
608
548
|
"chunks": [
|
|
609
549
|
3,
|
|
@@ -125,9 +125,7 @@ def non_global_dataset():
|
|
|
125
125
|
],
|
|
126
126
|
)
|
|
127
127
|
def test_select_times(data_fixture, expected_time_values, request, tmp_path, use_dask):
|
|
128
|
-
"""
|
|
129
|
-
Test selecting times with different datasets.
|
|
130
|
-
"""
|
|
128
|
+
"""Test selecting times with different datasets."""
|
|
131
129
|
start_time = datetime(2022, 2, 1)
|
|
132
130
|
end_time = datetime(2022, 3, 1)
|
|
133
131
|
|
|
@@ -160,9 +158,7 @@ def test_select_times(data_fixture, expected_time_values, request, tmp_path, use
|
|
|
160
158
|
def test_select_times_valid_start_no_end_time(
|
|
161
159
|
data_fixture, expected_time_values, request, tmp_path, use_dask
|
|
162
160
|
):
|
|
163
|
-
"""
|
|
164
|
-
Test selecting times with only start_time specified.
|
|
165
|
-
"""
|
|
161
|
+
"""Test selecting times with only start_time specified."""
|
|
166
162
|
start_time = datetime(2022, 2, 1)
|
|
167
163
|
|
|
168
164
|
# Get the fixture dynamically based on the parameter
|
|
@@ -196,9 +192,7 @@ def test_select_times_valid_start_no_end_time(
|
|
|
196
192
|
def test_select_times_invalid_start_no_end_time(
|
|
197
193
|
data_fixture, expected_time_values, request, tmp_path, use_dask
|
|
198
194
|
):
|
|
199
|
-
"""
|
|
200
|
-
Test selecting times with only start_time specified.
|
|
201
|
-
"""
|
|
195
|
+
"""Test selecting times with only start_time specified."""
|
|
202
196
|
# Get the fixture dynamically based on the parameter
|
|
203
197
|
dataset = request.getfixturevalue(data_fixture)
|
|
204
198
|
|
|
@@ -221,9 +215,8 @@ def test_select_times_invalid_start_no_end_time(
|
|
|
221
215
|
def test_multiple_matching_times(
|
|
222
216
|
global_dataset_with_multiple_times_per_day, tmp_path, use_dask
|
|
223
217
|
):
|
|
224
|
-
"""
|
|
225
|
-
|
|
226
|
-
"""
|
|
218
|
+
"""Test handling when multiple matching times are found when end_time is not
|
|
219
|
+
specified."""
|
|
227
220
|
filepath = tmp_path / "test.nc"
|
|
228
221
|
global_dataset_with_multiple_times_per_day.to_netcdf(filepath)
|
|
229
222
|
dataset = Dataset(
|
|
@@ -237,9 +230,7 @@ def test_multiple_matching_times(
|
|
|
237
230
|
|
|
238
231
|
|
|
239
232
|
def test_warnings_times(global_dataset, tmp_path, use_dask):
|
|
240
|
-
"""
|
|
241
|
-
Test handling when no matching times are found.
|
|
242
|
-
"""
|
|
233
|
+
"""Test handling when no matching times are found."""
|
|
243
234
|
# Create a temporary file
|
|
244
235
|
filepath = tmp_path / "test.nc"
|
|
245
236
|
global_dataset.to_netcdf(filepath)
|
|
@@ -271,9 +262,8 @@ def test_warnings_times(global_dataset, tmp_path, use_dask):
|
|
|
271
262
|
def test_reverse_latitude_reverse_depth_choose_subdomain(
|
|
272
263
|
global_dataset, tmp_path, use_dask
|
|
273
264
|
):
|
|
274
|
-
"""
|
|
275
|
-
|
|
276
|
-
"""
|
|
265
|
+
"""Test reversing latitude when it is not ascending, the choose_subdomain method,
|
|
266
|
+
and the convert_to_negative_depth method of the Dataset class."""
|
|
277
267
|
start_time = datetime(2022, 1, 1)
|
|
278
268
|
|
|
279
269
|
filepath = tmp_path / "test.nc"
|
|
@@ -45,16 +45,14 @@ def test_grid_creation(grid):
|
|
|
45
45
|
["grid", "counter_clockwise_rotated_grid", "clockwise_rotated_grid"],
|
|
46
46
|
)
|
|
47
47
|
def test_coords_relation(grid_fixture, request):
|
|
48
|
-
"""
|
|
49
|
-
Test that the coordinates satisfy the expected relations on a C-grid.
|
|
50
|
-
"""
|
|
48
|
+
"""Test that the coordinates satisfy the expected relations on a C-grid."""
|
|
51
49
|
grid = request.getfixturevalue(grid_fixture)
|
|
52
50
|
|
|
53
51
|
# psi versus rho
|
|
54
|
-
assert grid.ds.lon_psi.min() < grid.ds.lon_rho.min()
|
|
55
|
-
assert grid.ds.lon_psi.max() > grid.ds.lon_rho.max()
|
|
56
|
-
assert grid.ds.lat_psi.min() < grid.ds.lat_rho.min()
|
|
57
|
-
assert grid.ds.lat_psi.max() > grid.ds.lat_rho.max()
|
|
52
|
+
# assert grid.ds.lon_psi.min() < grid.ds.lon_rho.min()
|
|
53
|
+
# assert grid.ds.lon_psi.max() > grid.ds.lon_rho.max()
|
|
54
|
+
# assert grid.ds.lat_psi.min() < grid.ds.lat_rho.min()
|
|
55
|
+
# assert grid.ds.lat_psi.max() > grid.ds.lat_rho.max()
|
|
58
56
|
|
|
59
57
|
# Assertion with tolerance is necessary for non-rotated grids
|
|
60
58
|
def assert_larger_equal_than_with_tolerance(value1, value2, tolerance=1e-5):
|
|
@@ -218,7 +216,8 @@ def test_compatability_with_matlab_grid(tmp_path):
|
|
|
218
216
|
|
|
219
217
|
|
|
220
218
|
def test_roundtrip_netcdf(tmp_path):
|
|
221
|
-
"""Test that creating a grid, saving it to file, and re-opening it is the same as
|
|
219
|
+
"""Test that creating a grid, saving it to file, and re-opening it is the same as
|
|
220
|
+
just creating it."""
|
|
222
221
|
|
|
223
222
|
# Initialize a Grid object using the initializer
|
|
224
223
|
grid_init = Grid(
|
|
@@ -255,7 +254,8 @@ def test_roundtrip_netcdf(tmp_path):
|
|
|
255
254
|
|
|
256
255
|
|
|
257
256
|
def test_roundtrip_yaml(tmp_path):
|
|
258
|
-
"""Test that creating a grid, saving its parameters to yaml file, and re-opening
|
|
257
|
+
"""Test that creating a grid, saving its parameters to yaml file, and re- opening
|
|
258
|
+
yaml file creates the same grid."""
|
|
259
259
|
|
|
260
260
|
# Initialize a Grid object using the initializer
|
|
261
261
|
grid_init = Grid(
|
|
@@ -19,9 +19,7 @@ from conftest import calculate_file_hash
|
|
|
19
19
|
],
|
|
20
20
|
)
|
|
21
21
|
def test_initial_conditions_creation(ic_fixture, request):
|
|
22
|
-
"""
|
|
23
|
-
Test the creation of the InitialConditions object.
|
|
24
|
-
"""
|
|
22
|
+
"""Test the creation of the InitialConditions object."""
|
|
25
23
|
|
|
26
24
|
ic = request.getfixturevalue(ic_fixture)
|
|
27
25
|
|
|
@@ -181,9 +179,7 @@ def test_interpolation_from_climatology(
|
|
|
181
179
|
def test_initial_conditions_plot_save(
|
|
182
180
|
initial_conditions_with_bgc_from_climatology, tmp_path
|
|
183
181
|
):
|
|
184
|
-
"""
|
|
185
|
-
Test plot and save methods.
|
|
186
|
-
"""
|
|
182
|
+
"""Test plot and save methods."""
|
|
187
183
|
|
|
188
184
|
initial_conditions_with_bgc_from_climatology.plot(varname="temp", s=0)
|
|
189
185
|
initial_conditions_with_bgc_from_climatology.plot(
|
|
@@ -251,7 +247,8 @@ def test_initial_conditions_plot_save(
|
|
|
251
247
|
|
|
252
248
|
|
|
253
249
|
def test_roundtrip_yaml(initial_conditions, tmp_path, use_dask):
|
|
254
|
-
"""Test that creating an InitialConditions object, saving its parameters to yaml
|
|
250
|
+
"""Test that creating an InitialConditions object, saving its parameters to yaml
|
|
251
|
+
file, and re-opening yaml file creates the same object."""
|
|
255
252
|
|
|
256
253
|
# Create a temporary filepath using the tmp_path fixture
|
|
257
254
|
file_str = "test_yaml"
|
|
@@ -9,9 +9,8 @@ from conftest import calculate_file_hash
|
|
|
9
9
|
|
|
10
10
|
@pytest.fixture
|
|
11
11
|
def grid_that_straddles_dateline():
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
"""
|
|
12
|
+
"""Fixture for creating a domain that straddles the dateline and lies within the
|
|
13
|
+
bounds of the regional ERA5 data."""
|
|
15
14
|
grid = Grid(
|
|
16
15
|
nx=20,
|
|
17
16
|
ny=20,
|
|
@@ -27,8 +26,9 @@ def grid_that_straddles_dateline():
|
|
|
27
26
|
|
|
28
27
|
@pytest.fixture
|
|
29
28
|
def grid_that_straddles_dateline_but_is_too_big_for_regional_test_data():
|
|
30
|
-
"""
|
|
31
|
-
|
|
29
|
+
"""Fixture for creating a domain that straddles the dateline but exceeds the bounds
|
|
30
|
+
of the regional ERA5 data.
|
|
31
|
+
|
|
32
32
|
Centered east of dateline.
|
|
33
33
|
"""
|
|
34
34
|
grid = Grid(
|
|
@@ -46,9 +46,11 @@ def grid_that_straddles_dateline_but_is_too_big_for_regional_test_data():
|
|
|
46
46
|
|
|
47
47
|
@pytest.fixture
|
|
48
48
|
def another_grid_that_straddles_dateline_but_is_too_big_for_regional_test_data():
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
"""Fixture for creating a domain that straddles the dateline but exceeds the bounds
|
|
50
|
+
of the regional ERA5 data.
|
|
51
|
+
|
|
52
|
+
Centered west of dateline. This one was hard to catch for the nan_check for a long
|
|
53
|
+
time, but should work now.
|
|
52
54
|
"""
|
|
53
55
|
grid = Grid(
|
|
54
56
|
nx=5,
|
|
@@ -65,9 +67,11 @@ def another_grid_that_straddles_dateline_but_is_too_big_for_regional_test_data()
|
|
|
65
67
|
|
|
66
68
|
@pytest.fixture
|
|
67
69
|
def grid_that_lies_east_of_dateline_less_than_five_degrees_away():
|
|
68
|
-
"""
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
"""Fixture for creating a domain that lies east of Greenwich meridian, but less than
|
|
71
|
+
5 degrees away.
|
|
72
|
+
|
|
73
|
+
We care about the 5 degree mark because it decides whether the code handles the
|
|
74
|
+
longitudes as straddling the dateline or not.
|
|
71
75
|
"""
|
|
72
76
|
|
|
73
77
|
grid = Grid(
|
|
@@ -85,9 +89,11 @@ def grid_that_lies_east_of_dateline_less_than_five_degrees_away():
|
|
|
85
89
|
|
|
86
90
|
@pytest.fixture
|
|
87
91
|
def grid_that_lies_east_of_dateline_more_than_five_degrees_away():
|
|
88
|
-
"""
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
"""Fixture for creating a domain that lies east of Greenwich meridian, more than 5
|
|
93
|
+
degrees away.
|
|
94
|
+
|
|
95
|
+
We care about the 5 degree mark because it decides whether the code handles the
|
|
96
|
+
longitudes as straddling the dateline or not.
|
|
91
97
|
"""
|
|
92
98
|
grid = Grid(
|
|
93
99
|
nx=5,
|
|
@@ -104,9 +110,11 @@ def grid_that_lies_east_of_dateline_more_than_five_degrees_away():
|
|
|
104
110
|
|
|
105
111
|
@pytest.fixture
|
|
106
112
|
def grid_that_lies_west_of_dateline_less_than_five_degrees_away():
|
|
107
|
-
"""
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
"""Fixture for creating a domain that lies west of Greenwich meridian, less than 5
|
|
114
|
+
degrees away.
|
|
115
|
+
|
|
116
|
+
We care about the 5 degree mark because it decides whether the code handles the
|
|
117
|
+
longitudes as straddling the dateline or not.
|
|
110
118
|
"""
|
|
111
119
|
|
|
112
120
|
grid = Grid(
|
|
@@ -124,9 +132,11 @@ def grid_that_lies_west_of_dateline_less_than_five_degrees_away():
|
|
|
124
132
|
|
|
125
133
|
@pytest.fixture
|
|
126
134
|
def grid_that_lies_west_of_dateline_more_than_five_degrees_away():
|
|
127
|
-
"""
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
"""Fixture for creating a domain that lies west of Greenwich meridian, more than 5
|
|
136
|
+
degrees away.
|
|
137
|
+
|
|
138
|
+
We care about the 5 degree mark because it decides whether the code handles the
|
|
139
|
+
longitudes as straddling the dateline or not.
|
|
130
140
|
"""
|
|
131
141
|
|
|
132
142
|
grid = Grid(
|
|
@@ -144,8 +154,10 @@ def grid_that_lies_west_of_dateline_more_than_five_degrees_away():
|
|
|
144
154
|
|
|
145
155
|
@pytest.fixture
|
|
146
156
|
def grid_that_straddles_180_degree_meridian():
|
|
147
|
-
"""
|
|
148
|
-
|
|
157
|
+
"""Fixture for creating a domain that straddles 180 degree meridian.
|
|
158
|
+
|
|
159
|
+
This is a good test grid for the global ERA5 data, which comes on an [-180, 180]
|
|
160
|
+
longitude grid.
|
|
149
161
|
"""
|
|
150
162
|
|
|
151
163
|
grid = Grid(
|
|
@@ -172,8 +184,7 @@ def grid_that_straddles_180_degree_meridian():
|
|
|
172
184
|
],
|
|
173
185
|
)
|
|
174
186
|
def test_successful_initialization_with_regional_data(grid_fixture, request, use_dask):
|
|
175
|
-
"""
|
|
176
|
-
Test the initialization of SurfaceForcing with regional ERA5 data.
|
|
187
|
+
"""Test the initialization of SurfaceForcing with regional ERA5 data.
|
|
177
188
|
|
|
178
189
|
This test checks the following:
|
|
179
190
|
1. SurfaceForcing object initializes successfully with provided regional data.
|
|
@@ -242,8 +253,7 @@ def test_successful_initialization_with_regional_data(grid_fixture, request, use
|
|
|
242
253
|
def test_nan_detection_initialization_with_regional_data(
|
|
243
254
|
grid_fixture, request, use_dask
|
|
244
255
|
):
|
|
245
|
-
"""
|
|
246
|
-
Test handling of NaN values during initialization with regional data.
|
|
256
|
+
"""Test handling of NaN values during initialization with regional data.
|
|
247
257
|
|
|
248
258
|
Ensures ValueError is raised if NaN values are detected in the dataset.
|
|
249
259
|
"""
|
|
@@ -270,10 +280,11 @@ def test_nan_detection_initialization_with_regional_data(
|
|
|
270
280
|
def test_no_longitude_intersection_initialization_with_regional_data(
|
|
271
281
|
grid_that_straddles_180_degree_meridian, use_dask
|
|
272
282
|
):
|
|
273
|
-
"""
|
|
274
|
-
|
|
283
|
+
"""Test initialization of SurfaceForcing with a grid that straddles the 180°
|
|
284
|
+
meridian.
|
|
275
285
|
|
|
276
|
-
Ensures ValueError is raised when the longitude range does not intersect with the
|
|
286
|
+
Ensures ValueError is raised when the longitude range does not intersect with the
|
|
287
|
+
dataset.
|
|
277
288
|
"""
|
|
278
289
|
start_time = datetime(2020, 1, 31)
|
|
279
290
|
end_time = datetime(2020, 2, 2)
|
|
@@ -309,11 +320,11 @@ def test_no_longitude_intersection_initialization_with_regional_data(
|
|
|
309
320
|
],
|
|
310
321
|
)
|
|
311
322
|
def test_successful_initialization_with_global_data(grid_fixture, request, use_dask):
|
|
312
|
-
"""
|
|
313
|
-
Test initialization of SurfaceForcing with global data.
|
|
323
|
+
"""Test initialization of SurfaceForcing with global data.
|
|
314
324
|
|
|
315
325
|
Verifies that the SurfaceForcing object is correctly initialized with global data,
|
|
316
|
-
including the correct handling of the grid and physics data. Checks both coarse and
|
|
326
|
+
including the correct handling of the grid and physics data. Checks both coarse and
|
|
327
|
+
fine grid initialization.
|
|
317
328
|
"""
|
|
318
329
|
start_time = datetime(2020, 1, 31)
|
|
319
330
|
end_time = datetime(2020, 2, 2)
|
|
@@ -357,8 +368,7 @@ def test_successful_initialization_with_global_data(grid_fixture, request, use_d
|
|
|
357
368
|
|
|
358
369
|
|
|
359
370
|
def test_nans_filled_in(grid_that_straddles_dateline, use_dask):
|
|
360
|
-
"""
|
|
361
|
-
Test that the surface forcing fields contain no NaNs.
|
|
371
|
+
"""Test that the surface forcing fields contain no NaNs.
|
|
362
372
|
|
|
363
373
|
The test is performed twice:
|
|
364
374
|
- First with the default fine grid.
|
|
@@ -405,10 +415,8 @@ def test_nans_filled_in(grid_that_straddles_dateline, use_dask):
|
|
|
405
415
|
|
|
406
416
|
|
|
407
417
|
def test_time_attr_climatology(bgc_surface_forcing_from_climatology):
|
|
408
|
-
"""
|
|
409
|
-
|
|
410
|
-
when using climatology data.
|
|
411
|
-
"""
|
|
418
|
+
"""Test that the 'cycle_length' attribute is present in the time coordinate of the
|
|
419
|
+
BGC dataset when using climatology data."""
|
|
412
420
|
for time_coord in ["pco2_time", "iron_time", "dust_time", "nox_time", "nhy_time"]:
|
|
413
421
|
assert hasattr(
|
|
414
422
|
bgc_surface_forcing_from_climatology.ds[time_coord],
|
|
@@ -418,10 +426,8 @@ def test_time_attr_climatology(bgc_surface_forcing_from_climatology):
|
|
|
418
426
|
|
|
419
427
|
|
|
420
428
|
def test_time_attr(bgc_surface_forcing):
|
|
421
|
-
"""
|
|
422
|
-
|
|
423
|
-
when not using climatology data.
|
|
424
|
-
"""
|
|
429
|
+
"""Test that the 'cycle_length' attribute is not present in the time coordinate of
|
|
430
|
+
the BGC dataset when not using climatology data."""
|
|
425
431
|
for time_coord in ["pco2_time", "iron_time", "dust_time", "nox_time", "nhy_time"]:
|
|
426
432
|
assert not hasattr(
|
|
427
433
|
bgc_surface_forcing.ds[time_coord],
|
|
@@ -448,12 +454,11 @@ def test_time_attr(bgc_surface_forcing):
|
|
|
448
454
|
def test_surface_forcing_creation(
|
|
449
455
|
sfc_forcing_fixture, expected_climatology, expected_fname, request
|
|
450
456
|
):
|
|
451
|
-
"""
|
|
452
|
-
Test the creation and initialization of the SurfaceForcing object with BGC.
|
|
457
|
+
"""Test the creation and initialization of the SurfaceForcing object with BGC.
|
|
453
458
|
|
|
454
459
|
Verifies that the SurfaceForcing object is properly created with correct attributes.
|
|
455
|
-
Ensures that expected variables are present in the dataset
|
|
456
|
-
|
|
460
|
+
Ensures that expected variables are present in the dataset and that attributes match
|
|
461
|
+
the given configurations.
|
|
457
462
|
"""
|
|
458
463
|
|
|
459
464
|
sfc_forcing = request.getfixturevalue(sfc_forcing_fixture)
|
|
@@ -491,9 +496,7 @@ def test_surface_forcing_creation(
|
|
|
491
496
|
],
|
|
492
497
|
)
|
|
493
498
|
def test_surface_forcing_plot_save(sfc_forcing_fixture, request, tmp_path):
|
|
494
|
-
"""
|
|
495
|
-
Test plot and save methods.
|
|
496
|
-
"""
|
|
499
|
+
"""Test plot and save methods."""
|
|
497
500
|
sfc_forcing = request.getfixturevalue(sfc_forcing_fixture)
|
|
498
501
|
sfc_forcing.plot(varname="uwnd", time=0)
|
|
499
502
|
|
|
@@ -525,9 +528,7 @@ def test_surface_forcing_plot_save(sfc_forcing_fixture, request, tmp_path):
|
|
|
525
528
|
|
|
526
529
|
|
|
527
530
|
def test_surface_forcing_bgc_plot_save(bgc_surface_forcing, tmp_path):
|
|
528
|
-
"""
|
|
529
|
-
Test plot and save methods.
|
|
530
|
-
"""
|
|
531
|
+
"""Test plot and save methods."""
|
|
531
532
|
|
|
532
533
|
# Check the values in the dataset
|
|
533
534
|
bgc_surface_forcing.plot(varname="pco2_air", time=0)
|
|
@@ -562,9 +563,7 @@ def test_surface_forcing_bgc_plot_save(bgc_surface_forcing, tmp_path):
|
|
|
562
563
|
def test_surface_forcing_bgc_from_clim_plot_save(
|
|
563
564
|
bgc_surface_forcing_from_climatology, tmp_path
|
|
564
565
|
):
|
|
565
|
-
"""
|
|
566
|
-
Test plot and save methods.
|
|
567
|
-
"""
|
|
566
|
+
"""Test plot and save methods."""
|
|
568
567
|
|
|
569
568
|
# Check the values in the dataset
|
|
570
569
|
bgc_surface_forcing_from_climatology.plot(varname="pco2_air", time=0)
|
|
@@ -609,7 +608,8 @@ def test_surface_forcing_bgc_from_clim_plot_save(
|
|
|
609
608
|
],
|
|
610
609
|
)
|
|
611
610
|
def test_roundtrip_yaml(sfc_forcing_fixture, request, tmp_path, use_dask):
|
|
612
|
-
"""Test that creating an SurfaceForcing object, saving its parameters to yaml file,
|
|
611
|
+
"""Test that creating an SurfaceForcing object, saving its parameters to yaml file,
|
|
612
|
+
and re-opening yaml file creates the same object."""
|
|
613
613
|
|
|
614
614
|
sfc_forcing = request.getfixturevalue(sfc_forcing_fixture)
|
|
615
615
|
|