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

Add linear path through projection coordinates to cross_section as alternative option to geodesic #2463

Open
jthielen opened this issue Apr 29, 2022 · 0 comments
Labels
Area: Cross-sections Pertains to making cross-sections through data good first issue Straightforward issues suitable for new and inexperienced contributors to the project Type: Feature New functionality

Comments

@jthielen
Copy link
Collaborator

What should we add?

Currently, metpy.interpolate.cross_section only operates by interpolating to a geodesic between specified start and end points. This becomes problematic when:

  • Data are not georeferenced (e.g., idealized cloud models)
  • User wants a straight path in the projection of their data (e.g., a rhumb line in lat/lon data)
  • User seeks one of the dimensions of target points to be aligned with source points (so as to minimize interpolation artifacts)

I'd like to see something like a new path_type kwarg on cross_section. It would default to "geodesic", which has current behavior, but we would add a new "linear" option, which would construct points something like the following:

x_range_source = data.metpy.x.metpy.sel(x=slice(start[0], end[0])).values
y_range_source = data.metpy.y.metpy.sel(y=slice(start[1], end[1])).values

if steps is None:
    steps = max(len(x_range_source), len(y_range_source))

x_range_target = np.linspace(x_range_source[0], x_range_source[-1], steps)
y_range_target = np.linspace(y_range_source[0], y_range_source[-1], steps)
    
points_cross = np.stack([x_range_target, y_range_target], axis=1)

Note this also makes steps an optional argument rather than defaulting to 100 (which we could probably still implement as default for the "geodesic" option for backwards compatibility). Also, I wrote this sketch assuming start and end are (x, y) pairs...which I like for projection coordinates over (y, x), but really don't like for lon and lat (since that is flipped from (lat, lon) used with geodesic). Not sure the best solution there.

Reference

No response

@jthielen jthielen added Type: Feature New functionality good first issue Straightforward issues suitable for new and inexperienced contributors to the project Area: Cross-sections Pertains to making cross-sections through data labels Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Cross-sections Pertains to making cross-sections through data good first issue Straightforward issues suitable for new and inexperienced contributors to the project Type: Feature New functionality
Projects
Status: No status
Development

No branches or pull requests

1 participant