From 6f843e969f51cbe6cce0aa374889d3a9b0e49693 Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Wed, 6 Nov 2024 08:05:33 +0100 Subject: [PATCH] Using private grid._depth for negating depth (#75) * 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? * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/virtualship/expedition/input_data.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/virtualship/expedition/input_data.py b/src/virtualship/expedition/input_data.py index 7af9ef72..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 + 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 +139,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 +171,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)