-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support creating global graphs by introducing haversine distance metric #37
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: sadamov <[email protected]>
This is neat :) I did not know that Something I am thinking about around this is to what extent the "rectangular" layout of mesh nodes makes sense when we use a different metric as distance. In some sense the concept of equally spaced rows and columns of mesh nodes would be different for a different metric. Now this implementation is only concerned with the connections between mesh and grid. And yes, I understand this is just an example demonstration. Just wanted to put my thoughts here for future reference 😄 |
Yes! It's quite a heavy dependency though, so we might want to make it optional... We'll see
Yes, that is true. The current "rectangular" layout (I wish I could think of a better name...) implemented would spacing lat/lon values equally apart, but that would then not be equidistantly spaced with for example the haversine metric. Hmm... I was also thinking that if want to introduce other types of mesh layout than this "rectangular" layout then we might need to change/adapt the arguments a bit. Maybe if we do that then we could add a warning/raise an exception if someone tries to use a "rectangular" layout while trying to use the haversine distance for the g2m and m2g connectivity. Does that make sense? I think this would benefit from some examples in a notebook... 😆
Yes unless it (the distance metric) starts playing a role in mesh layout too. If you contrast making a triangular mesh layout on a plane vs on a sphere, you might want to set the mesh-spacing by applying a different metric in the two cases. |
Maybe rectilinear would be a better name for the "layout" of the mesh? |
Rectilinear is probably the correct term yes. We wrote that in a paper and then I have stopped using it. I realize that there's hardly anyone that read rectilinear and immediately understands what you mean, whereas just writing rectangular is wrong, but people understand you 😄 |
Describe your changes
A student I am working with would like to look at emulating 1D fluid simulations on a periodic 1D domain with neural-lam. I thought an easy way to create a 1D periodic domain was to just create a line along the equator and use haversine distance to do the mesh-generation and grid-to-mesh connections. This PR is a proof-of-concept that builds on #32 to make that possible.
The PR introduces the
distance_metric
argument (which defaults toeuclidean
) to all graph generation functions, so that this metric is used when computing distances. By using thehaversine
distance metric and also not providing aprojection
argument then we can create a 1D periodic domain that wraps the equator:The PR also adapts the flat-mesh creation routines to ensure that both the "x" and "y" directions have at least one grid point (this is necessary when the point-to-point span of on direction, here the poleward direction, is zero).
The haversine distance calculation is used within the Ball-tree implementation in
scikit-learn
which has been added as a dependency.NB: the hierarchical graph generation doesn't work yet, I think because the graph refinement is applied in both "x" and "y" directions for now. I will try and fix this.
NB no 2: this PR does not add more clever mesh-geometries than the "rectangular" mesh that we already have. I think how this should fit into the existing codebase needs a bit more thought. But I just wanted to show you all what I have done :)
Issue Link
This builds on #32 and the suggestion I gave in there that the generalisation in #32 allows for.
Type of change
Checklist before requesting a review
pull
with--rebase
option if possible).Checklist for reviewers
Each PR comes with its own improvements and flaws. The reviewer should check the following:
Author checklist after completed review
reflecting type of change (add section where missing):
Checklist for assignee