roms-tools 1.0.0__py3-none-any.whl → 1.1.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.
@@ -1,31 +1,22 @@
1
1
  import pytest
2
2
  import numpy as np
3
- import tempfile
4
- import os
5
- from roms_tools import Grid, VerticalCoordinate
6
- import textwrap
3
+ from roms_tools import Grid
7
4
 
8
5
 
9
- @pytest.fixture
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
- VerticalCoordinate(
28
- grid=example_grid,
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(example_grid):
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
- VerticalCoordinate(
43
- grid=example_grid,
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,19 +44,46 @@ def test_invalid_theta_b_value(example_grid):
48
44
  )
49
45
 
50
46
 
51
- @pytest.fixture
52
- def vertical_coordinate(example_grid):
47
+ def test_update_vertical_coordinate():
53
48
 
54
- return VerticalCoordinate(
55
- grid=example_grid, N=3, theta_s=5.0, theta_b=2.0, hc=250.0
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
58
66
 
59
- def test_vertical_coordinate_data_consistency(vertical_coordinate, tmp_path):
67
+
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)
@@ -219,119 +242,45 @@ def test_vertical_coordinate_data_consistency(vertical_coordinate, tmp_path):
219
242
  dtype=np.float32,
220
243
  )
221
244
  # Check the values in the dataset
222
- assert np.allclose(vertical_coordinate.ds["sc_r"].values, expected_sc_r)
223
- assert np.allclose(vertical_coordinate.ds["Cs_r"].values, expected_Cs_r)
224
- assert np.allclose(
225
- vertical_coordinate.ds["layer_depth_rho"].values, expected_layer_depth_rho
226
- )
245
+ assert np.allclose(grid.ds["sc_r"].values, expected_sc_r)
246
+ assert np.allclose(grid.ds["Cs_r"].values, expected_Cs_r)
247
+ assert np.allclose(grid.ds["layer_depth_rho"].values, expected_layer_depth_rho)
248
+ assert np.allclose(grid.ds["layer_depth_u"].values, expected_layer_depth_u)
249
+ assert np.allclose(grid.ds["layer_depth_v"].values, expected_layer_depth_v)
227
250
  assert np.allclose(
228
- vertical_coordinate.ds["layer_depth_u"].values, expected_layer_depth_u
229
- )
230
- assert np.allclose(
231
- vertical_coordinate.ds["layer_depth_v"].values, expected_layer_depth_v
232
- )
233
- assert np.allclose(
234
- vertical_coordinate.ds["interface_depth_rho"].values,
251
+ grid.ds["interface_depth_rho"].values,
235
252
  expected_interface_depth_rho,
236
253
  )
237
- assert np.allclose(
238
- vertical_coordinate.ds["interface_depth_u"].values, expected_interface_depth_u
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)
278
-
279
- vertical_coordinate_from_file = VerticalCoordinate.from_file(filepath)
280
-
281
- assert vertical_coordinate.ds == vertical_coordinate_from_file.ds
254
+ assert np.allclose(grid.ds["interface_depth_u"].values, expected_interface_depth_u)
255
+ assert np.allclose(grid.ds["interface_depth_v"].values, expected_interface_depth_v)
282
256
 
283
- finally:
284
- os.remove(filepath)
285
257
 
286
-
287
- def test_roundtrip_yaml(vertical_coordinate):
288
- """Test that creating a VerticalCoordinate object, saving its parameters to yaml file, and re-opening yaml file creates the same object."""
289
-
290
- # Create a temporary file
291
- with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
292
- filepath = tmpfile.name
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
- """
258
+ def test_plot():
259
+ grid = Grid(
260
+ nx=2,
261
+ ny=2,
262
+ size_x=500,
263
+ size_y=1000,
264
+ center_lon=0,
265
+ center_lat=55,
266
+ rot=10,
267
+ N=3,
268
+ theta_s=5.0,
269
+ theta_b=2.0,
270
+ hc=250.0,
324
271
  )
325
-
326
- with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
327
- yaml_filepath = tmp_file.name
328
- tmp_file.write(yaml_content.encode())
329
-
330
- try:
331
- with pytest.raises(
332
- ValueError,
333
- match="No VerticalCoordinate configuration found in the YAML file.",
334
- ):
335
- VerticalCoordinate.from_yaml(yaml_filepath)
336
- finally:
337
- os.remove(yaml_filepath)
272
+ grid.plot_vertical_coordinate("layer_depth_u", s=0)
273
+ grid.plot_vertical_coordinate("layer_depth_rho", s=-1)
274
+ grid.plot_vertical_coordinate("interface_depth_v", s=-1)
275
+ grid.plot_vertical_coordinate("layer_depth_rho", eta=0)
276
+ grid.plot_vertical_coordinate("layer_depth_u", eta=0)
277
+ grid.plot_vertical_coordinate("layer_depth_v", eta=0)
278
+ grid.plot_vertical_coordinate("interface_depth_rho", eta=0)
279
+ grid.plot_vertical_coordinate("interface_depth_u", eta=0)
280
+ grid.plot_vertical_coordinate("interface_depth_v", eta=0)
281
+ grid.plot_vertical_coordinate("layer_depth_rho", xi=0)
282
+ grid.plot_vertical_coordinate("layer_depth_u", xi=0)
283
+ grid.plot_vertical_coordinate("layer_depth_v", xi=0)
284
+ grid.plot_vertical_coordinate("interface_depth_rho", xi=0)
285
+ grid.plot_vertical_coordinate("interface_depth_u", xi=0)
286
+ 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.0
3
+ Version: 1.1.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
- [![PyPI version](https://badge.fury.io/py/roms-tools.svg)](https://badge.fury.io/py/roms-tools)
34
+ [![PyPI version](https://img.shields.io/pypi/v/roms-tools.svg)](https://pypi.org/project/roms-tools/)
36
35
  [![codecov](https://codecov.io/gh/CWorthy-ocean/roms-tools/graph/badge.svg?token=5S1oNu39xE)](https://codecov.io/gh/CWorthy-ocean/roms-tools)
37
36
  [![Documentation Status](https://readthedocs.org/projects/roms-tools/badge/?version=latest)](https://roms-tools.readthedocs.io/en/latest/?badge=latest)
38
37
  ![Run Tests](https://github.com/CWorthy-ocean/roms-tools/actions/workflows/tests.yaml/badge.svg)
@@ -0,0 +1,31 @@
1
+ ci/environment.yml,sha256=tjoIEUdPWfJBO4ijsJYhq7ay8_QfJKxRtq8Z0r8rHTI,427
2
+ roms_tools/__init__.py,sha256=PQ7jWQ97DYS5b6YIFZVE2PYaRwXjN0Ykfhq0PKqN9ME,560
3
+ roms_tools/_version.py,sha256=zxeJ2mSI8C93mJwJVRHja1imkOUF_4LDMbFODuXtPc8,72
4
+ roms_tools/setup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ roms_tools/setup/boundary_forcing.py,sha256=IK-NqyCF5sFXyRpU0sKHt5uDYcsown2wq-0kIh32tIc,32060
6
+ roms_tools/setup/datasets.py,sha256=3PJ0JCQUcNVHd4Xl7dodJ6lZJmV5cRkCxH-vOuZtrZ4,41478
7
+ roms_tools/setup/download.py,sha256=SapK5GIx-ykBrqqj0S_dgMxBBDGVKTfgIdbaiiOohhY,4280
8
+ roms_tools/setup/fill.py,sha256=45Ro5oN-n-n_qKZq3qTHn27ZKpTKWhr_9AWw6gUJ-9I,13291
9
+ roms_tools/setup/grid.py,sha256=fBRGRw4MGSKt1nxQ1u-pbhooLPhQIkinSpIX9vc-Ij4,39182
10
+ roms_tools/setup/initial_conditions.py,sha256=EOAEsvAwaBEFI5hdD23C3xkNBNfen1i814sVptEGzf8,20458
11
+ roms_tools/setup/mixins.py,sha256=sq9CKHtWScR4v29IrgQic-UtfFreZMhCFqS39_rP6UE,16434
12
+ roms_tools/setup/plot.py,sha256=vpOoAHE5HvnmeAPyhr-GijGLLlqkEple5hfr_f3Nfn8,6331
13
+ roms_tools/setup/surface_forcing.py,sha256=fZGn93qzPgCJNKPUSjZH3rIfVL2nqXr4OJ7YtR5Tzro,22143
14
+ roms_tools/setup/tides.py,sha256=PP-R4mqMI_RpVOAg0hH3dAAaUjB6C3rSR_JyvJ1zODw,22907
15
+ roms_tools/setup/topography.py,sha256=qjvbeSO_Y-PvuqmpKZiOU42fLZJa8dkr60BRP9UU0sg,9778
16
+ roms_tools/setup/utils.py,sha256=6_rNPWSP1Q5PjRlMAKS3GunBWySzPcnj6xYAFaFbqfY,12678
17
+ roms_tools/setup/vertical_coordinate.py,sha256=hYQG-zQoMnxfuAzzQOF4XDGtYqp1GVc93kCfeTkjDgw,2875
18
+ roms_tools/tests/test_boundary_forcing.py,sha256=VDH7R8Wh5tN0fj_vtlEYjQ0dve6Zm6PGXoPU8uZaJsA,24043
19
+ roms_tools/tests/test_datasets.py,sha256=RPpnKa4kUrXgCUCc3ca7SdHnFs7qQmOwQYQnPEN6T_g,11743
20
+ roms_tools/tests/test_grid.py,sha256=0qpYu-zPd4XhU0j2KE6qDpdk9e4zS8aS9blUl0Oxr4o,11142
21
+ roms_tools/tests/test_initial_conditions.py,sha256=SiBp5uKjIX8xNzjFarCqCnNmsgxoqtiQuDF3NEjxEGE,15664
22
+ roms_tools/tests/test_surface_forcing.py,sha256=TyZNZVScFIow0wFiWA9Do0q9jN4wdVYN43lyEgzHslU,77892
23
+ roms_tools/tests/test_tides.py,sha256=wcH8WAvzb-FqJmr_VLTwldV8XalyntZANhy-FRMQ7e4,11133
24
+ roms_tools/tests/test_topography.py,sha256=RxdLyz_Fduu85tVx5aW62Dj4REg_RLWgvsSpgjDURqM,2014
25
+ roms_tools/tests/test_utils.py,sha256=Ey5jrsdd7B9kL5ijqr9CLQNguPlxVMTybIneihdefN8,560
26
+ roms_tools/tests/test_vertical_coordinate.py,sha256=s5DItBx-eoBAaZN-dtvM3V5y_rvXAIWHUjRIhQcKq84,9363
27
+ roms_tools-1.1.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
28
+ roms_tools-1.1.0.dist-info/METADATA,sha256=h-MWfFlBxYoNs1TsAYsaMIX_kygZIM9vAjG3iBpfTuQ,2923
29
+ roms_tools-1.1.0.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
30
+ roms_tools-1.1.0.dist-info/top_level.txt,sha256=aAf4T4nYQSkay5iKJ9kmTjlDgd4ETdp9OSlB4sJdt8Y,19
31
+ roms_tools-1.1.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (73.0.0)
2
+ Generator: setuptools (73.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,31 +0,0 @@
1
- ci/environment.yml,sha256=tjoIEUdPWfJBO4ijsJYhq7ay8_QfJKxRtq8Z0r8rHTI,427
2
- roms_tools/__init__.py,sha256=v0fXc7jON8jbXD1zIxuC5dEqIa30PkMzTVe0bLGMrhY,642
3
- roms_tools/_version.py,sha256=TDFyBsBYj5dQ4UQBcf-o9xaD5eD4cemY65tpAOJYk5Y,72
4
- roms_tools/setup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- roms_tools/setup/boundary_forcing.py,sha256=ulif6YOZX-RzoJ-HotNlWSb3z3g-7E2qIR_mzv-F8Q4,33179
6
- roms_tools/setup/datasets.py,sha256=3PJ0JCQUcNVHd4Xl7dodJ6lZJmV5cRkCxH-vOuZtrZ4,41478
7
- roms_tools/setup/download.py,sha256=SapK5GIx-ykBrqqj0S_dgMxBBDGVKTfgIdbaiiOohhY,4280
8
- roms_tools/setup/fill.py,sha256=45Ro5oN-n-n_qKZq3qTHn27ZKpTKWhr_9AWw6gUJ-9I,13291
9
- roms_tools/setup/grid.py,sha256=V3vVOrkmlHM4CfhIGGlGTCw2OvZ62MGnrUHJepDylsA,30848
10
- roms_tools/setup/initial_conditions.py,sha256=CzoGLzQiJKRw2V_HChX3XACJU-2uEVD279H_b2PvfIw,21588
11
- roms_tools/setup/mixins.py,sha256=EDaIbRCPVE2aJkGekh99sAeiSmyl-SUMfiTaCcHGVyg,16808
12
- roms_tools/setup/plot.py,sha256=vpOoAHE5HvnmeAPyhr-GijGLLlqkEple5hfr_f3Nfn8,6331
13
- roms_tools/setup/surface_forcing.py,sha256=fZGn93qzPgCJNKPUSjZH3rIfVL2nqXr4OJ7YtR5Tzro,22143
14
- roms_tools/setup/tides.py,sha256=PP-R4mqMI_RpVOAg0hH3dAAaUjB6C3rSR_JyvJ1zODw,22907
15
- roms_tools/setup/topography.py,sha256=yNJn9KW9m7UB6nxh5bUQzllt6z22AQahUwWIIUwHz_Y,8557
16
- roms_tools/setup/utils.py,sha256=6_rNPWSP1Q5PjRlMAKS3GunBWySzPcnj6xYAFaFbqfY,12678
17
- roms_tools/setup/vertical_coordinate.py,sha256=IqZN3vDW4DyeaQSr-Di5O8qH2cLJE__XKmf4lROgF8s,16122
18
- roms_tools/tests/test_boundary_forcing.py,sha256=wLhX9UOZ6cfR-c3gw7bvM6ttwMCH8LpZlqXlLrQsvWM,24438
19
- roms_tools/tests/test_datasets.py,sha256=RPpnKa4kUrXgCUCc3ca7SdHnFs7qQmOwQYQnPEN6T_g,11743
20
- roms_tools/tests/test_grid.py,sha256=Dhci5NXOQsASM9mdNCmqyxVXcSasjjlNvcYxKZoah6E,5587
21
- roms_tools/tests/test_initial_conditions.py,sha256=xY-QkpGUEMeO1R076Ww0bSa3p8-qtTLVl1bTFUrv7kw,16701
22
- roms_tools/tests/test_surface_forcing.py,sha256=CBLOOuA0LxLQwyedbN0idtnl2wVjT5mDq4nR5LH1DxA,78007
23
- roms_tools/tests/test_tides.py,sha256=wcH8WAvzb-FqJmr_VLTwldV8XalyntZANhy-FRMQ7e4,11133
24
- roms_tools/tests/test_topography.py,sha256=Nwzor5ciOZfV7Y7fDazE1JH1qxotmJilOpZUcHxAypI,1945
25
- roms_tools/tests/test_utils.py,sha256=Ey5jrsdd7B9kL5ijqr9CLQNguPlxVMTybIneihdefN8,560
26
- roms_tools/tests/test_vertical_coordinate.py,sha256=GshM5l1e9bl4RT0HATQJg9YJ9asGK4beqIKbZxr9j7U,10843
27
- roms_tools-1.0.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
28
- roms_tools-1.0.0.dist-info/METADATA,sha256=gi-rdZeU47LyWqXw-Xn_KrYpteCjYqVlmQz9lNLccAA,2918
29
- roms_tools-1.0.0.dist-info/WHEEL,sha256=nCVcAvsfA9TDtwGwhYaRrlPhTLV9m-Ga6mdyDtuwK18,91
30
- roms_tools-1.0.0.dist-info/top_level.txt,sha256=aAf4T4nYQSkay5iKJ9kmTjlDgd4ETdp9OSlB4sJdt8Y,19
31
- roms_tools-1.0.0.dist-info/RECORD,,