Add support for multi-dimensional coordinates in from_structured #202
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@roeldegoede:
I realized the name
rotated
isn't appropriate: supporting multi-dimensional coordinates is more general, e.g. if you have a curvilinear grid (which is approximated by straight edges). I also ran into the trouble of finding out how the coordinates are called. In your example, they are calledxc
andyc
, but in many other cases they will have different names.This implementation currently assumes that the last two logical dimensions are always called ("y", "x"), but the multi-dimensional coordinates may be arbitrarily named. They could technically be identified by their attrs (if set), but this seems much simpler.
Taking your example in the issue:
This doesn't specifiy the x and y coordinates, so it works as before: it looks at the x and y dimensions/coordinates. In this case, they are unlabeled, so they are just a range of 0...N.
To succesfully use the multi-dimensional coordinates, specify them explicitly:
This seems to work, if we check with a plot of the original:
The
.ugrid.plot
seems a bit sharper, maybe due to how to matplotlib treats a PolyCollection (bit of a surprise to me).