Skip to content
Snippets Groups Projects
Commit 5c8c79e5 authored by Brian Groenke's avatar Brian Groenke
Browse files

Fix units not being correctly stripped in interpolateprofile!

parent bb9a6716
No related branches found
No related tags found
1 merge request!37Add nfactors for dampening wintertime air temperature forcings
......@@ -119,8 +119,8 @@ function interpolateprofile!(profile::DimArray, state; interp=Linear())
let (depths,names) = dims(profile),
z = ustrip.(depths);
for p in names
f = extrapolate(interpolate((z,), profile[:,p], Gridded(interp)), Flat())
state[p] .= f.(state.grids[p]) .|> dustrip # assume length(grid) == length(state.p)
f = extrapolate(interpolate((z,), ustrip.(profile[:,p]), Gridded(interp)), Flat())
state[p] .= f.(state.grids[p]) # assume length(grid) == length(state.p)
end
end
end
......
......@@ -64,18 +64,6 @@ export Params
export tuplejoin
"""
Debug ustrip. Remove units if and only if debug mode is NOT enabled.
"""
dustrip(x::Number) = CryoGrid.CRYOGRID_DEBUG ? x : ustrip(x)
dustrip(u::Unitful.Units, x::Number) = CryoGrid.CRYOGRID_DEBUG ? x : ustrip(u,x)
export dustrip
duconvert(u::Unitful.Units, x::Number) = CryoGrid.CRYOGRID_DEBUG ? x : uconvert(u,x)
export duconvert
getscalar(x::Number) = x
getscalar(a::AbstractArray) = a[1]
......@@ -128,4 +116,16 @@ adstrip(x::Number) = x
adstrip(x::ForwardDiff.Dual) = ForwardDiff.value(x) |> adstrip
adstrip(x::ReverseDiff.TrackedReal) = x.value
"""
Debug ustrip. Remove units if and only if debug mode is NOT enabled.
"""
dustrip(x::Number) = CryoGrid.CRYOGRID_DEBUG ? x : ustrip(x)
dustrip(u::Unitful.Units, x::Number) = CryoGrid.CRYOGRID_DEBUG ? x : ustrip(u,x)
export dustrip
duconvert(u::Unitful.Units, x::Number) = CryoGrid.CRYOGRID_DEBUG ? x : uconvert(u,x)
export duconvert
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment