Skip to content

Commit

Permalink
emergency, about to factory reset
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamedwards committed Oct 3, 2024
1 parent cf002a0 commit 6afaf11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/history.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function porewaterhistory!(sc::SedimentColumn, p::Proposal, k::Constants, climhi
equilibratecolumn!(sc,sw,Water(p.basalCl,p.basalO),k.z,p.flr)

isd = searchsortedfirst(climhist.t, p.onset, rev=true)
#isd = ifelse(isd<climhist.n, isd, climhist.n)
@inbounds for t = isd:climhist.n
climate = climhist.x[t]

Expand Down
37 changes: 9 additions & 28 deletions src/metropolis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,10 @@ function stopwatch(i::Integer,n::Integer,t::Number)
string("0% |", bar,"| 100% || step: $i / $n || time: $tt m")
end

"""
!!! DEPRECATED !!!
CorePore.strictpriors(p::Proposal, record_max_age::Number, climatelimits::Tuple{Number,Number}, depth::Number)
Evalute strict constraints on priors that will automatically reject a proposal with..
"""
function strictpriors(p::Proposal, record_max_age::Number, climatelimits::Tuple{Number,Number}, depth::Number)

x=true

x &= 0 < p.onset <= record_max_age
x &= climatelimits[1] < p.sea2frz < p.frz2mlt < climatelimits[2]
x &= 0 < p.dfrz <= 0.002 # ≤ 0.4dt/dz to prevent an error in a log-calculation in `CorePore.boundaryconditions`
x &= 0 < p.dmlt <= 10.
x &= 0 < p.flr <= depth
x &= 0 < p.basalCl <= 200
x &= -56 < p.basalO

x
end

"""
checkpriors(p::Proposal, pp::ProposalPriors)
CorePore.checkpriors(p::Proposal, pp::ProposalPriors)
Returns `false` if any proposal value `p` falls beyond the prescribed prior bounds in `pp`, or if proposed subglacial thresholds are non-physical, i.e. melting at lower benthic δ¹⁸O than freezing.
Expand All @@ -49,8 +27,8 @@ function checkpriors(p::Proposal, pp::ProposalPriors)
x=true

x &= pp.onset[1] < p.onset <= pp.onset[2]
x &= pp.dfrz[1] < p.dfrz <= pp.dfrz[2]
x &= pp.dmlt[1] < p.dmlt <= pp.dmlt[2]
x &= pp.dfrz[1] < p.dfrz < pp.dfrz[2]
x &= pp.dmlt[1] < p.dmlt < pp.dmlt[2]
x &= pp.climatelimits[1] < p.sea2frz < p.frz2mlt < pp.climatelimits[2]
x &= pp.flr[1] < p.flr <= pp.flr[2]
x &= pp.basalCl[1] < p.basalCl <= pp.basalCl[2]
Expand Down Expand Up @@ -145,7 +123,8 @@ function porewatermetropolis(p::Proposal, jumpsigma::Proposal, priors::ProposalP

pwhfunc(sc, ϕ, k, climate, seawater, ka_dt)

llCl, llO = loglikelihood(coredata.z,coredata.Cl.mu,coredata.Cl.sig,k.z,sc.Cl.p), loglikelihood(coredata.z,coredata.O.mu,coredata.O.sig,k.z,sc.O.p)
llCl = loglikelihood(coredata.z,coredata.Cl.mu,coredata.Cl.sig,k.z,sc.Cl.p)
llO = loglikelihood(coredata.z,coredata.O.mu,coredata.O.sig,k.z,sc.O.p)
ll = llCl + ifelse(onlychloride,0,llO)

clock = time()
Expand All @@ -163,7 +142,8 @@ function porewatermetropolis(p::Proposal, jumpsigma::Proposal, priors::ProposalP

pwhfunc(sc, ϕ, k, climate, seawater, ka_dt)

llCl, llO = loglikelihood(coredata.z,coredata.Cl.mu,coredata.Cl.sig,k.z,sc.Cl.p), loglikelihood(coredata.z,coredata.O.mu,coredata.O.sig,k.z,sc.O.p)
llCl = loglikelihood(coredata.z,coredata.Cl.mu,coredata.Cl.sig,k.z,sc.Cl.p)
llO = loglikelihood(coredata.z,coredata.O.mu,coredata.O.sig,k.z,sc.O.p)
llϕ = llCl + ifelse(onlychloride,0,llO)
else
llϕ=-Inf
Expand Down Expand Up @@ -193,7 +173,8 @@ function porewatermetropolis(p::Proposal, jumpsigma::Proposal, priors::ProposalP

pwhfunc(sc, ϕ, k, climate, seawater, ka_dt)

llCl, llO = loglikelihood(coredata.z,coredata.Cl.mu,coredata.Cl.sig,k.z,sc.Cl.p), loglikelihood(coredata.z,coredata.O.mu,coredata.O.sig,k.z,sc.O.p)
llCl = loglikelihood(coredata.z,coredata.Cl.mu,coredata.Cl.sig,k.z,sc.Cl.p)
llO = loglikelihood(coredata.z,coredata.O.mu,coredata.O.sig,k.z,sc.O.p)
llϕ = llCl + ifelse(onlychloride,0,llO)
else
llϕ=-Inf
Expand Down
4 changes: 2 additions & 2 deletions src/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ See [`Proposal`](@ref) for descriptions and units of shared parameters.
| field | default | explanation |
| :---- | :------ | :---------- |
|`onset`| (`0`, `first(climate.t)`) | Onset date must fall within climate record timespan.
| `dfrz`| (`0`, `0.002`) | Freezing rate is non-zero and less than the upperbound of observed freezing rates (0.002 m/yr).¹ |
| `dmlt` | (`0`, `10`) | Annual melting rate is non-zero and must be no more than that observed at the Thwaites grounding line.² |
| `dfrz`| (`0`, `0.002`) | Freezing rate >0 and less than the upperbound of observed freezing rates (0.002 m/yr).¹ |
| `dmlt` | (`0`, `10`) | Annual melting rate >0 and less than that observed at the Thwaites grounding line.² |
| `climatelimits` | `extrema(climate.x)` | `sea2frz` and `frz2mlt` must lie within the observed climate record values. |
| `flr` | (`0`, `k.depth`) | Diffusive porewater column (`p.flr`) has non-zero depth within model domain. |
| `basalCl` | (`0`, `200`) | Basal [Cl⁻] compositions within 0-200 g/kg. (³) |
Expand Down

0 comments on commit 6afaf11

Please sign in to comment.