Skip to content

Commit

Permalink
Fix AIBECS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
briochemc committed Aug 19, 2021
1 parent 072e538 commit 8ab2419
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions test/AIBECS_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,18 @@ function prior(::Type{T}, s::Symbol) where {T<:AbstractParameters}
lb, ub = limits(T, s)
if (lb, ub) == (0,∞)
μ = log(initial_value(T, s))
return LogNormal(μ, 1.0)
LogNormal(μ, 1.0)
elseif (lb, ub) == (-∞,∞)
μ = initial_value(T, s)
σ = 10.0 # Assumes that a sensible unit is chosen (i.e., that within 10.0 * U)
return Normal(μ, σ)
else
return LocationScale(lb, ub-lb, LogitNormal()) # <- The LogitNormal works well for Optim?
Distributions.Normal(μ, σ)
else # LogitNormal with median as initial value and bounds
m = initial_value(T, s)
f = (m - lb) / (ub - lb)
LocationScale(lb, ub - lb, LogitNormal(log(f/(1-f)), 1.0))
end
else
return nothing
nothing
end
end
prior(::T, s::Symbol) where {T<:AbstractParameters} = prior(T,s)
Expand All @@ -86,11 +88,14 @@ sol = solve(prob, CTKAlg())
# AIBECS model mismatch with observations
# and generate the objective function
ρSW = 1.035u"kg/L" # approximate mean sea water density
DIPobs = ustrip(upreferred(WorldOceanAtlasTools.observations("PO₄") * ρSW))
obs = let
obs = WorldOceanAtlasTools.observations("phosphate")
obs.value = ustrip.(upreferred.(obs.phosphate * ρSW))
(obs,)
end
modify(DIP, POP) = (DIP,)
ωs = (1.0,) # the weight for the mismatch (weight of POP = 0)
ωp = 1.0 # the weight for the parameters prior estimates
obs = (DIPobs,)
f, ∇ₓf = f_and_∇ₓf(ωs, ωp, grd, modify, obs, PmodelParameters)

# Now we apply the F1 method
Expand Down

2 comments on commit 8ab2419

@briochemc
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/43110

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.1 -m "<description of version>" 8ab2419c2b364008c6629dd704d37ce88c37f5c9
git push origin v0.4.1

Please sign in to comment.