CorePore
Documentation for CorePore.
CorePore.ClimateHistory
CorePore.Constants
CorePore.CoreData
CorePore.PorewaterProperty
CorePore.Proposal
CorePore.ProposalPriors
CorePore.SedimentColumn
CorePore.Water
CorePore.LR04
CorePore.andrill1b
CorePore.andrill2a
CorePore.boundaryconditions
CorePore.checkpriors
CorePore.chlordiffuseadvectcolumn!
CorePore.chlorporewaterhistory!
CorePore.deepbonney
CorePore.density
CorePore.diffuseadvectcolumn!
CorePore.diffusion
CorePore.diffusionadvection
CorePore.dt_climatetimestep
CorePore.equilibratecolumn!
CorePore.fastsplat
CorePore.linterp
CorePore.loglikelihood
CorePore.mcmurdoshelf
CorePore.mcmurdosound
CorePore.means
CorePore.medians
CorePore.normll
CorePore.normpdf
CorePore.porewaterhistory
CorePore.porewaterhistory!
CorePore.porewatermetropolis
CorePore.proposaljump
CorePore.stopwatch
CorePore.update
CorePore.velocity
CorePore.ClimateHistory
— TypeClimateHistory
Custom struct to contain a climate record x
over timescale t
, where t
contains n
timesteps.
The type generated by LR04
, which is used for (perhaps unnecessary) type stability and code readability.
CorePore.Constants
— TypeConstants( ; k, dt, dz, depth )
Returns a Constants
struct containing constants and coefficients used in diffusion history calculations. The inputs and their default values are listed in the table below. From these it calculates a few convenient variables–-the product dt * dz
(dtdz
), a Range of node depths z
(in m), the number of nodes nz
, and the penultimate_node
–-as well as temperature-dependent diffusion coefficients used in diffusionadvection
, using the temperature-depth paramterization of Morin+ 2010. These are returned as Vectors of length nz
, where each cell corresponds to a depth node in z
. The two coefficients are k1
and k2
, both of which are follwed with cl
or w
to denote Cl⁻ or water, respectively: k1cl
, k2cl
, k1w
, and k2w
.
field | description | default |
---|---|---|
k | hydraulic conductivity of sediment column | 0.1 m / yr |
dt | timestep | 10 yrs |
dz | node spacing | 5 m |
depth | sediment column depth | 2000 m |
CorePore.CoreData
— TypeCoreData(z, mCl, σCl, mO, σO)
Returns an CoreData
struct with sediment core data formatted for porewatermetropolis
— (; z, Cl = (mu, sig), O = (mu, sig))
. Inputs are Vectors for values of sample depths z
(meters below sea floor), measured (mean) chlorinity mCl
and 1σ uncertainty σCl
, and measured (mean) δ¹⁸O mO
and 1σ uncertainties σO
.
Vectors must all be of the same length. If Cl and δ¹⁸O sampling is not 1:1, use NaN
or anything that is not a subtype of Number (e.g. missing
, nothing
). While NaN
is used internally, CoreData
does this conversion for you.
CoreData(z, m, σ, measurement)
Same as above, but for a core with only chlorinity or δ¹⁸O data (the other Vectors are empty to return null values in loglikelihood
calculations). Provide sample depths z
, measured means m
, 1σ uncertainties σ
, and the measurement
as a symbol, e.g. :Cl
or :O
.
CorePore.jl
comes loaded with convenience functions to generate data for andrill2a
from Tracy+ 2010 (doi:10.1130/G30849.1) and andrill1b
from Pompilio+ 2007 (https://digitalcommons.unl.edu/andrillrespub/37).
CorePore.PorewaterProperty
— TypePorewaterProperty(n::Int, [, x])
struct
to contain sediment column poperties at each node for the previous timestep o
and present timestep p
.
Constructor function returns an instance of PorewaterProperty
with vectors of length n
. Optionally provide a value x <: Number
to fill vectors with (otherwise values are undefined).
CorePore.Proposal
— TypeProposal
Struct containing porewater parameters (described below). All inputs must be of type Number (converts to Float64). Built-in functionality includes splatting (...
) and CorePore.fastsplat
.
field | description | units | default |
---|---|---|---|
onset | onset of model | ka | 5320 |
dfrz | freezing rate | m/yr | 0.0001 |
dmlt | melting rate | m/yr | 0.001 |
sea2frz | Benthic δ¹⁸O threshold for subglacial freezing | ‰ | 3.5 |
frz2mlt | Benthic δ¹⁸O threshold for subglacial melting | ‰ | 4.2 |
flr | depth of diffusion-dominated porewater column | m | 1000. |
basalCl | chloridity at base of diffusion-dominated column | g/kg | 119.4 |
basalO | δ¹⁸O at base of diffusion-dominated column | ‰ | -25.2 |
see also: update
CorePore.ProposalPriors
— TypeProposalPriors(climate, k; onset, dfrz, fmlt, climatelimits, flr, basalCl, basalO)
Custom struct
to hold the bounds of parameters in Proposal as Tuple
s of (minimum value
, maximum value
). The constructor function takes a ClimateHistory
instance climate
and Constants
instance k
, as well as any customizations to default values.
Fields
See Proposal
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 >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. (³) |
basalO | (-56 , ∞ ) | δ¹⁸O exceed dome-like values. |
¹ Must be ≤ 0.4dt/dz to prevent an error in a log-calculation in CorePore.boundaryconditions
² <10 m/yr – Davis+ 2023, https://www.nature.com/articles/s41586-022-05586-0
³ The water+halite peritectic is ~163 g/kg Cl, assuming charge balance with NaCl.
CorePore.SedimentColumn
— TypeSedimentColumn(n::Int, [, Cl, O])
struct
to contain PorewaterProperty
s for the porewater properties of chloridity (Cl
), δ¹⁸O (O
), and density (rho
).
Constructor function returns an instance of SedimentColumn
with PorewaterProperty
vectors of length n
. Optionally provide values for Cl
, O
, and rho
(otherwise values are undefined).
see also: PorewaterProperty
, density
CorePore.Water
— Typewater(Cl, O)
Custom struct
containing Float64
values of chlorinity Cl
and δ¹⁸O O
. Built-in splatting functionality.
see also: mcmurdoshelf
, mcmurdosound
CorePore.LR04
— MethodLR04()
Generate a ClimateHistory
instance containing the Liesiecki & Raymo 2004 benthic stack (data, publication) interpolated for 1 ka timesteps and going forward in time from 5.32 Ma.
field | description |
---|---|
t | time (ka) |
x | benthic δ¹⁸O (‰) |
n | timesteps in t |
CorePore.andrill1b
— Methodandrill1b
Generate a CoreData
instance with data from core ANDRILL-1B (from Pompilio+ 2007 (https://digitalcommons.unl.edu/andrillrespub/37)).
see also: CoreData
CorePore.andrill2a
— Methodandrill2a
Generate a CoreData
instance with data from core ANDRILL-2A (from Frank+ 2010, doi:10.1130/G30849.1).
see also: CoreData
CorePore.boundaryconditions
— Methodfunction boundaryconditions(Cl, d18O, x, sea2freeze,freeze2melt, meltrate, freezerate, Clsw, d18Osw, dz, dt)
Calculates sediment surface boundary condition for δ¹⁸O (d18O
) and chloridity (Cl
), based on the thermodynamic state described by the current current benthic δ¹⁸O value x
and the threshold values corresponding to subglacial freezing sea2freeze
and subglacial melting freeze2melt
.
For melting or freezing states, calculates boundary condition from the assumed meltrate
, freezerate
, timestep dt
, length-step dt
, and composition of seawater Clsw
and d18Osw
.
CorePore.checkpriors
— MethodCorePore.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.
Otherwise returns true
.
CorePore.chlordiffuseadvectcolumn!
— Methodchlordiffuseadvectcolumn!(sc, k, flr)
Same as diffuseadvectcolumn!
, but skipping δ¹⁸O calculations.
CorePore.chlorporewaterhistory!
— Methodchlorporewaterhistory!(sc, p, k, climhist, seawater, ka_dt)
Same as porewaterhistory
, but skipping δ¹⁸O calculations.
CorePore.deepbonney
— Methoddeepbonney()
Generate a [`Water`](@ref) instance with >30 m Lake Bonney water compositions. Use for sediment column basal boundary condition. Chloridity (143.333 g/L ÷ 1.2 kg/L ≈ 119 g/kg) from Angino+ 1963 ([doi:10.1086/626879](https://doi.org/10.1086/626879)) and δ¹⁸O from Matsubaya+ 1979 ([doi:10.1016/0016-7037(79)90042-5](https://doi.org/10.1016/0016-7037(79)90042-5)).
CorePore.density
— Methoddensity(chlorinity)
Calculates the density of a water parcel with chlorinity
in units g/m³ (rather than kg/m³ for convenience with velocity
)
see also: velocity
CorePore.diffuseadvectcolumn!
— Methoddiffuseadvectcolumn!(sc, k, flr)
Calculate diffusive and advective transport of chlorinity and isotope-traced water through a sediment column described by properties in k
, a NamedTuple generated by the Constants
function.
Overwrites the o
and p
PorewaterProperty fields of sc
– a SedimentColumn
with pre-existing conditions of Cl
, O
, and rho
in its o
fields.
relies on: velocity
, density
, diffusionadvection
,
see also: SedimentColumn
, Constants
CorePore.diffusion
— Methoddiffusion(x,above,below,k)
Calculate the property of a node in a vertical profile given the effect of diffusion, alone. Returns the property given initial values for the node x
, the overlying node above
, the underlying node below
, and (dt
/dz
²-scaled) diffusion coefficient k
.
CorePore.diffusionadvection
— Methoddiffusionadvection(x,above,below,k1,k2,v,dt,dz)
Calculate the property of a node in a vertical profile given the combined effects of diffusion and advection. Returns the property given initial values for the node x
, the overlying node above
, the underlying node below
, (dt
/dz
-scaled) diffusion coefficients k1
and k2
, vertical advection velocity v
, timestep dt
, and lengthstep dz
. Alternatively provide the product of v * dt * dz
for a minor speed-up.
CorePore.dt_climatetimestep
— Methoddt_climatetimestep(katime,dt)
A helper function to calculate the number of diffusion model timesteps dt
(in years) in each timestep of the climate timescale katime
(in kiloannum). Returns an integer.
CorePore.equilibratecolumn!
— Methodequilibratecolumn!(sc, seawater, basalwater, z, flr)
Calculate an equilibrium linear profile for all SedimentColumn vectors in sc
between a seafloor seawater
and basalwater
composition, given node depths z
and diffusion-dominated column depth flr
.
CorePore.fastsplat
— Methodfastsplat(x::Proposal)
Returns a tuple of the contents of x
. Avoids type inherent instability of Base.iterate
for fast splatting.
CorePore.linterp
— Methodlinterp(x, x₁, Δx, y₂, y₁ )
Estimate the value of y corresponding to x
given known coordinate (x₁
, y₁
), value y₂
, and Δx
= x₂ - x₁. Note that if x
==x₁
, y= y₁
.
CorePore.loglikelihood
— Methodloglikelihood( zₒ, μ, σ, zₘ, m )
Calculate the (relative) log-likelihood that model values in m
simulated at depth nodes in zₘ
were drawn from normally distributed observations with sample depths, mean values, and 1σ uncertainties in corresponding indices of the Vectors zₒ
, μₒ
, and σ
. The simulated value is linearly interpolated between bounding depth nodes in zₘ
.
CorePore.mcmurdoshelf
— Methodmcmurdoshelf()
Generate a Water
instance with coretop porewater compositions from the McMurdo ice shelf. Pairs with core ANDRILL-1B.
see also: andrill1b
CorePore.mcmurdosound
— Methodmcmurdosound()
Generate a Water
instance with southern McMurdo Sound water compositions. Pair with core ANDRILL-2A.
see also: andrill2a
CorePore.means
— Methodmeans(x; std::Integer)
Calculate the means of each field in NamedTuple x
. Optionally provide an integer number of standard deviations to calculate, returned as the form key
= (m=μ, s=σ). Use with the returned chains of porewatermetropolis
.
CorePore.medians
— Methodmedians(x; ci::Float64)
Calculate the medians of each field in NamedTuple x
. Optionally provide a ci
∈ [0,1] of standard deviations to calculate, returned as the form key
= (m=median, l=lower, u=upper). Use with the returned chains of porewatermetropolis
.
CorePore.normll
— Methodnormll(x, μ, σ)
Calculate the (relative) log-likelihood that an observation x
was drawn from the normal distribution with mean μ
and standard deviation σ
. If μ
is a NaN (instead of missing for type homogeneity), returns 0
.
Note: This function excludes a constant that will not vary for different vlaues of x
to speed up calculation in metropolis
. To calculate the absolute log-likelihood, take the log
of normpdf
CorePore.normpdf
— Methodnormpdf(x, μ, σ)
Calculate the probability density of a normal distribution with mean μ
and standard deviation σ
at the value x
.
CorePore.porewaterhistory!
— Methodporewaterhistory!(sc::SedimentColumn, p::Proposal, k::Constants, climhist::NamedTuple, seawater::Water, ka_dt::Int)
In-place version of porewaterhistory
, which takes every input as an arg (rather than some defaults as kwargs). It also requires you to provide ka_dt
– the number of diffusion timesteps in each thousand-year climate timestep.
see also: porewaterhistory
CorePore.porewaterhistory
— Methodporewaterhistory(p [; k=Constants(), climatehistory=LR04(), seawater=mcmurdosound()])
Calculate the porewater advection-diffusion history of chlorinity and O-isotope-traced water in a sediment column described by properties in k
(::Constants
) over a given ClimateHistory
(LR04
by default) and coretop seawater
compositions.
Proposal
) instance p
describes the sensitivity and response of the system to climate fluctuations as recorded in climatehistory
.
See diffuseadvectcolumn!
for the underlying diffusion-advection transport calculations.
see also: porewaterhistory!
, Proposal
, Constants
, LR04
, Water
CorePore.porewatermetropolis
— Methodporewatermetropolis(p, σ, priors, coredata, cliamte, k; burnin=10, chainsteps=10, climate, k, seawater, onlychloride=true, explore, rng)
Executes a Markov chain Monte Carlo (MCMC) routine that explores the parameter space of the variables in Proposal
instance p
, constrained by sediment column porewater chemistry records in CoreData
instance coredata
and climate record in ClimateHistory
instance climate
(e.g. LR04
), and diffusion-advection parameters in Constants
instance k
(I recommend using default values Constants()
).
Proposal
instance σ
describes the (1σ) Gaussian jump size corresponding to each field in p
(note that fields :dmlt
, :dfrz
, and :basalCl
use a log-normal jump and require a log-space value in σ
), and priors
are a ProposalPriors
instance describing the prior bounds on p
.
Kwarg onlychloride
determines whether the MCMC inverts for only porewater chloridity (default=true
) or porewater chloridity and δ¹⁸O (false
).
Additional kwargs include...
kwarg | DataType | description | default |
---|---|---|---|
burnin | Int | number of Markov chain burnin-warm-up steps | 10 |
chainsteps | Int | number of recorded Markov chains steps | 10 |
seawater | Water | seawater composition overlying sediment column | mcmurdosound() |
explore | Tuple{Vararg{Symbol}} | parameters explored by the MCMC | fieldnames(Proposal) |
rng | AbstractRNG | optional random number seed | Random.Xoshiro() |
see also: Proposal
, CoreData
, ClimateHistory
, Constants
, Water
CorePore.proposaljump
— MethodCorePore.proposaljump(p::Proposal, σ::Proposal; f, rng::AbstractRNG)
Add a random jump to a randomly selected field of p
with a corresponding normal jumping distribution defined by the corresponding field in σ
. The possible fields may be specified by providing a Tuple of Symbols f
(default=fieldnames(Proposal)
), and a specific RNG seed may be provided.
Note that :dmlt
, :dfrz
, and :basalCl
are drawn from a lognormal jumping distribution (where σ
is in log-space.)
see also: porewatermetropolis
, Proposal
CorePore.stopwatch
— Methodstopwatch(i, n, t)
Convenience function for [porewatermetropolis
] that returns a String reporting the progress at step i
for total steps n
with start time t
(in s since the epoch).
CorePore.update
— Methodupdate(p::Proposal, f::Symbol, x::Number)
Update field f
of Proposal
instance p
with value x
.
CorePore.velocity
— Methodvelocity(x, above, k)
Calculate the velocity (m/yr) at a node with density x
, given the density of the node above
, and the hydraulic conductivity k
(m/yr).
see also: density