roms-tools 0.1.0__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 +2 -0
- roms_tools/__init__.py +4 -2
- roms_tools/_version.py +1 -1
- roms_tools/setup/boundary_forcing.py +757 -0
- roms_tools/setup/datasets.py +1141 -35
- roms_tools/setup/download.py +118 -0
- roms_tools/setup/fill.py +118 -5
- roms_tools/setup/grid.py +145 -19
- roms_tools/setup/initial_conditions.py +557 -0
- roms_tools/setup/mixins.py +395 -0
- roms_tools/setup/plot.py +149 -4
- roms_tools/setup/surface_forcing.py +596 -0
- roms_tools/setup/tides.py +472 -437
- roms_tools/setup/topography.py +18 -3
- roms_tools/setup/utils.py +352 -0
- roms_tools/setup/vertical_coordinate.py +494 -0
- roms_tools/tests/test_boundary_forcing.py +706 -0
- roms_tools/tests/test_datasets.py +370 -0
- roms_tools/tests/test_grid.py +226 -0
- roms_tools/tests/test_initial_conditions.py +520 -0
- roms_tools/tests/test_surface_forcing.py +2622 -0
- roms_tools/tests/test_tides.py +365 -0
- roms_tools/tests/test_topography.py +78 -0
- roms_tools/tests/test_utils.py +16 -0
- roms_tools/tests/test_vertical_coordinate.py +337 -0
- {roms_tools-0.1.0.dist-info → roms_tools-1.0.0.dist-info}/METADATA +9 -4
- roms_tools-1.0.0.dist-info/RECORD +31 -0
- {roms_tools-0.1.0.dist-info → roms_tools-1.0.0.dist-info}/WHEEL +1 -1
- roms_tools/setup/atmospheric_forcing.py +0 -993
- roms_tools/tests/test_setup.py +0 -181
- roms_tools-0.1.0.dist-info/RECORD +0 -17
- {roms_tools-0.1.0.dist-info → roms_tools-1.0.0.dist-info}/LICENSE +0 -0
- {roms_tools-0.1.0.dist-info → roms_tools-1.0.0.dist-info}/top_level.txt +0 -0
roms_tools/tests/test_setup.py
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
import numpy as np
|
|
3
|
-
import numpy.testing as npt
|
|
4
|
-
from scipy.ndimage import label
|
|
5
|
-
from roms_tools import Grid
|
|
6
|
-
from roms_tools.setup.topography import _compute_rfactor
|
|
7
|
-
from roms_tools.setup.tides import TPXO
|
|
8
|
-
import os
|
|
9
|
-
import tempfile
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class TestCreateGrid:
|
|
13
|
-
def test_simple_regression(self):
|
|
14
|
-
grid = Grid(
|
|
15
|
-
nx=1, ny=1, size_x=100, size_y=100, center_lon=-20, center_lat=0, rot=0
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
expected_lat = np.array(
|
|
19
|
-
[
|
|
20
|
-
[-8.99249453e-01, -8.99249453e-01, -8.99249453e-01],
|
|
21
|
-
[0.0, 0.0, 0.0],
|
|
22
|
-
[8.99249453e-01, 8.99249453e-01, 8.99249453e-01],
|
|
23
|
-
]
|
|
24
|
-
)
|
|
25
|
-
expected_lon = np.array(
|
|
26
|
-
[
|
|
27
|
-
[339.10072286, 340.0, 340.89927714],
|
|
28
|
-
[339.10072286, 340.0, 340.89927714],
|
|
29
|
-
[339.10072286, 340.0, 340.89927714],
|
|
30
|
-
]
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
# TODO: adapt tolerances according to order of magnitude of respective fields
|
|
34
|
-
npt.assert_allclose(grid.ds["lat_rho"], expected_lat, atol=1e-8)
|
|
35
|
-
npt.assert_allclose(grid.ds["lon_rho"], expected_lon, atol=1e-8)
|
|
36
|
-
|
|
37
|
-
def test_raise_if_domain_too_large(self):
|
|
38
|
-
with pytest.raises(ValueError, match="Domain size has to be smaller"):
|
|
39
|
-
Grid(nx=3, ny=3, size_x=30000, size_y=30000, center_lon=0, center_lat=51.5)
|
|
40
|
-
|
|
41
|
-
# test grid with reasonable domain size
|
|
42
|
-
grid = Grid(
|
|
43
|
-
nx=3,
|
|
44
|
-
ny=3,
|
|
45
|
-
size_x=1800,
|
|
46
|
-
size_y=2400,
|
|
47
|
-
center_lon=-21,
|
|
48
|
-
center_lat=61,
|
|
49
|
-
rot=20,
|
|
50
|
-
)
|
|
51
|
-
assert isinstance(grid, Grid)
|
|
52
|
-
|
|
53
|
-
def test_grid_straddle_crosses_meridian(self):
|
|
54
|
-
grid = Grid(
|
|
55
|
-
nx=3,
|
|
56
|
-
ny=3,
|
|
57
|
-
size_x=100,
|
|
58
|
-
size_y=100,
|
|
59
|
-
center_lon=0,
|
|
60
|
-
center_lat=61,
|
|
61
|
-
rot=20,
|
|
62
|
-
)
|
|
63
|
-
assert grid.straddle
|
|
64
|
-
|
|
65
|
-
grid = Grid(
|
|
66
|
-
nx=3,
|
|
67
|
-
ny=3,
|
|
68
|
-
size_x=100,
|
|
69
|
-
size_y=100,
|
|
70
|
-
center_lon=180,
|
|
71
|
-
center_lat=61,
|
|
72
|
-
rot=20,
|
|
73
|
-
)
|
|
74
|
-
assert not grid.straddle
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
class TestGridFromFile:
|
|
78
|
-
def test_roundtrip(self):
|
|
79
|
-
"""Test that creating a grid, saving it to file, and re-opening it is the same as just creating it."""
|
|
80
|
-
|
|
81
|
-
# Initialize a Grid object using the initializer
|
|
82
|
-
grid_init = Grid(
|
|
83
|
-
nx=10,
|
|
84
|
-
ny=15,
|
|
85
|
-
size_x=100.0,
|
|
86
|
-
size_y=150.0,
|
|
87
|
-
center_lon=0.0,
|
|
88
|
-
center_lat=0.0,
|
|
89
|
-
rot=0.0,
|
|
90
|
-
topography_source="etopo5",
|
|
91
|
-
smooth_factor=2,
|
|
92
|
-
hmin=5.0,
|
|
93
|
-
rmax=0.2,
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
# Create a temporary file
|
|
97
|
-
with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
|
|
98
|
-
filepath = tmpfile.name
|
|
99
|
-
|
|
100
|
-
try:
|
|
101
|
-
# Save the grid to a file
|
|
102
|
-
grid_init.save(filepath)
|
|
103
|
-
|
|
104
|
-
# Load the grid from the file
|
|
105
|
-
grid_from_file = Grid.from_file(filepath)
|
|
106
|
-
|
|
107
|
-
# Assert that the initial grid and the loaded grid are equivalent (including the 'ds' attribute)
|
|
108
|
-
assert grid_init == grid_from_file
|
|
109
|
-
|
|
110
|
-
finally:
|
|
111
|
-
os.remove(filepath)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
class TestTopography:
|
|
115
|
-
def test_enclosed_regions(self):
|
|
116
|
-
"""Test that there are only two connected regions, one dry and one wet."""
|
|
117
|
-
|
|
118
|
-
grid = Grid(
|
|
119
|
-
nx=100,
|
|
120
|
-
ny=100,
|
|
121
|
-
size_x=1800,
|
|
122
|
-
size_y=2400,
|
|
123
|
-
center_lon=30,
|
|
124
|
-
center_lat=61,
|
|
125
|
-
rot=20,
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
reg, nreg = label(grid.ds.mask_rho)
|
|
129
|
-
npt.assert_equal(nreg, 2)
|
|
130
|
-
|
|
131
|
-
def test_rmax_criterion(self):
|
|
132
|
-
grid = Grid(
|
|
133
|
-
nx=100,
|
|
134
|
-
ny=100,
|
|
135
|
-
size_x=1800,
|
|
136
|
-
size_y=2400,
|
|
137
|
-
center_lon=30,
|
|
138
|
-
center_lat=61,
|
|
139
|
-
rot=20,
|
|
140
|
-
smooth_factor=4,
|
|
141
|
-
rmax=0.2,
|
|
142
|
-
)
|
|
143
|
-
r_eta, r_xi = _compute_rfactor(grid.ds.h)
|
|
144
|
-
rmax0 = np.max([r_eta.max(), r_xi.max()])
|
|
145
|
-
npt.assert_array_less(rmax0, grid.rmax)
|
|
146
|
-
|
|
147
|
-
def test_hmin_criterion(self):
|
|
148
|
-
grid = Grid(
|
|
149
|
-
nx=100,
|
|
150
|
-
ny=100,
|
|
151
|
-
size_x=1800,
|
|
152
|
-
size_y=2400,
|
|
153
|
-
center_lon=30,
|
|
154
|
-
center_lat=61,
|
|
155
|
-
rot=20,
|
|
156
|
-
smooth_factor=2,
|
|
157
|
-
rmax=0.2,
|
|
158
|
-
hmin=5,
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
assert np.less_equal(grid.hmin, grid.ds.h.min())
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
class TestTPXO:
|
|
165
|
-
def test_load_data_file_not_found(self):
|
|
166
|
-
# Test loading data from a non-existing file
|
|
167
|
-
with pytest.raises(FileNotFoundError):
|
|
168
|
-
TPXO.load_data("non_existing_file.nc")
|
|
169
|
-
|
|
170
|
-
def test_load_data_checksum_mismatch(self):
|
|
171
|
-
# Create a temporary file for testing
|
|
172
|
-
filename = "test_tidal_data.nc"
|
|
173
|
-
with open(filename, "wb") as file:
|
|
174
|
-
# Write some data to the file
|
|
175
|
-
file.write(b"test data")
|
|
176
|
-
# Test loading data with incorrect checksum
|
|
177
|
-
with open(filename, "wb") as file:
|
|
178
|
-
with pytest.raises(ValueError):
|
|
179
|
-
TPXO.load_data(filename)
|
|
180
|
-
# Remove temporary file
|
|
181
|
-
os.remove(filename)
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
ci/environment.yml,sha256=OzTO5aTfzirFobAM6TmzJXZ622liCwIzreZH-x7n4mU,394
|
|
2
|
-
roms_tools/__init__.py,sha256=9MiZw2yYthIwOrktbOKwNptyZPmMV4_p4aCK4HymzUM,489
|
|
3
|
-
roms_tools/_version.py,sha256=FGsmFbZ942cZk42U_qHqxgRCbsD--5Vld_eR6xKJ-mQ,72
|
|
4
|
-
roms_tools/setup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
roms_tools/setup/atmospheric_forcing.py,sha256=A6wPmEfjeCIO3tu4TLt4Sul_J6AnF_peWZdON3I_6iw,34790
|
|
6
|
-
roms_tools/setup/datasets.py,sha256=0Hcsr7VzE-jo51kSMZ0ltHnIqc3fHe2v9lAC6ig2rH0,1943
|
|
7
|
-
roms_tools/setup/fill.py,sha256=8Klt77rkJqyXQ54TUv75KK_5iHcAwH-3bBtO3eoBieM,8701
|
|
8
|
-
roms_tools/setup/grid.py,sha256=p8AgCzUx5CkuxFcjFX6X65pYwEyOzxslx_nZDNJd-M4,26449
|
|
9
|
-
roms_tools/setup/plot.py,sha256=LZjTB4NHpXGsju_VZSCBwTfyox08nXHh6TkqmNBvz5Y,1809
|
|
10
|
-
roms_tools/setup/tides.py,sha256=aOez64Zv6MM1VFs1WIClKPpSg9vySvogqfqbg2eHKHA,20942
|
|
11
|
-
roms_tools/setup/topography.py,sha256=hj_IEbMTaazEtp6rrNbqAtGgPesWcCs8eHko0XHEhJg,8010
|
|
12
|
-
roms_tools/tests/test_setup.py,sha256=L90eM0IroRhYQ8ZY9BVOyUQND41lzdJKB_y2n7Aihmc,5102
|
|
13
|
-
roms_tools-0.1.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
14
|
-
roms_tools-0.1.0.dist-info/METADATA,sha256=XtN4Icf1h7Sh_ZbL9OFNCr9wIkvRpqTuo95szsLNtcg,2567
|
|
15
|
-
roms_tools-0.1.0.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
|
|
16
|
-
roms_tools-0.1.0.dist-info/top_level.txt,sha256=aAf4T4nYQSkay5iKJ9kmTjlDgd4ETdp9OSlB4sJdt8Y,19
|
|
17
|
-
roms_tools-0.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|