Skip to content

Structured grid index searching and computing barycentric coordinates #2035

@VeckoTheGecko

Description

@VeckoTheGecko

To enable indexing and interpolation, we need to (with respect to the tracer cells) provide:

  • XGrid.search: finds the tracer cell that the particle lives in, and its position in barycentric coordinates
  • XGrid.ravel and XGrid.unravel convert to and from ei and the tracer cells index

Details:

  • Update init to require longitude and latitude arrays are provided as coordinates
    • lon and lat arrays need to have dimensions that are axis directions on the F-points (i.e., not "center" in xgcm world)
  • create index searching methods that work for 1D and 2D lon, lat arrays
    • 1D: Simple argmin() calls (as done in the v3 codebase)
    • 2D: Can check every cell to see if the point is inside (similar to what is done in the unstructured case). I was initially thinking we could do some performance optimisation by constructing larger quads and then binary searching down, but I concluded that this wouldn't work in the general case. This can be left for further improvement if the need arrises.
      • I'll also look at the v3 code to see if there's any inspiration I should take from there

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions