Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ jobs:
environment-file: environment.yml
- name: Integration test
# TODO v4: Re-enable `tutorial_periodic_boundaries`, `tutorial_timevaryingdepthdimensions` and `tutorial_croco_3D` notebooks
# TODO v4: Re-enable `tutorial_nemo_3D` notebook once 3D grids are implemented (https://github.com/OceanParcels/Parcels/pull/1936#issuecomment-2717666705)
run: |
coverage run -m pytest -v -s --nbval-lax -k "not documentation and not tutorial_periodic_boundaries and not tutorial_timevaryingdepthdimensions and not tutorial_croco_3D" --html="${{ matrix.os }}_${{ matrix.python-version }}_integration_test_report.html" --self-contained-html docs/examples
coverage run -m pytest -v -s --nbval-lax -k "not documentation and not tutorial_periodic_boundaries and not tutorial_timevaryingdepthdimensions and not tutorial_croco_3D and not tutorial_nemo_3D" --html="${{ matrix.os }}_${{ matrix.python-version }}_integration_test_report.html" --self-contained-html docs/examples
coverage xml
- name: Codecov
uses: codecov/[email protected]
Expand Down
5 changes: 0 additions & 5 deletions parcels/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,9 @@ def from_netcdf(
) as filebuffer:
filebuffer.name = variable[1]
depth = filebuffer.depth
data_full_zdim = filebuffer.data_full_zdim
else:
indices["depth"] = np.array([0])
depth = np.zeros(1)
data_full_zdim = 1

kwargs["data_full_zdim"] = data_full_zdim

if len(data_filenames) > 1 and "time" not in dimensions:
raise RuntimeError("Multiple files given but no time dimension specified")
Expand All @@ -421,7 +417,6 @@ def from_netcdf(
dimensions,
indices,
interp_method=interp_method,
data_full_zdim=data_full_zdim,
) as filebuffer:
# If Field.from_netcdf is called directly, it may not have a 'data' dimension
# In that case, assume that 'name' is the data dimension
Expand Down
23 changes: 7 additions & 16 deletions parcels/fieldfilebuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
indices,
*,
interp_method: InterpMethodOption = "linear",
data_full_zdim=None,
gridindexingtype="nemo",
):
self.filename: PathLike | list[PathLike] = filename
Expand All @@ -26,7 +25,6 @@
self.dataset = None
self.interp_method = interp_method
self.gridindexingtype = gridindexingtype
self.data_full_zdim = data_full_zdim

def __enter__(self):
self.dataset = open_xarray_dataset(self.filename)
Expand Down Expand Up @@ -58,6 +56,8 @@

@property
def zdim(self):
if "depth" not in self.dimensions:
return 1
depth = self.dataset[self.dimensions["depth"]]
zdim = depth.size if len(depth.shape) == 1 else depth.shape[-3]
if self.gridindexingtype in ["croco"]:
Expand All @@ -84,23 +84,14 @@

@property
def depth(self):
self.indices["depth"] = range(self.zdim)
if "depth" in self.dimensions:
depth = self.dataset[self.dimensions["depth"]]
self.data_full_zdim = self.zdim
self.indices["depth"] = range(self.zdim)
return depth
else:
self.indices["depth"] = [0]
return np.zeros(1)
return self.dataset[self.dimensions["depth"]]
return np.zeros(1)

Check warning on line 90 in parcels/fieldfilebuffer.py

View check run for this annotation

Codecov / codecov/patch

parcels/fieldfilebuffer.py#L90

Added line #L90 was not covered by tests

@property
def depth_dimensions(self):
if "depth" in self.dimensions:
data = self.dataset[self.name]
depthsize = data.shape[-3]
self.data_full_zdim = depthsize
self.indices["depth"] = range(depthsize)
return np.empty((0, self.zdim) + data.shape[-2:])
def data_full_zdim(self):
return self.zdim

def _check_extend_depth(self, data, dim):
return (
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]

[tool.pixi.tasks]
tests = "pytest"
tests-notebooks = "pytest -v -s --nbval-lax -k 'not documentation and not tutorial_periodic_boundaries and not tutorial_timevaryingdepthdimensions and not tutorial_croco_3D'" # TODO v4: Re-enable `tutorial_periodic_boundaries`, `tutorial_timevaryingdepthdimensions`, and `tutorial_croco_3D` notebooks
tests-notebooks = "pytest -v -s --nbval-lax -k 'not documentation and not tutorial_periodic_boundaries and not tutorial_timevaryingdepthdimensions and not tutorial_croco_3D and not tutorial_nemo_3D'" # TODO v4: Re-enable `tutorial_periodic_boundaries`, `tutorial_timevaryingdepthdimensions`, `tutorial_croco_3D`, `tutorial_nemo_3D` notebooks
coverage = "coverage run -m pytest && coverage html"
typing = "mypy parcels"
pre-commit = "pre-commit run --all-files"
Expand Down
13 changes: 12 additions & 1 deletion tests/test_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,18 @@ def UpdateR(particle, fieldset, time): # pragma: no cover
assert np.allclose(pset.radius, pset.radius_start, atol=10)


@pytest.mark.parametrize("gridindexingtype", ["mom5"]) # TODO v4: add pop in params?
@pytest.mark.parametrize(
"gridindexingtype",
[
pytest.param(
"mom5",
marks=[
pytest.mark.v4alpha,
pytest.mark.xfail(reason="https://github.com/OceanParcels/Parcels/pull/1936#issuecomment-2717408483"),
],
)
],
) # TODO v4: add pop in params?
@pytest.mark.parametrize("extrapolation", [True, False])
def test_bgrid_interpolation(gridindexingtype, extrapolation):
xi, yi = 3, 2
Expand Down
Loading