Fixing OutOfBounds errors on field.eval (attempt 2) #2681
Fixing OutOfBounds errors on field.eval (attempt 2) #2681erikvansebille wants to merge 8 commits into
Conversation
By masking out all the interpolated values to zero for particles out of bound
fluidnumericsJoe
left a comment
There was a problem hiding this comment.
This PR is a straightforward fix that applies a mask to the interpolated values for particles that are aligned with negative indices. The masking function, in its current form, assumes grid_position dimensions are X, Y and Z; this is only valid for structured grids - while this resolves the associated issue, it would introduce a breaking scenario for unstructured grids.
I've provided comments on the code changes that suggest a path forward .
And filtering this warning in kernel execution
VeckoTheGecko
left a comment
There was a problem hiding this comment.
Code changes look good! Some comments about the tests though.
Do any changes to docs/migration guide need to be made?
Also, could we wait to merge this until #2646 is merged? (I think it would be easier to do that than have to deal with conflicts introduced in this PR on the other end)
| "FieldEvalWarning", | ||
| "FieldSetWarning", | ||
| "FileWarning", | ||
| "KernelWarning", |
There was a problem hiding this comment.
nit: I wonder whether we should have a parcels.warnings namespace.
I'm not strongly for or against - just a convention some packages adopt.
Similarly for parcels.errors.
There was a problem hiding this comment.
Something for a separate PR? Do you want to turn this into an Issue?
No, I don't think so. The normal Parcels workflow hasn't changed; the only change is that users now see a Warning if they direct call
Sure, let's first merge #2646 |
Description
This PR supersedes #2665 by going for another approach to fixing OutOfBound errors. Instead of setting the
GRID_SEARCH_ERROR,LEFT_OUT_OF_BOUNDSandRIGHT_OUT_OF_BOUNDSvariables to very large numbers (which leads to IndexErrors in e.g. the RK4 kernel), this PR masks the returned values of particles that are out of bound to zeroIn doing so, I also found that a few of the default interpolators didn't return numpy arrays (see also 2114), so that had to be fixed for all the tests to pass too
Checklist
Field.evalsilently returns wrong values for out-of-domain queries #2629 (attempt 2)mainfor normal development,v3-supportfor v3 support)AI Disclosure