Add FACE to dims to check in _update_particle_states_position#2688
Conversation
Resolves the TODO comment and issue #2687
erikvansebille
left a comment
There was a problem hiding this comment.
Good catch and solution; only one question below
| lon_max = float(ds.uxgrid.node_lon.max()) | ||
| pset = ParticleSet(fieldset, lon=[lon_max - 0.1], lat=[10.0], z=[0.5], pclass=Particle) | ||
|
|
||
| with pytest.raises(GridSearchingError): |
There was a problem hiding this comment.
Why does this not throw an ErrorOutOfBounds? Would that not be more similar to how it's done in Sgrid?
There was a problem hiding this comment.
The grid search returns a value of GRID_SEARCH_ERROR on the face index when it's not found in the grid; this is done in spatialhash.query()
There was a problem hiding this comment.
ErrorOutOfBounds is thrown when the search index is -1
GRID_SEARCH_ERROR=-3 which triggers this line
There was a problem hiding this comment.
Why does the Sgrid return a value of grid index -1, corresponding to RIGHT_OUT_OF_BOUNDS ?
GRID_SEARCH_ERROR = -3
LEFT_OUT_OF_BOUNDS = -2
RIGHT_OUT_OF_BOUNDS = -1
There was a problem hiding this comment.
Ah I see; I was confused
We use these LEFT and RIGHT only in the 1d_search:
Parcels/src/parcels/_core/index_search.py
Lines 59 to 60 in 481decc
This is especially useful for z/depth, where users may want to distinguish between a particle moving into the air or into the ground. And it just so happens we can also use it on rectilinear grids in the horizontal, because these use 1d_search
On CurviLinear grids, Xgrid would also not be able to disinguish between LEFT and RIGHT. So your test is fine as is
Resolves the TODO comment and issue #2687
Description
Checklist
mainfor normal development,v3-supportfor v3 support)