Skip to content

Commit

Permalink
Using private grid._depth for negating depth (OceanParcels#75)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
erikvansebille and pre-commit-ci[bot] authored Nov 6, 2024
1 parent 8cdf931 commit 6f843e9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/virtualship/expedition/input_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6f843e9

Please sign in to comment.