Skip to content

Taking a cross section of data (2d lat and lon) #5921

Answered by jthielen
pecos27 asked this question in Q&A
Discussion options

You must be logged in to vote

As you noted, having 1D dimension coordinates enables xarray's vectorized indexing functionality (which is all MetPy is doing under the hood). And so, one solution to taking a cross section when you have 2D lon and lat arrays (and probably the most efficient) is to re-derive the "missing" x and y 1D dimension coordinates given your data's projection (if sticking with MetPy, assign_y_x should do the trick if you've added the projection information properly), and then use that built-in vectorized indexing.

Alternatively, you can index the data with the 2D lon and lat arrays directly using the extension package xoak, as in this example. While this is likely to be less efficient (and may requ…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pecos27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants