-
Notifications
You must be signed in to change notification settings - Fork 24
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
Interpolation: AbstractGrid -> arbitrary grid #212
Conversation
Great work, Milan! Also, for computational performance, instead of anvil averaging, you could consider using the two-step interpolation (i.e., doing longitude interpolations for the adjacent rings, then doing latitudinal interpolation using the interpolated value that align on the same longitude). Perhaps we can introduce |
Yes, absolutely. I thought I start easy though and I like your idea to introduce
The latter is what I've implemented here, I've tried to sketch this in the docstring
So first we interpolate onto the |
Re: Generalisation. We now have abstract type AbstractLocator{NF} end
struct AnvilLocator{NF<:AbstractFloat} <: AbstractLocator{NF}
abstract type AbstractInterpolator{NF,G} end
struct AnvilInterpolator{NF<:AbstractFloat,G<:AbstractGrid} <: AbstractInterpolator{NF,G}
geometry::GridGeometry{G}
locator::AnvilLocator{NF}
end So only a |
Thank you, Milan! and sorry that I commented without carefully reading the code. I am always impressed with the elegance of the code that you write in Julia. Thank you! |
Ha! Thanks but I feel a lot of elegance credit also goes to Julia. |
@hottad I felt today like writing an
Interpolator
to get from any Grid<:AbstractGrid to an arbitrary grid that's just defined by two vectors of latitude/longitude points. This should allow us to have a semi-Lagrangian advection scheme and also allows us to get from one grid to another without going through spectral space. E.g.Done. 🥳
What happens under the hood is that we create
I::Interpolator
which knows about the geometry ofA::AbstractGrid
and contains the arrays that define which grid points of A have to be used to interpolate onto all the θs,λs and with which weightsNow the Interpolator can be used but also reused in case several different fields should be interpolated onto the same grid
I still need to test that everything works and it should already be type-stable and flexible. We could even put a
interpolate!(B::AbstractGrid,A::AbstractGrid)
on top of these functions and can then conveniently jump between all our grids.