You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct FastLinear1DInterpolationMethod <:AbstractInterpolationMethodend# Consider repalcing one day with Interpolations.jl - That has Linear() NoInterp() and Throw() BCs... and can hold SVectors and be isbits etc. Notably, however, integration is missing natively so we'd have to implement it, but `Interpolations.gradient()` is provided for the derivative
# struct InterpolaionsJLMethod <: AbstractInterpolationMethod end # Has so many methods
82
+
50
83
51
84
create_svector(x::AbstractVector) = StaticArrays.SVector{length(x)}(x) # create an SVector from an array, this is the same as SVector(x...) but faster [still slow bc length(x) is looked up at compile time]
52
85
create_svector(x::NTuple{N, FT}) where {FT, N} = StaticArrays.SVector{N, FT}(x) # create an SVector from a tuple, this is the same as SVector(x...) but faster [still slow bc length(x) is looked up at compile time]
Copy file name to clipboardExpand all lines: src/get_LES_reference_profiles.jl
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -59,17 +59,17 @@ function get_LES_reference_profiles(
59
59
ps = LES_data["Ps"][1] *100.0# surface pressure
60
60
ρ = NC.nomissing(LES_data["RHO"][:, 1]) # use t=0 as our reference
61
61
# extrapolate to get ρs since that's not given (not calculating from first principles probably is safer too w/ uncertainty in q)
62
-
ρs = interpolate_1d(ps, reverse(p), reverse(ρ), FastLinear1DInterpolation, bc ="extrapolate") # switch to increasing for interpolation
62
+
ρs = interpolate_1d(ps, reverse(p), reverse(ρ), FastLinear1DInterpolation, bc =ExtrapolateBoundaryCondition()) # switch to increasing for interpolation
63
63
64
64
# Consider switching to SVector but probably not worth it for now since the high res grids can have 320 levels
65
65
p = [ps; p]
66
66
ρ = [ρs; ρ]
67
67
z = [0; z]
68
68
69
-
p_c = interpolate_1d(new_zc, z, p, FastLinear1DInterpolation; bc ="nearest")
70
-
p_f = interpolate_1d(new_zf, z, p, FastLinear1DInterpolation; bc ="nearest")
71
-
ρ_c = interpolate_1d(new_zc, z, ρ, FastLinear1DInterpolation; bc ="nearest")
72
-
ρ_f = interpolate_1d(new_zf, z, ρ, FastLinear1DInterpolation; bc ="nearest")
69
+
p_c = interpolate_1d(new_zc, z, p, FastLinear1DInterpolation; bc =NearestBoundaryCondition())
70
+
p_f = interpolate_1d(new_zf, z, p, FastLinear1DInterpolation; bc =NearestBoundaryCondition())
71
+
ρ_c = interpolate_1d(new_zc, z, ρ, FastLinear1DInterpolation; bc =NearestBoundaryCondition())
72
+
ρ_f = interpolate_1d(new_zf, z, ρ, FastLinear1DInterpolation; bc =NearestBoundaryCondition())
Copy file name to clipboardExpand all lines: src/helper_functions.jl
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ function lev_to_z_from_LES_output_column(
128
128
# Load pressure from the thermodynamic state
129
129
p_in = TD.air_pressure.(thermo_params, tsz)
130
130
# Interpolate z from the LES output to the pressure levels of the thermodynamic state
131
-
z_out = interpolate_1d(p_in, lesp, lesz, interp_method; bc ="error")
131
+
z_out = interpolate_1d(p_in, lesp, lesz, interp_method; bc =ErrorBoundaryCondition())
132
132
return z_out
133
133
end
134
134
@@ -196,8 +196,11 @@ function lev_to_z_from_LES_output(
196
196
197
197
# interpolate les output data to input times (instead of just choosing the `closest` hour like we did before... (need to apply by row)
198
198
# i think you need to map this bc of the splines... but there's probably some way...
199
-
p_LES =
200
-
mapslices(x -> interpolate_1d(t_in, t_les, x, FastLinear1DInterpolation; bc ="nearest"), p_LES; dims =2) # apply to each row, use nearest interp but outside les time bounds is bogus
199
+
p_LES = mapslices(
200
+
x -> interpolate_1d(t_in, t_les, x, FastLinear1DInterpolation; bc = NearestBoundaryCondition()),
201
+
p_LES;
202
+
dims =2,
203
+
) # apply to each row, use nearest interp but outside les time bounds is bogus
201
204
202
205
tsz = ts
203
206
@@ -643,9 +646,9 @@ function interp_along_dim(
643
646
f_enhancement_factor = get(interp_kwargs, :f_enhancement_factor, 1) # default to 1.0
644
647
f_p_enhancement_factor = get(interp_kwargs, :f_p_enhancement_factor, 1) # default to 1.0
645
648
if conservative_interp
646
-
bc = get(interp_kwargs, :bc, "extrapolate") # default to extrapolate
649
+
bc::AbstractBoundaryCondition=create_bc(get(interp_kwargs, :bc, ExtrapolateBoundaryCondition())) # default to extrapolate
647
650
else
648
-
bc = get(interp_kwargs, :bc, "error") # default to error
651
+
bc =create_bc(get(interp_kwargs, :bc, ErrorBoundaryCondition())) # default to error
# qg = (1 / molmass_ratio) .* pvg ./ (pg .- pvg) #Total water mixing ratio at surface , assuming saturation [ add source ]
1243
1246
1244
1247
# not sure if this should be linear in p or logarithmic (linear in z), gonna do linear in p
1245
-
qg = interpolate_1d(pg, p, q, interp_method; bc ="extrapolate") # default to spline1d for extrapolation as pchip may not be the most reliable outside bounds of data.
1248
+
qg = interpolate_1d(pg, p, q, interp_method; bc =ExtrapolateBoundaryCondition()) # default to spline1d for extrapolation as pchip may not be the most reliable outside bounds of data.
1246
1249
# qg = interpolate_1d(log.(pg), log.(p), q, interp_method; bc="extrapolate") # default to spline1d for extrapolation as pchip may not be the most reliable outside bounds of data.
0 commit comments