Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-regularly gridded and lat-lon coordinates #29

Closed
joeloskarsson opened this issue Oct 2, 2024 · 3 comments · Fixed by #32
Closed

Allow non-regularly gridded and lat-lon coordinates #29

joeloskarsson opened this issue Oct 2, 2024 · 3 comments · Fixed by #32
Assignees
Labels
enhancement New feature or request

Comments

@joeloskarsson
Copy link
Contributor

This issue is to document and discuss some enhancements I am looking into w.r.t. the coordinates used as inputs.

The current situation

Currently the grid node coordinates fed to wmg are a numpy array of shape [2, N_y, N_x]. This assumes that the grid nodes are on a regular grid. It is also the case that these are assumed to be cartesian coordinates, in the projection used for the LAM data.

Generalizing to non-regular gridded data

My idea to generalize this is to change so that the coordinate array xy instead has shape [N_grid_nodes, 2] with e.g. xy[:,0] containing the x-coordinate for all grid nodes. Existing mesh creation algorithms would still have to work with a rectangular area, for which they can use the axis-aligned bounding box of the grid nodes. Other, new, mesh creation methods could use the convex hull of the set of grid nodes.

Generalizing to allow lat-lon coordinates

For lat-lon coordinates the same [N_grid_nodes, 2] shape could be used for the coordinates. It would also be good to feed a projection specification (I propose a Cartopy projection instance, https://scitools.org.uk/cartopy/docs/latest/reference/generated/cartopy.crs.Projection.html). Using the projection the lat-lon coordinates can then be mapped to a euclidean space and all our current methods can be applied as is. Having the option of lat-lon coordinates however also opens up the opportunity for mesh creation methods that work directly with these.

A question is how to tell wmg if in-projection or lat-lon coordinates are given. Some options are:

  • Have separate arguments xy and lat_lon where only one has to be given.
  • Have only one argument coords, and then a separate boolean flag e.g. uses_lat_lon.
  • One could also enforce that a projection has to be given when using lat-lon coordinates, and use that implicitly as the uses_lat_lon flag above.
  • Another option is really to only allow lat-lon coordinates from here onwards.

Not really sure what is the best option of the ones above. Any input is appreciated.

@joeloskarsson joeloskarsson added the enhancement New feature or request label Oct 2, 2024
@joeloskarsson joeloskarsson self-assigned this Oct 2, 2024
@joeloskarsson joeloskarsson changed the title Allow non-grid and lat-lon coordinates Allow non-regularly gridded and lat-lon coordinates Oct 2, 2024
@joeloskarsson
Copy link
Contributor Author

I also realize that the concept of grid_refinement_factor is defined in terms of the number of grid nodes in the x- and y-directions. This will not make sense for irregularly positioned grid nodes. So likely this will have to be generalized to a refinement in terms of actual distances, rather than number of nodes. Which probably makes more sense anyhow (and you can always find a mapping in-between).

@joeloskarsson
Copy link
Contributor Author

Currently being worked on in #32

@joeloskarsson
Copy link
Contributor Author

Now the option

One could also enforce that a projection has to be given when using lat-lon coordinates, and use that implicitly as the uses_lat_lon flag above.

is what is implemented in #32 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant