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

Switch from Dierckx.jl to Interpolations.jl #43

Closed
Sbozzolo opened this issue Jul 2, 2024 · 11 comments · Fixed by #44
Closed

Switch from Dierckx.jl to Interpolations.jl #43

Sbozzolo opened this issue Jul 2, 2024 · 11 comments · Fixed by #44

Comments

@Sbozzolo
Copy link
Member

Sbozzolo commented Jul 2, 2024

Dierckx does not preserve type kbarbary/Dierckx.jl#48 and it is not GPU compatible. It also has some loading costs that can be avoided.

@Sbozzolo Sbozzolo transferred this issue from CliMA/ClimaAtmos.jl Jul 2, 2024
@szy21
Copy link
Member

szy21 commented Jul 2, 2024

Yes. I tried to fix it here some time ago: #39. But it didn't work.

@Sbozzolo Sbozzolo changed the title diagnostic_edmfx_trmm_box_0M.yml cannot be run in Float32 TRMM does not preserve float time Jul 2, 2024
@Sbozzolo Sbozzolo changed the title TRMM does not preserve float time Profiles do not preserve float type Jul 2, 2024
@charleskawczynski
Copy link
Member

This is an upstream issue: kbarbary/Dierckx.jl#48

@Sbozzolo
Copy link
Member Author

Sbozzolo commented Jul 2, 2024

Is it fine to switch to linear interpolation?

If yes, we can move to Interpolations.jl, which is GPU compatible, and stop using Dierckx.

@charleskawczynski
Copy link
Member

julia> x = Float32[1,2];

julia> z = Float32[1,2];

julia> Dierckx.Spline1D(z, x; k = 1)(Float32(2))
2.0

@charleskawczynski
Copy link
Member

Perhaps we could switch to Interpolations.jl. Although: JuliaMath/Interpolations.jl#598

@charleskawczynski
Copy link
Member

Also, it has quite a few dependencies: https://github.com/JuliaMath/Interpolations.jl/blob/master/Project.toml#L6-L17

@charleskawczynski
Copy link
Member

I had actually thought about writing our own, e.g., SimpleInterpolations.jl. Make it GPU compatible and type-stable.

@charleskawczynski
Copy link
Member

Honestly, we could roll our own very simply interpolation package. Ah right: https://github.com/CliMA/SimpleInterpolations.jl. I just never got it off the ground

@Sbozzolo
Copy link
Member Author

Sbozzolo commented Jul 2, 2024

We are already using Interpolations.jl because it is the only package that is GPU compatible and supports 3D interpolations on irregular grids (needed to read in aerosol data for example).

It seems to be type-preserving:

B = Float32[1, 2, 10, 20, 30]
5-element Vector{Float32}:
  1.0
  2.0
 10.0
 20.0
 30.0

julia> A = Float32[1, 2, 10, 20, 30]
5-element Vector{Float32}:
  1.0
  2.0
 10.0
 20.0
 30.0

julia> itp = interpolate((A, ), B, Gridded(Linear()))
5-element interpolate((::Vector{Float32},), ::Vector{Float32}, Gridded(Linear())) with element type Float32:
  1.0
  2.0
 10.0
 20.0
 30.0

julia> itp(2.0)
2.0

julia> itp(2.f0)
2.0f0

@charleskawczynski
Copy link
Member

Sure, switching to Interpolations is fine by me. Alternatively, we could wrap types to recover type stability in this package, which might be a quicker solution, but more of a bandaid.

@charleskawczynski
Copy link
Member

Should we rename the issue to "Switch from Dierckx.jl to Interpolations.jl"?

@Sbozzolo Sbozzolo changed the title Profiles do not preserve float type Switch from Dierckx.jl to Interpolations.jl Jul 2, 2024
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

Successfully merging a pull request may close this issue.

3 participants