From 7ecb9e855d4a7d0b82bd93fee2c47cdff22177e4 Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Thu, 31 Oct 2024 18:56:48 +0100 Subject: [PATCH 1/2] Using private grid._depth for negating depth As Parcels v3.1.0 has moved from `grid.depth` to `grid._depth`, the code for VirtualShip is now broken. THis PR fixes that, although a more propoer implementation would be to add a grid.negate_depth() method to Parcels itself? --- src/virtualship/expedition/input_data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/virtualship/expedition/input_data.py b/src/virtualship/expedition/input_data.py index 7af9ef72..19f8ae94 100644 --- a/src/virtualship/expedition/input_data.py +++ b/src/virtualship/expedition/input_data.py @@ -97,7 +97,7 @@ def _load_default_fieldset(cls, directory: str | Path) -> FieldSet: # make depth negative for g in fieldset.gridset.grids: - g.depth = -g.depth + g._depth = -g._depth # TODO maybe add a grid.negate_depth() method in Parcels? # add bathymetry data bathymetry_file = directory.joinpath("bathymetry.nc") @@ -137,7 +137,7 @@ def _load_drifter_fieldset(cls, directory: str | Path) -> FieldSet: # make depth negative for g in fieldset.gridset.grids: - g.depth = -g.depth + g._depth = -g._depth # read in data already fieldset.computeTimeChunk(0, 1) @@ -169,7 +169,7 @@ def _load_argo_float_fieldset(cls, directory: str | Path) -> FieldSet: # make depth negative for g in fieldset.gridset.grids: if max(g.depth) > 0: - g.depth = -g.depth + g._depth = -g._depth # read in data already fieldset.computeTimeChunk(0, 1) From cc5738ebc5284600afb120c18fc98f283ab6f427 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:58:13 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/virtualship/expedition/input_data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/virtualship/expedition/input_data.py b/src/virtualship/expedition/input_data.py index 19f8ae94..a280c477 100644 --- a/src/virtualship/expedition/input_data.py +++ b/src/virtualship/expedition/input_data.py @@ -97,7 +97,9 @@ def _load_default_fieldset(cls, directory: str | Path) -> FieldSet: # make depth negative for g in fieldset.gridset.grids: - g._depth = -g._depth # TODO maybe add a grid.negate_depth() method in Parcels? + g._depth = ( + -g._depth + ) # TODO maybe add a grid.negate_depth() method in Parcels? # add bathymetry data bathymetry_file = directory.joinpath("bathymetry.nc")