Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for grid.negate_depth() method #1778

Merged
merged 4 commits into from
Nov 28, 2024
Merged

Conversation

erikvansebille
Copy link
Member

This PR adds a grid.negate_depth() method, which can be useful when the depth needs to be flipped from positive to negative values. This is the case for example in the VirtualShip package:
https://github.com/OceanParcels/virtualship/blob/44eae19e55545166c446e8eabe7c76ab13d7344b/src/virtualship/expedition/input_data.py#L98-L100

Note that this method does not change the direction of the vertical velocity; for that users need to add a fieldset.W.set_scaling_factor(-1.0)

This fixes #1746

This is useful when the depth needs to be flipped from positive to negative values. Note that this does _not_ change the direction of the vertical velocity; for that users need to add a fieldset.W.set_scaling_factor(-1.0)
@erikvansebille erikvansebille marked this pull request as ready for review November 27, 2024 08:57
Copy link
Contributor

@VeckoTheGecko VeckoTheGecko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Maybe we could add a simple docstring detailing some of the stuff that you have mentioned here about why it's useful? Also maybe specifying that the grid classes don't really support grid manipulation beyond this simple case (as that is beyond the scope of Parcels).

@erikvansebille erikvansebille merged commit e709843 into master Nov 28, 2024
15 checks passed
@erikvansebille erikvansebille deleted the grid_negate_depth branch November 28, 2024 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Create a grid.negate_depth method to swap the sign of depth fields?
2 participants