Skip to content

Commit 0e5c7c2

Browse files
committed
Remove Field.set_depth_from_field() and grid.depth_field
1 parent afaf376 commit 0e5c7c2

File tree

5 files changed

+5
-37
lines changed

5 files changed

+5
-37
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ jobs:
7676
with:
7777
environment-file: environment.yml
7878
- name: Integration test
79-
run: | # TODO v4: Re-enable `tutorial_periodic_boundaries` notebook
80-
coverage run -m pytest -v -s --nbval-lax -k "not documentation and not tutorial_periodic_boundaries" --html="${{ matrix.os }}_${{ matrix.python-version }}_integration_test_report.html" --self-contained-html docs/examples
79+
# TODO v4: Re-enable `tutorial_periodic_boundaries` and `tutorial_timevaryingdepthdimensions` notebooks
80+
run: |
81+
coverage run -m pytest -v -s --nbval-lax -k "not documentation and not tutorial_periodic_boundaries and not tutorial_timevaryingdepthdimensions" --html="${{ matrix.os }}_${{ matrix.python-version }}_integration_test_report.html" --self-contained-html docs/examples
8182
coverage xml
8283
- name: Codecov
8384
uses: codecov/[email protected]

parcels/field.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,6 @@ def __init__(
234234
self._dataFiles = kwargs.pop("dataFiles", None)
235235
self._netcdf_engine = kwargs.pop("netcdf_engine", "netcdf4")
236236
self._creation_log = kwargs.pop("creation_log", "")
237-
self.grid.depth_field = kwargs.pop("depth_field", None)
238-
239-
if self.grid.depth_field == "not_yet_set":
240-
assert (
241-
self.grid._z4d
242-
), "Providing the depth dimensions from another field data is only available for 4d S grids"
243237

244238
# data_full_zdim is the vertical dimension of the complete field data, ignoring the indices.
245239
# (data_full_zdim = grid.zdim if no indices are used, for A- and C-grids and for some B-grids). It is used for the B-grid,
@@ -498,11 +492,7 @@ def from_netcdf(
498492
gridindexingtype=gridindexingtype,
499493
) as filebuffer:
500494
filebuffer.name = variable[1]
501-
if dimensions["depth"] == "not_yet_set":
502-
depth = filebuffer.depth_dimensions
503-
kwargs["depth_field"] = "not_yet_set"
504-
else:
505-
depth = filebuffer.depth
495+
depth = filebuffer.depth
506496
data_full_zdim = filebuffer.data_full_zdim
507497
else:
508498
indices["depth"] = [0]
@@ -690,19 +680,6 @@ def set_scaling_factor(self, factor):
690680
self._scaling_factor = factor
691681
self.data *= factor
692682

693-
def set_depth_from_field(self, field):
694-
"""Define the depth dimensions from another (time-varying) field.
695-
696-
Notes
697-
-----
698-
See `this tutorial <../examples/tutorial_timevaryingdepthdimensions.ipynb>`__
699-
for a detailed explanation on how to set up time-evolving depth dimensions.
700-
701-
"""
702-
self.grid.depth_field = field
703-
if self.grid != field.grid:
704-
field.grid.depth_field = field
705-
706683
def _search_indices(self, time, z, y, x, ti, particle=None, search2D=False):
707684
if self.grid._gtype in [GridType.RectilinearSGrid, GridType.RectilinearZGrid]:
708685
return _search_indices_rectilinear(self, time, z, y, x, ti, particle=particle, search2D=search2D)

parcels/fieldset.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,6 @@ def check_velocityfields(U, V, W):
290290
for f in self.get_fields():
291291
if isinstance(f, (VectorField, NestedField)) or f._dataFiles is None:
292292
continue
293-
if f.grid.depth_field is not None:
294-
if f.grid.depth_field == "not_yet_set":
295-
raise ValueError(
296-
"If depth dimension is set at 'not_yet_set', it must be added later using Field.set_depth_from_field(field)"
297-
)
298-
depth_data = f.grid.depth_field.data
299-
f.grid._depth = depth_data if isinstance(depth_data, np.ndarray) else np.array(depth_data)
300293
self._completed = True
301294

302295
@classmethod
@@ -434,8 +427,6 @@ def from_netcdf(
434427
possibly_samegrid = True
435428
if not possibly_samegrid:
436429
break
437-
if "depth" in dims and dims["depth"] == "not_yet_set":
438-
break
439430
processedGrid = False
440431
if (not isinstance(filenames, dict)) or filenames[procvar] == filenames[var]:
441432
processedGrid = True

parcels/grid.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def __init__(
6767
self._lonlat_minmax = np.array(
6868
[np.nanmin(lon), np.nanmax(lon), np.nanmin(lat), np.nanmax(lat)], dtype=np.float32
6969
)
70-
self.depth_field = None
7170

7271
def __repr__(self):
7372
with np.printoptions(threshold=5, suppress=True, linewidth=120, formatter={"float": "{: 0.2f}".format}):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]
4646

4747
[tool.pixi.tasks]
4848
tests = "pytest"
49-
tests-notebooks = "pytest -v -s --nbval-lax -k 'not documentation and not tutorial_periodic_boundaries'" # TODO v4: Re-enable `tutorial_periodic_boundaries` notebook
49+
tests-notebooks = "pytest -v -s --nbval-lax -k 'not documentation and not tutorial_periodic_boundaries and not tutorial_timevaryingdepthdimensions'" # TODO v4: Re-enable `tutorial_periodic_boundaries` and `tutorial_timevaryingdepthdimensions` notebooks
5050
coverage = "coverage run -m pytest && coverage html"
5151
typing = "mypy parcels"
5252
pre-commit = "pre-commit run --all-files"

0 commit comments

Comments
 (0)