Skip to content

use zero for land-values throughout Parcels#2762

Open
erikvansebille wants to merge 2 commits into
Parcels-code:mainfrom
erikvansebille:land_filling
Open

use zero for land-values throughout Parcels#2762
erikvansebille wants to merge 2 commits into
Parcels-code:mainfrom
erikvansebille:land_filling

Conversation

@erikvansebille

Copy link
Copy Markdown
Member

Description

This PR implements the definition that land values are zero in Parcels. This choice is intuitive for velocities (since ocean velocities are zero on land) and is needed for slip boundary conditions. For tracer fields, using zero for land also works nicer because NaNs currently throw errors. The XLinearInvdistLandTracer interpolator also assumes that land is 0.0

This PR adds a _assert_no_nan_in_field_data() function that throws a ValueError when there are NaNs in the Sgrid-dataset, and adds fillna(0) calls to some of the convert functions.

This PR supersedes #2451

Checklist

AI Disclosure

None

Comment on lines +514 to +515
arr = field_data.isel(time=0) if "time" in field_data.dims else field_data
if xr.ufuncs.isnan(arr).any():

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since isnan is not a lazy function, we need to be careful not to check the entire DataArray. Here only checking the first time step, under the assumption that if there is no land in that first time step it will also not be there in other time steps

Admittedly, this is a bit of a hacky fix, since we have to compute the entire first time slice of each Field

If you know of a cleaner way to do this, I'd be very open to that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Land as np.nan or 0 in v4?

1 participant