Repository navigation
Uxgrid edge data interpolators - #3012
Conversation
for more information, see https://pre-commit.ci
…ode/Parcels into uxgrid-edge-data-interpolators
erikvansebille
left a comment
There was a problem hiding this comment.
PR looks good - just one request below
| assert np.allclose(fieldset.p.eval(t=tq, z=zq, y=yq, x=xq), zc * (xq + yq)) | ||
|
|
||
|
|
||
| def test_from_ugrid_conventions_selects_correct_interpolator(): |
There was a problem hiding this comment.
Can you also add a test for correctness? E.g. with a simple field where you can calculate the answer by hand? So that we can make sure that the interpolator doesn't break in the future?
There was a problem hiding this comment.
Added in 82a15bf. I also realized that none of the other UxGrid interpolators have testing for this kind of thing either. I'll open an issue on this tomorrow.
| edim: xr.DataArray(edge_ids, dims=("points", "edges")), | ||
| } | ||
| edge_data = field.data.isel(selection_dict, ignore_grid=True) | ||
| value = edge_data.mean("edges").data # Face value is the mean of its surrounding edges |
There was a problem hiding this comment.
So this is essentially piecewise constant ? What if I have an edge that is much shorter than the other 2 ? Is it's value as important as the others in constructing the value for the face ?
There was a problem hiding this comment.
My understanding is that the centroid is the mean of the node locations. So this is just averaging to the centroid and then using piecewise constant. The default interpolator for n_face is also piecewise constant so I think this is fine for now.
Long term it would be great to add more complex interpolation methods for unstructured grids, I'll open an issue on this?
Description
This PR adds built in interpolators for edge registered UxGrid data, it also adds testing for the default selection of uxinterpolators during fieldset creation.
The two interpolators match existing built in convention for constant
ZCand linearZFinterpolation, while doing piecewise constant lateral interpolation by averaging edge data to face centers.Checklist
from_ugrid_conventionscrashes with opaqueTypeErrorfor extra variables with unsupported dimension layouts #2674mainfor normal development,v3-supportfor v3 support)AI Disclosure
ZCinterpolator and then asked opus 5.5 to do the matching case for linearZF. I reviewed all code produced by the llm.