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

Move to Interpolations.jl #44

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name = "AtmosphericProfilesLibrary"
uuid = "86bc3604-9858-485a-bdbe-831ec50de11d"
authors = ["Climate Modeling Alliance"]
version = "0.1.5"
version = "0.1.6"

[deps]
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[compat]
Dierckx = "0.5"
Interpolations = "0.14"
julia = "1"
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ A library of atmospheric profiles
| **Docs Build** | [![docs build][docs-bld-img]][docs-bld-url] |
| **Documentation** | [![dev][docs-dev-img]][docs-dev-url] |
| **GHA CI** | [![gha ci][gha-ci-img]][gha-ci-url] |
| **Bors enabled** | [![bors][bors-img]][bors-url] |

[docs-bld-img]: https://github.com/CliMA/AtmosphericProfilesLibrary.jl/actions/workflows/docs.yml/badge.svg
[docs-bld-url]: https://github.com/CliMA/AtmosphericProfilesLibrary.jl/actions/workflows/docs.yml
Expand All @@ -18,8 +17,5 @@ A library of atmospheric profiles
[gha-ci-img]: https://github.com/CliMA/AtmosphericProfilesLibrary.jl/actions/workflows/ci.yml/badge.svg
[gha-ci-url]: https://github.com/CliMA/AtmosphericProfilesLibrary.jl/actions/workflows/ci.yml

[bors-img]: https://bors.tech/images/badge_small.svg
[bors-url]: https://app.bors.tech/repositories/41911

See our [docs](https://CliMA.github.io/AtmosphericProfilesLibrary.jl/dev/) for usage and how to contribute.

10 changes: 0 additions & 10 deletions bors.toml

This file was deleted.

4 changes: 2 additions & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[deps]
AtmosphericProfilesLibrary = "86bc3604-9858-485a-bdbe-831ec50de11d"
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[compat]
Dierckx = "0.5"
Interpolations = "0.14"
1 change: 0 additions & 1 deletion docs/src/define_save_plots.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Plots
import Dierckx

# https://github.com/jheinen/GR.jl/issues/278#issuecomment-587090846
ENV["GKSwstype"] = "nul"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This repository is meant to serve as a library of static functions in efforts to
- `prof = z->2*z` callable by `prof(z)`
- `prof = t->2*t` callable by `prof(t)`
- `prof = (t,z) -> z*t` callable by `prof(t, z)`
- `prof = Dierckx.Spline1D(FT[0, 1, 2], FT[0, 2, 4]; k = 1)` callable by `prof(z)`
- `prof = Interpolations.interpolate(FT[0, 1, 2], FT[0, 2, 4])` callable by `prof(z)`

## How to contribute

Expand Down
7 changes: 6 additions & 1 deletion src/AtmosphericProfilesLibrary.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module AtmosphericProfilesLibrary

import Dierckx
import Interpolations as Intp

abstract type AbstractProfile end
struct TimeProfile{P} <: AbstractProfile
Expand Down Expand Up @@ -28,6 +28,11 @@ struct ΠZProfile{P} <: AbstractProfile
end
@inline (prof::ΠZProfile)(Π, z) = prof.prof(Π, z)

@inline function linear_interp(z, x)
_interp = Intp.interpolate((z, ), x, Intp.Gridded(Intp.Linear()))
return Intp.extrapolate(_interp, Intp.Flat())
end

# Large data-based profiles
include("profiles/Soares.jl")
include("profiles/Nieuwstadt.jl")
Expand Down
19 changes: 8 additions & 11 deletions src/profiles/ARM_SGP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ end
function ARM_SGP_θ_liq_ice(::Type{FT}) where {FT}
z_in = ARM_SGP_z(FT)
θ_liq_ice_in = FT[299.0, 301.5, 302.5, 303.53, 303.7, 307.13, 314.0, 343.2] # K
profile = Dierckx.Spline1D(z_in, θ_liq_ice_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, θ_liq_ice_in))
end
""" [Brown2002](@cite) """
ARM_SGP_u(::Type{FT}) where {FT} = ZProfile(z -> FT(10))
Expand All @@ -18,8 +17,7 @@ function ARM_SGP_q_tot(::Type{FT}) where {FT}
z_in = ARM_SGP_z(FT)
r_in = FT[15.2,15.17,14.98,14.8,14.7,13.5,3.0,3.0] ./ 1000 # qt should be in kg/kg
q_tot_in = r_in ./ (1 .+ r_in)
profile = Dierckx.Spline1D(z_in, q_tot_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, q_tot_in))
end
""" [Brown2002](@cite) """
function ARM_SGP_tke(::Type{FT}) where {FT}
Expand Down Expand Up @@ -49,8 +47,7 @@ function ARM_SGP_tke_prescribed(::Type{FT}) where {FT}
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
not_type_stable_spline = Dierckx.Spline1D(z_in, tke_in; k = 1)
return ZProfile(x -> FT(not_type_stable_spline(x)))
return ZProfile(linear_interp(z_in, tke_in))
end

""" [Brown2002](@cite) """
Expand All @@ -66,8 +63,8 @@ function ARM_SGP_dTdt(::Type{FT}) where {FT}
AT_in = FT[0.0, 0.0, 0.0, -0.08, -0.016, -0.016] ./ 3600
# Radiative forcing for theta [K/h] converted to [K/sec]
RT_in = FT[-0.125, 0.0, 0.0, 0.0, 0.0, -0.1] ./ 3600
dTdt_A = Dierckx.Spline1D(t_in, AT_in; k = 1)
dTdt_R = Dierckx.Spline1D(t_in, RT_in; k = 1)
dTdt_A = linear_interp(t_in, AT_in)
dTdt_R = linear_interp(t_in, RT_in)
prof = (t, z) -> if z <= 1000.0
FT(dTdt_A(t)+dTdt_R(t))
elseif z > 1000.0 && z <= 2000.0
Expand All @@ -83,7 +80,7 @@ function ARM_SGP_dqtdt(::Type{FT}) where {FT}
t_in = ARM_SGP_time(FT)
# Radiative forcing for qt converted to [kg/kg/sec]
Rqt_in = FT[0.08, 0.02, 0.04, -0.1, -0.16, -0.3] ./ 1000 ./ 3600
dqtdt = Dierckx.Spline1D(t_in, Rqt_in; k = 1)
dqtdt = linear_interp(t_in, Rqt_in)
prof = (Π, t, z) -> if z <= 1000.0
FT(dqtdt(t) * Π)
elseif z > 1000.0 && z <= 2000.0
Expand All @@ -98,14 +95,14 @@ end
function ARM_SGP_shf(::Type{FT}) where {FT}
t_Sur_in = FT[0.0, 4.0, 6.5, 7.5, 10.0, 12.5, 14.5] .* 3600 #LES time is in sec
shf = FT[-30.0, 90.0, 140.0, 140.0, 100.0, -10, -10] # W/m^2
profile = Dierckx.Spline1D(t_Sur_in, shf; k = 1)
profile = linear_interp(t_Sur_in, shf)
return TimeProfile(profile)
end

""" [Brown2002](@cite) """
function ARM_SGP_lhf(::Type{FT}) where {FT}
t_Sur_in = FT[0.0, 4.0, 6.5, 7.5, 10.0, 12.5, 14.5] .* 3600 #LES time is in sec
lhf = FT[5.0, 250.0, 450.0, 500.0, 420.0, 180.0, 0.0] # W/m^2
profile = Dierckx.Spline1D(t_Sur_in, lhf; k = 1)
profile = linear_interp(t_Sur_in, lhf)
return TimeProfile(profile)
end
3 changes: 1 addition & 2 deletions src/profiles/Bomex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ function Bomex_tke_prescribed(::Type{FT}) where {FT}
0.1468, 0.1470, 0.1458, 0.1423, 0.1351, 0.1224, 0.1033, 0.0793, 0.0542, 0.0322,
0.0162, 0.0068, 0.0024, 0.0007, 0.0001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
not_type_stable_spline = Dierckx.Spline1D(z_in, tke_in; k = 1)
return ZProfile(x -> FT(not_type_stable_spline(x)))
return ZProfile(linear_interp(z_in, tke_in))
end

# Geostrophic velocity profiles
Expand Down
15 changes: 5 additions & 10 deletions src/profiles/DryBubble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ function DryBubble_θ_liq_ice(::Type{FT}) where {FT}
299.9837, 299.9837, 299.9837, 299.9837, 299.9837, 299.9837,
299.9837, 299.9837
]
profile = Dierckx.Spline1D(z_in, θ_liq_ice_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, θ_liq_ice_in))
end

""" :( """
Expand Down Expand Up @@ -97,8 +96,7 @@ function DryBubble_updrafts_θ_liq_ice(::Type{FT}) where {FT}
300.5212, 300.482 , 300.4272, 300.3875, 300.3354, 300.2968,
300.2587, 300.2216, 300.1782, 300.1452, 300.1143, 300.0859,
300.0603, 300.0408, 300.0211, 300.0067, 299.9963, 299.9884]
profile = Dierckx.Spline1D(z_in, θ_liq_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, θ_liq_in))
end

""" :( """
Expand All @@ -114,8 +112,7 @@ function DryBubble_updrafts_area(::Type{FT}) where {FT}
0.15 , 0.145, 0.145, 0.145, 0.14 , 0.14 , 0.14 , 0.135, 0.135,
0.13 , 0.13 , 0.125, 0.12 , 0.115, 0.115, 0.11 , 0.105, 0.1 ,
0.095, 0.085, 0.08 , 0.07 , 0.055, 0.04]
profile = Dierckx.Spline1D(z_in, Area_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, Area_in))
end

""" :( """
Expand All @@ -132,8 +129,7 @@ function DryBubble_updrafts_w(::Type{FT}) where {FT}
0.1601, 0.1559, 0.1589, 0.1543, 0.1496, 0.1514, 0.1464, 0.1475,
0.1422, 0.1425, 0.1424, 0.1419, 0.1361, 0.135 , 0.1335, 0.1316,
0.1294, 0.1302, 0.1271, 0.1264, 0.1269, 0.1256]
profile = Dierckx.Spline1D(z_in, W_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, W_in))
end

""" :( """
Expand All @@ -153,6 +149,5 @@ function DryBubble_updrafts_T(::Type{FT}) where {FT}
270.4339, 269.9094, 269.3711, 268.8465, 268.311 , 267.7877,
267.2649, 266.7432, 266.2159, 265.698 , 265.1821, 264.6685,
264.1574, 263.6518, 263.1461, 262.6451, 262.1476, 261.6524]
profile = Dierckx.Spline1D(z_in, T_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, T_in))
end
3 changes: 1 addition & 2 deletions src/profiles/Dycoms_RF01.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function Dycoms_RF01_tke_prescribed(::Type{FT}) where {FT}
775.0, 825.0, 875.0, 925.0, 975.0, 1025.0, 1075.0, 1125.0, 1175.0, 1225.0, 1275.0, 1325.0, 1375.0, 1425.0, 1475.0]
tke_in = FT[0.2726, 0.5479, 0.6597, 0.7079, 0.7285, 0.7343, 0.7319, 0.7252, 0.7166, 0.7064, 0.6887, 0.6317,
0.6362, 0.6266, 0.5832, 0.4633, 0.0504, 0.0001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
not_type_stable_spline = Dierckx.Spline1D(z_in, tke_in; k = 1)
return ZProfile(x -> FT(not_type_stable_spline(x)))
return ZProfile(linear_interp(z_in, tke_in))
end

3 changes: 1 addition & 2 deletions src/profiles/GABLS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ GABLS_tke(::Type{FT}) where {FT} =
function GABLS_tke_prescribed(::Type{FT}) where {FT}
z_in = FT[25.0, 75.0, 125.0, 175.0, 225.0, 275.0, 325.0, 375.0]
tke_in = FT[0.4662, 0.3873, 0.2777, 0.0277, 0.0003, 5.89e-8, 0.0, 0.0]
not_type_stable_spline = Dierckx.Spline1D(z_in, tke_in; k = 1)
return ZProfile(x -> FT(not_type_stable_spline(x)))
return ZProfile(linear_interp(z_in, tke_in))
end

""" :( """
Expand Down
16 changes: 6 additions & 10 deletions src/profiles/GATE_III.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ function GATE_III_q_tot(::Type{FT}) where {FT}
0.9, 0.5, 0.25, 0.125, 0.065, 0.003, 0.0015, 0.0007, 0.0003, 0.0001, 0.0001, 0.0001, 0.0001,
0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001] ./ 1000 # mixing ratio should be in kg/kg
q_tot = r_in ./ (1 .+ r_in) # convert mixing ratio to specific humidity
profile = Dierckx.Spline1D(z_in, q_tot; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, q_tot))
end


Expand All @@ -26,8 +25,7 @@ function GATE_III_u(::Type{FT}) where {FT}
U_in = FT[ -1, -1.75, -2.5, -3.6, -6.0, -8.75, -11.75, -13.0, -13.1, -12.1, -11.0, -8.5, -5.0, -2.6, 0.0,
0.5, 0.4, 0.3, 0.0, -1.0, -2.5, -3.5, -4.5, -4.8, -5.0, -3.5, -2.0, -1.0, -1.0, -1.0,
-1.5, -2.0, -2.5, -2.6, -2.7, -3.0, -3.0, -3.0] # [m/s]
profile = Dierckx.Spline1D(z_in, U_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, U_in))
end

""" [Khairoutdinov2009](@cite) """
Expand All @@ -36,8 +34,7 @@ function GATE_III_T(::Type{FT}) where {FT}
z_in = GATE_III_z(FT)
T_in = FT[299.184, 294.836, 294.261, 288.773, 276.698, 265.004, 253.930, 243.662, 227.674, 214.266, 207.757, 201.973, 198.278, 197.414, 198.110, 198.110]
z_T_in = FT[0.0, 0.492, 0.700, 1.698, 3.928, 6.039, 7.795, 9.137, 11.055, 12.645, 13.521, 14.486, 15.448, 16.436, 17.293, 22.0] .* 1000 # for km
profile = Dierckx.Spline1D(z_T_in, T_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_T_in, T_in))
end

""" [Khairoutdinov2009](@cite) """
Expand Down Expand Up @@ -77,8 +74,7 @@ function GATE_III_dqtdt(::Type{FT}) where {FT}
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ./ (24 * 3600) ./ 1000

Qtend_in = r_tend_in ./ (1 .+ r_tend_in) # convert mixing ratio to specific humidity
profile = Dierckx.Spline1D(z_in, Qtend_in; k = 1)
return ZProfile(profile)
return ZProfile(linear_interp(z_in, Qtend_in))
end

""" [Khairoutdinov2009](@cite) """
Expand All @@ -97,7 +93,7 @@ function GATE_III_dTdt(::Type{FT}) where {FT}
-3.7, -3.5, -3.25, -3.0, -2.8, -2.5, -2.1, -1.7, -1.3, -1.0, -0.7, -0.5, -0.4,
-0.3, -0.2, -0.1,-0.05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ./ (24*3600)

profile_T = Dierckx.Spline1D(z_in, Ttend_in; k = 1)
profile_R = Dierckx.Spline1D(z_in, RAD_in; k = 1)
profile_T = linear_interp(z_in, Ttend_in)
profile_R = linear_interp(z_in, RAD_in)
return ZProfile(z -> profile_T(z) + profile_R(z))
end
3 changes: 1 addition & 2 deletions src/profiles/LifeCycleTan2018.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ function LifeCycleTan2018_tke_prescribed(::Type{FT}) where {FT}
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0]
not_type_stable_spline = Dierckx.Spline1D(z_in, tke_in; k = 1)
return ZProfile(x -> FT(not_type_stable_spline(x)))
return ZProfile(linear_interp(z_in, tke_in))
end

# Large-scale cooling
Expand Down
3 changes: 1 addition & 2 deletions src/profiles/Nieuwstadt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ function Nieuwstadt_tke_prescribed(::Type{FT}) where {FT}
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
not_type_stable_spline = Dierckx.Spline1D(z_in, tke_in; k = 1)
return ZProfile(x -> FT(not_type_stable_spline(x)))
return ZProfile(linear_interp(z_in, tke_in))
end
3 changes: 1 addition & 2 deletions src/profiles/Rico.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,5 @@ function Rico_tke_prescribed(::Type{FT}) where {FT}
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0]
not_type_stable_spline = Dierckx.Spline1D(z_in, tke_in; k = 1)
return ZProfile(x -> FT(not_type_stable_spline(x)))
return ZProfile(linear_interp(z_in, tke_in))
end
3 changes: 1 addition & 2 deletions src/profiles/Soares.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ function Soares_tke_prescribed(::Type{FT}) where {FT}
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
not_type_stable_spline = Dierckx.Spline1D(z_in, tke_in; k = 1)
return ZProfile(x -> FT(not_type_stable_spline(x)))
return ZProfile(linear_interp(z_in, tke_in))
end
21 changes: 8 additions & 13 deletions src/profiles/TRMM_LBA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ function TRMM_LBA_p(::Type{FT}) where {FT}
182.3, 167.9, 154.9, 143.0, 131.1, 119.7, 108.9,
100.1, 92.1, 84.6, 77.5, 71.4, 65.9, 60.7,
55.9, 51.3, 47.2, 43.3, 10.3] .* 100 # LES pres is in pasc
prof = Dierckx.Spline1D(z_in, p_in; k = 1)
return ZProfile(prof)
return ZProfile(linear_interp(z_in, p_in))
end
""" [Grabowski2006](@cite) """
function TRMM_LBA_T(::Type{FT}) where {FT}
Expand All @@ -34,8 +33,7 @@ function TRMM_LBA_T(::Type{FT}) where {FT}
-59.16, -63.60, -67.68, -70.77, -74.41, -77.51, -80.64,
-80.69, -80.00, -81.38, -81.17, -78.32, -74.77, -74.52,
-72.62, -70.87, -69.19, -66.90, -66.90] .+ FT(273.15) # LES T is in deg K
prof = Dierckx.Spline1D(z_in, T_in; k = 1)
return ZProfile(prof)
return ZProfile(linear_interp(z_in, T_in))
end
""" [Grabowski2006](@cite) """
function TRMM_LBA_RH(::Type{FT}) where {FT}
Expand All @@ -47,8 +45,7 @@ function TRMM_LBA_RH(::Type{FT}) where {FT}
45.33, 39.78, 33.78, 28.78, 24.67, 20.67, 17.67,
17.11, 16.22, 14.22, 13.00, 13.00, 12.22, 9.56,
7.78, 5.89, 4.33, 3.00, 3.00]
prof = Dierckx.Spline1D(z_in, RH_in; k = 1)
return ZProfile(prof)
return ZProfile(linear_interp(z_in, RH_in))
end
""" [Grabowski2006](@cite) """
function TRMM_LBA_u(::Type{FT}) where {FT}
Expand All @@ -60,8 +57,7 @@ function TRMM_LBA_u(::Type{FT}) where {FT}
-9.00, -7.77, -5.37, -3.88, -1.15, -2.36, -9.20,
-8.01, -5.68, -8.83, -14.51, -15.55, -15.36, -17.67,
-17.82, -18.94, -15.92, -15.32, -15.32]
prof = Dierckx.Spline1D(z_in, u_in; k = 1)
return ZProfile(prof)
return ZProfile(linear_interp(z_in, u_in))
end
""" [Grabowski2006](@cite) """
function TRMM_LBA_v(::Type{FT}) where {FT}
Expand All @@ -73,8 +69,7 @@ function TRMM_LBA_v(::Type{FT}) where {FT}
3.14, 3.93, 7.57, 2.58, 2.50, 6.44, 6.84,
0.19, -2.20, -3.60, 0.56, 6.68, 9.41, 7.03,
5.32, 1.14, -0.65, 5.27, 5.27]
prof = Dierckx.Spline1D(z_in, v_in; k = 1)
return ZProfile(prof)
return ZProfile(linear_interp(z_in, v_in))
end

""" [Grabowski2006](@cite) """
Expand Down Expand Up @@ -110,8 +105,7 @@ function TRMM_LBA_tke_prescribed(::Type{FT}) where {FT}
1.7938 , 1.56451, 1.37531, 1.17515, 0.96797, 0.61262, 0.26423,
0.14929, 0.07465, 0.00635, 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. ]
not_type_stable_spline = Dierckx.Spline1D(z_in, tke_in; k = 1)
return ZProfile(x -> FT(not_type_stable_spline(x)))
return ZProfile(linear_interp(z_in, tke_in))
end


Expand Down Expand Up @@ -234,6 +228,7 @@ function TRMM_LBA_radiation(::Type{FT}) where {FT}
rad_in = reduce(hcat, rad_in)::Matrix{FT}
rad_in .= rad_in ./ 86400
rad_in = (rad_in')::LinearAlgebra.Adjoint{FT, Matrix{FT}}
profile = Dierckx.Spline2D(rad_time, z_in, rad_in; kx = 1, ky = 1)
interp = Intp.interpolate((rad_time, z_in), rad_in, (Intp.Gridded(Intp.Linear()), Intp.Gridded(Intp.Linear())))
profile = Intp.extrapolate(interp, Intp.Flat())
return TimeZProfile(profile)
end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AtmosphericProfilesLibrary as APL
iscallable(f) = !isempty(methods(f))

function test_profile(::Type{FT}, prof, name) where {FT}
@debug "Testing $name"
# println("Testing $name")
if prof isa APL.TimeProfile
prof(1)
@inferred prof(Float32(1))
Expand Down
Loading