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

custom interpolation #3622

Closed
RubendeBruin opened this issue Dec 14, 2019 · 2 comments
Closed

custom interpolation #3622

RubendeBruin opened this issue Dec 14, 2019 · 2 comments

Comments

@RubendeBruin
Copy link

I need to interpolate (wave) forces on a ship between headings and/or frequencies.

heading and frequency are both dimensions.
force is a phase + amplitude pair.

What I would normally do is linear interpolation of the force amplitude and linear interpolation of the unwrapped phase.
Interpolation of the amplitude works fine, but interpolation of the phase is troublesome because I can not unwrap the phases in two dimensions (heading and frequency) at the same time.

A solution that I can think of is storing the phase as a complex number, interpolate that, and then get the phase of the interpolated value. But calculating the angle (phase) from the interpolated values would be slow and it feels like a workaround rather than a good solution.

It would be great if I could pass a custom interpolation function to the interpolate method to use instead of scipy.interpolate.interp1d. But as far as I can see this is not (yet) an option.

@TomNicholas
Copy link
Member

For now you probably want to apply your chosen interpolation method using xarray.apply_ufunc. The documentation on wrapping custom computation using apply_ufunc is here. (You might also be interested on an upcoming tutorial on exactly this topic too.)

@RubendeBruin
Copy link
Author

Thanks for the link to the tutorial!

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

No branches or pull requests

2 participants