Reference

Sample Planning

Generating Points

Monty.Sampling.randinFunction
randin(
    rng::Random.AbstractRNG,
    geom::Meshes.Geometry{2, 𝒯},
    N::Int64
) -> Vector{T} where T<:(Meshes.Point{2})

Generates a vector of N random points inside a two-dimensional geometry

source
Monty.Sampling.randin!Function
randin!(
    rng::Random.AbstractRNG,
    points::AbstractArray{Meshes.Point{2, 𝒯}, 1},
    geom::Meshes.Geometry{2, 𝒯}
)

Fills a vector with random points inside a two-dimensional geometry

source
Monty.Sampling.gridpointoverlayFunction
gridpointoverlay(geom, dims::Tuple{Integer, Integer}) -> Any

Creates a CartesianGrid of size dims, intersects the grid with geom, and returns the centroids of intersected grid cells. Any cells with no intersection are removed.

source
gridpointoverlay(
    rng::Random.AbstractRNG,
    geom,
    dims::Tuple{Integer, Integer}
) -> Any

Creates a CartesianGrid of size dims, intersects the grid with geom, and returns points sampled randomly from the intersected grid cells. Any cells with no intersection are removed.

source
Monty.Jitters.jittergridFunction
jittergrid(
    rng::Random.AbstractRNG,
    grid::Meshes.CartesianGrid{2, 𝒯},
    centering::Real
) -> Vector

Generates a vector of points where each point is assigned to a random location in each cell of a CartesianGrid. The centering parameter controls how closely the points tend to be to each cell's centroid. For uniform randomness (no centering) use centering=1.0. Higher values induce stronger centering.

source

Sample Plans

Monty.Sampling.SamplePlanType

A SamplePlan represents the intended locations and times for all samples in a simulated deployment, in addition to whether target samples are control samples (no feedstock spreading). Generally, it's easiest to construct a sample plan using either the pairedsampleplan or randomsampleplan functions. The fields of a SamplePlan are ReadOnlyArray types that cannot be modified.

The fields are

  • location::ReadOnlyArrays.ReadOnlyVector{UInt16, Vector{UInt16}}

  • round::ReadOnlyArrays.ReadOnlyVector{UInt16, Vector{UInt16}}

  • time::ReadOnlyArrays.ReadOnlyArray{𝒯, 1, Vector{𝒯}} where 𝒯

  • control::ReadOnlyArrays.ReadOnlyVector{Bool, Vector{Bool}}

  • points::ReadOnlyArrays.ReadOnlyArray{Meshes.Point{2, 𝒯}, 1, Array{Meshes.Point{2, 𝒯}, 1}} where 𝒯

source
Monty.nsampleFunction
nsample(plan::SamplePlan) -> Int64

Returns the number of sample locations in a SamplePlan. This is the number of planned samples after compositing the cores for each planned location. The number of cores for each sample is given by ncore(plan). The total number of cores is ncore(plan) * nsample(plan).

source
nsample(samp::CoreSet) -> Int64

Returns the number of cores per sample

source
Meshes.boundingboxFunction
boundingbox(plan::SamplePlan) -> Meshes.Box

Returns the bounding box of the samples in a plan

source
Monty.Sampling.pairedsampleplanFunction
pairedsampleplan(
    points::Array{Meshes.Point{2, 𝒯}, 1},
    times::AbstractArray{𝒯, 1}
) -> SamplePlan

Creates a SamplePlan where sample locations are repeated for each round of sampling (location-paired). No control points are created. The timing of each sampling round is given by the times vector.

source
pairedsampleplan(
    points::Array{Meshes.Point{2, 𝒯}, 1},
    control,
    times::AbstractArray{𝒯, 1}
) -> SamplePlan

Creates a location-paired smaple plan using a vector of existing points. Points inside the control geometry will be assigned to the control group. The timing of each sampling round is given by the times vector.

source
pairedsampleplan(
    treatments::Array{Meshes.Point{2, 𝒯}, 1},
    controls::Array{Meshes.Point{2, 𝒯}, 1},
    times::AbstractArray{𝒯, 1}
) -> SamplePlan

Creates a location-paired sample plan using existing vectors of treatment and control points. The timing of each sampling round is given by the times vector.

source
pairedsampleplan(
    rng::Random.AbstractRNG,
    field::Meshes.Geometry{2, 𝒯},
    N::Integer,
    times::AbstractArray{𝒯, 1}
) -> SamplePlan

Creates a location-paired sample plan using N points selected random from inside a field geometry. The locations are repeated for each sampling round specified in the times vector.

source
pairedsampleplan(
    rng::Random.AbstractRNG,
    treatment::Meshes.Geometry{2, 𝒯},
    ntreatment::Integer,
    control::Meshes.Geometry{2, 𝒯},
    ncontrol::Integer,
    times::AbstractArray{𝒯, 1}
) -> SamplePlan

Creates a SamplePlan where sample locations are repeated for each round of sampling (location-paired). ntreatment treatment locations are drawn randomly from inside the treatment geometry and ncontrol control locations are drawn randomly from inside the control geometry. The timing of each sampling round is given by the times vector.

source
Monty.Sampling.randomsampleplanFunction
randomsampleplan(
    rng::Random.AbstractRNG,
    treatment::Meshes.Geometry{2, 𝒯},
    ntreatment::AbstractVector{<:Integer},
    control::Meshes.Geometry{2, 𝒯},
    ncontrol::AbstractVector{<:Integer},
    times::AbstractArray{𝒯, 1}
) -> SamplePlan

Creates a random SamplePlan, where sample locations are not repeated across different rounds of sampling. For each round of sampling, treament points are drawn randomly from the treatment geometry. The number of treatment points in each round is determined by the vector of integers ntreatment. The same true for control points, using the control geometry and ncontrol sample sizes for each round. The timing of each sampling round is given by the times vector.

source
randomsampleplan(
    rng::Random.AbstractRNG,
    treatment::Meshes.Geometry{2, 𝒯},
    ntreatment::Integer,
    control::Meshes.Geometry{2, 𝒯},
    ncontrol::Integer,
    times::AbstractArray{𝒯, 1}
) -> SamplePlan

Creates a random SamplePlan, where sample locations are not repeated across different rounds of sampling. For each round of sampling, ntreatment treament points are drawn randomly from the treatment geometry and ncontrol points are drawn randomly from inside the control geometry. The timing of each sampling round is given by the times vector.

source
randomsampleplan(
    rng::Random.AbstractRNG,
    field::Meshes.Geometry{2, 𝒯},
    N::AbstractVector{<:Integer},
    times::AbstractArray{𝒯, 1}
) -> SamplePlan

Creates a random sample plan with points selected randomly from inside the field geometry for each round. The number of points in each round is given by a vector of integers N and the timing of each round by the times vector.

source
randomsampleplan(
    rng::Random.AbstractRNG,
    field::Meshes.Geometry{2, 𝒯},
    N::Integer,
    times::AbstractArray{𝒯, 1}
) -> SamplePlan

Creates a random SamplePlan, where sample locations are not repeated across different rounds of sampling. For each round of sampling, N treament points are drawn randomly from the field geometry. The timing of each sampling round is given by the times vector.

source

Location Jitter

Monty has three "jitter" types meant to be used as callable objects or "functors." This means that a jitter object is created with some parameters, then used like a function and applied to sample/core locations. Each jitter type can be called on a Point and it will return a jittered Point.

Monty.Jitters.jitterpointFunction
jitterpoint(
    rng::Random.AbstractRNG,
    point::Meshes.Point{𝒩, 𝒯},
    σ
) -> Meshes.Point

Applies random, isotropic normally distributed jitter to a point in two-dimensional space, where σ is the absolute standard deviation of the jitter.

source
Monty.Jitters.jitterpoints!Function
jitterpoints!(
    rng::Random.AbstractRNG,
    points::AbstractArray{Meshes.Point{2, 𝒯}, 1},
    σ
)

Applies random, isotropic normally distributed jitter to a vector of points, where σ is the absolute standard deviation of the jitter.

source
jitterpoints!(
    rng::Random.AbstractRNG,
    jittered::AbstractArray{Meshes.Point{2, 𝒯}, 1},
    original::AbstractArray{Meshes.Point{2, 𝒯}, 1},
    σ
)

Applies random, isotropic normally distributed jitter to a vector of points in place, filling the jittered vector with points from original after jittering them, where σ is the absolute standard deviation of the jitter.

source
Monty.Jitters.JitterType

The Jitter type applies random isotropic noise to a Point.

Jitter(d::UnivariateDistribution; seed=Union{Nothing,Integer}=nothing)

The first constructor above accepts a pre-specified distribution, which represents the noise applied in each dimension.

Jitter(σ; seed::Union{Nothing,Integer}=nothing)

The second constructor assumes a normal distribution for the noise, and receives the standard deviation of that distribution. In both cases a seed can be given, which is used to draw random values.

source

Core Stencils

Like the jitter types above, core stencil types are all used as callable objects or "functors." This means that a stencil is created with some parameters, then used like a function to generate core locations. Generally, stencils don't have to be used directly in Monty. They are passed to executeplan!, which handles the function calling. To use one directly, however, just requires passing a location and core number to the object

stencil(point::Point, n::Integer)

which returns the core location as another Point.

Monty.Stencils.RandomStencilType

A core stencil representing randomly drawn core locations

RandomStencil(N::Integer, args...; kwargs...)

Creates a RandomStencil with N cores, where the args and kwargs are passed through to the Jitter constructor

source
Monty.Stencils.CircleStencilType

A core stencil representing a circle of cores

A CircleStencil is defined by the number of cores and the radius of the circle

CircleStencil(N::Integer, r)
source
Monty.Stencils.HubSpokeStencilType

A core stencil representing a circle of cores with one point in the center of the circle.

HubSpokeStencil(N::Integer, r)

The constructor takes the number of cores and a radius for the circle

source
Monty.Stencils.LineStencilType

A core stencil representing a line of cores.

LineStencil(N::Integer, δ::𝒯, θ::𝒯) where {𝒯}

The constructor takes the number of cores, the distance between each core in the line (δ), and the angle of the line (θ)

source

Plan Execution

Monty.Sampling.CoreSetType

A CoreSet represents the realization of a SamplePlan and is closely related. The sample plan represents the ideal sampling locations. A core set expands on the sample plan by

  1. representing planned and unplanned jitter in the target sample locations (for example, simple GPS inaccuracy)
  2. defining some number of cores for each sample, which are composited during the simulation process.

Dividing the sample plan and core set allows for more efficient simulation of many realizations from the same hypothetical sample plan. A core set can be defined without any location jitter and without compositing (a single core).

A CoreSet can be created and filled by the executeplan and executeplan! functions, respectively.

source
Monty.Sampling.executeplan!Function
executeplan!(
    samp::Array{Meshes.Point{2, 𝒯}, 2},
    plan::SamplePlan{𝒯};
    stencil,
    plannedjitter,
    samplerjitter,
    corejitter
)

Executes a sample plan, filling an existing CoreSet with the results.

source

Mixing Model

Monty.MixingModel.feedstockfractionFunction
feedstockfraction(
    Γ::Distributions.UnivariateDistribution,
    d
) -> Any

Computes the fraction of applied original feedstock contained in a sample, given the mixing profile Γ, which must be a univariate distribution, and the sample depth d. This function simply wraps a cdf evaluation (cumulative probability density) and includes checks for physical consistency.

source
Monty.MixingModel.feedstockmassFunction
feedstockmass(Q, γ, ℒ) -> Any

Computes the mass of feedstock contained in a sample, given the application rate Q, the sampled fraction γ, and the feedstock mass loss fraction . Evaluates

\[Q \gamma (1 - \mathscr{L})\]

source
Monty.MixingModel.feedstockelementmassFunction
feedstockelementmass(Q, γ, 𝓁, cf) -> Any

Computes the mass of an individual element or analyte in a sample, given the application rate Q, the sampled feedstock fraction γ, the analyte loss fraction 𝓁, and the feedstock mass loss fraction . Evaluates

\[Q \gamma (1 - \mathscr{l}) \mathscr{L}\]

source
Monty.MixingModel.feedstockthicknessFunction
feedstockthickness(Q, γ, ρf, ℒ) -> Any

Computes the thickness of the feedstock in a sample, given the application rate Q, the sampled feedstock fraction γ, and the feedstock bulk density in the sample ρs. Evaluates

\[Q \gamma / \rho_f\]

source
Monty.MixingModel.soilmassFunction
soilmass(ρs, d) -> Any

Computes the soil mass in a sample, given the soil bulk density ρs and the soil/sample depth d. Note that in analytical model, d represents an apparent soil depth after accounting for the thickness of feedstock material. This function simply performs physical checks and evaluates

\[\rho_s d\]

source
Monty.MixingModel.soilelementmassFunction
soilelementmass(ρs, d, cs) -> Any

Computes the mass of an element/analyte in soil, given the soil bulk density ρs, the soil/sample depth d, and the concentration of the element in the soil cs. Evaluates

\[\rho_s d c_s\]

source
Monty.MixingModel.samplemassFunction
samplemass(M, a) -> Any

Computes the mass of a sample given the sampled soil's mass per unit area M and sampled cross-sectional area a. Evaluates

M a
source
Monty.MixingModel.SampleType

The Sample type represents a mass of soil/material with some number of analyte concentrations. When defined, all samples represent an individual soil core, which can be combined by addition (the + operator) into composite samples.

The Sample type has three fields:

FieldDescription
concentrationsa NamedTuple containing exact sample concentrations
massthe exact mass of the sample
coresthe number of individual cores combined into the composite sample

A Sample represents the true, exact properties of a piece of soil and is immutable. Once defined, it can't be modifed. When compositing samples (adding them together), the composite concentrations are computed exactly by mass weighted average. Samples are created from soil and deployment parameters using the mixing function. To simulate measurement noise/uncertainty, a sample is passed to the measure function, which applies gaussian noise defined in terms of relative standard deviations.

source
Monty.MixingModel.mixingFunction
mixing(
    γ::Number,
    d::Number,
    a::Number,
    Q::Number,
    ρf::Number,
    cf::NamedTuple{𝒦, Tuple{Vararg{𝒯, 𝒩}}},
    ρs::Number,
    cs::NamedTuple{𝒦, Tuple{Vararg{𝒯, 𝒩}}},
    𝓁::NamedTuple{𝒦, Tuple{Vararg{𝒰, 𝒩}}},
    ℒ::Number
) -> Sample

Evaluates the mixing and leaching model for a single piece of soil, returning a Sample.

source
mixing(
    γ::Number,
    d,
    a,
    Q,
    ρf,
    cf::Number,
    ρs,
    cs::Number,
    𝓁::Number,
    ℒ
) -> Sample{1, (:analyte,)}

Evaluates the mixing and leaching model for a single piece of soil, returning a Sample.

source

Weathering & Leaching Models

Leaching models define the fraction of a feedstock's element lost at any point in time. Each leaching model is a scalar function of time. They always return values that are

  • fractional, meaning $\in [0,1]$
  • exactly 1 for negative time
  • exactly zero at time zero
  • monotonically increasing after time zero (no reverse leaching)
Monty.LeachingModels.ExponentialLeachingType

Leaching model with exponential loss over time. The internal fields are

  • λ::Any

  • C::Any

  • σ::Any

  • rng::Random.Xoshiro

The constructor is

function ExponentialLeaching(;
    λ::𝒯=1.0,
    C::𝒯=1.0,
    σ::𝒯=0.0,
    seed::Union{Nothing,Integer}=nothing,
)

Keyword Arguments

  • The λ parameter is the exponential decay/loss rate
  • C is a floor, above which the leache fraction will never cross.
  • The σ parameter adds noise to the model, but should be used with caution because the noise is not symmetrical and can change the average leached fraction at a given point in time.
  • If there is noise, the internal rng can be initialized using the seed keyword argument.
source
Monty.LeachingModels.MultiExponentialLeachingType

Leaching model with an average of exponential losses over time. The internal fields are

  • λ::Tuple{Vararg{𝒯, 𝒩}} where {𝒯, 𝒩}

  • C::Any

  • σ::Any

  • rng::Random.Xoshiro

The constructor is

function MultiExponentialLeaching(;
    λ::NTuple{𝒩,𝒯}=1.0,
    C::𝒯=1.0,
    σ::𝒯=0.0,
    seed::Union{Nothing,Integer}=nothing,
)

Keyword Arguments

  • The λ parameter is tuple of decay/loss rates
  • C is a floor, above which the leache fraction will never cross.
  • The σ parameter adds noise to the model, but should be used with caution because the noise is not symmetrical and can change the average leached fraction at a given point in time.
  • If there is noise, the internal rng can be initialized using the seed keyword argument.
source
Monty.LeachingModels.SeasonalLeachingType

Leaching model with seasonally varying loss over time, representing an annual cycle. The period of the cycles is exactly one year. The internal fields are

  • λ::Any

  • C::Any

  • A::Any

  • γ::UInt8

  • ϕ::Any

  • σ::Any

  • rng::Random.Xoshiro

The constructor is

function SeasonalLeaching(;
    λ=1.0,
    C=1.0,
    floor=0.0,
    power::Integer=1,
    phase=π,
    σ=0.0,
    seed::Union{Nothing,Integer}=nothing,
)

Keyword Arguments

  • The λ parameter is the exponential decay/loss rate
  • C is a floor, above which the leache fraction will never cross.
  • floor sets the minimum value of the sinusoid that is integrated to produce monotonically increasing loss fractions. The details are not that important. It sets the minimum leaching rate. For example, if floor is zero, there is a point in each annual cycle where the leaching rate is also zero. As floor is increased, the minimum leaching rate over each annual cycle will increase.
  • power defines how wide the cycles are, which is analogous to how long the "winter" is when the leaching rate is slow.
  • phase shifts the cycle in time.
  • The σ parameter adds noise to the model, but should be used with caution because the noise is not symmetrical and can change the average leached fraction at a given point in time.
  • If there is noise, the internal rng can be initialized using the seed keyword argument.
source

Here are some a example leaching models:

# time points where models are evaluated
t = LinRange(-1.0, 4.0, 51) |> collect
# models
exp_model = ExponentialLeaching(λ=1.5, C=0.9)
multi_exp_model = MultiExponentialLeaching(λ=(10.0, 1.0), C=0.9)
seasonal_model = SeasonalLeaching(λ=1.0, floor=0.05, power=2, C=0.85)
Example block output

Simulation

The main simulation function is simulationstack and an example is shown in the Efficient Simulations page.

Monty.Simulating.moisturefractionFunction
moisturefraction(Ω) -> Any

Computes the moisture fraction ($\Phi$) from the moisture ratio ($\Omega$). The "ratio" is the water mass divided by the mass of dry material. The "fraction" is the water mass divided by the total mass. Evaluates

\[\Omega / (1 + \Omega)\]

source
Monty.Simulating.moistureratioFunction
moistureratio(Φ) -> Any

Computes the moisture ratio ($\Omega$) from the moisture fraction ($\Phi$). The "ratio" is the water mass divided by the mass of dry material. The "fraction" is the water mass divided by the total mass. Evaluates

\[\Phi / (1 - \Phi)\]

source
Monty.Simulating.spreading!Function
spreading!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯, 𝒩, 𝒦},
    plan::SamplePlan,
    X::Distributions.UnivariateDistribution
)

Samples spreading/application rates from a distribution or Simulator (or Cosimulator), automatically ignoring control points as identified by the provided plan.

source
spreading!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯},
    plan::SamplePlan,
    X
)

Samples any object for which rand! can be called to apply feedstock, ignoring controls.

source
Monty.Simulating.unmixed!Function
unmixed!(rng::Random.AbstractRNG, sim::Simulation{𝒯}; depth)

Sets feedstock fractions and sample depths assuming the feedstock is resting in a layer on top of soil (no mixing).

source
Monty.Simulating.uniformmixing!Function
uniformmixing!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯};
    depth,
    upper
)

Assumes feedstock mixing profiles uniform over a depth interval

source
Monty.Simulating.feedstockconcentration!Function
feedstockconcentration!(
    sim::Simulation{𝒯, 𝒩, 𝒦},
    concentrations::NamedTuple{𝒦, Tuple{Vararg{𝒯, 𝒩}}}
)

Sets feedstock concentrations to constants

source
feedstockconcentration!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯, 𝒩, 𝒦},
    μ::NamedTuple{𝒦, Tuple{Vararg{𝒯, 𝒩}}},
    σ
)

Sets feedstock concentrations using a mean and relative standard deviation for each analyte

source
Monty.Simulating.soilconcentration!Function
soilconcentration!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯},
    analyte::Symbol,
    X::Distributions.Distribution
)

Sets soil analyte concentrations using any distribution

source
soilconcentration!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯, 𝒩, 𝒦},
    μ::NamedTuple{𝒦, Tuple{Vararg{𝒯, 𝒩}}},
    σ
)

Sets soil analyte concentrationss using means and relative standard deviation

source
soilconcentration!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯},
    samp::CoreSet{𝒯},
    analyte::Symbol,
    μ,
    σ::GeoStatsFunctions.Covariance
)

Sets soil analyte concentrations using a multivariate normal distribution defined by a Covariance

source
soilconcentration!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯},
    gc::GaussianCosimulator{𝒯, 𝒦}
)

Sets soil analyte concentrations using a GaussianSimulator

source
Monty.Simulating.leaching!Function
leaching!(
    𝓁::Array{𝒯, 2},
    model::AbstractLeachingModel{𝒯},
    time::AbstractArray{𝒯, 1}
)

Sets leached fractions for one analyte using a Leaching Model

source
leaching!(
    sim::Simulation{𝒯, 𝒩, 𝒦},
    analyte::Symbol,
    model::AbstractLeachingModel{𝒯},
    time::AbstractArray{𝒯, 1}
)

Sets leached fractions for one analyte using a Leaching Model

source
leaching!(
    sim::Simulation{𝒯, 𝒩, 𝒦},
    analyte::Symbol,
    model::AbstractLeachingModel{𝒯},
    plan::SamplePlan{𝒯}
)

Sets leached fractions using a Leaching Model and times from a SamplePlan

source
leaching!(
    sim::Simulation{𝒯, 𝒩, 𝒦},
    models::NamedTuple{𝒦, Tuple{Vararg{ℳ<:AbstractLeachingModel, 𝒩}}},
    time::AbstractArray{𝒯, 1}
)

Sets leached fractions using a Leaching Model for each analyte

source
leaching!(
    sim::Simulation{𝒯, 𝒩, 𝒦},
    models::NamedTuple{𝒦, Tuple{Vararg{ℳ<:AbstractLeachingModel, 𝒩}}},
    plan::SamplePlan{𝒯}
)

Sets leached fractions using a Leaching Model for each analyte and times from a SamplePlan

source
Monty.Simulating.massloss!Function
massloss!(
    sim::Simulation{𝒯, 𝒩, 𝒦},
    plan::SamplePlan{𝒯},
    loss::Function
)

Sets feedstock mass loss fraction using a function of analyte leached fractions

source
Monty.Simulating.measure!Function
measure!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯, 𝒩, 𝒦},
    σ::NamedTuple{𝒦, Tuple{Vararg{𝒯, 𝒩}}},
    σₘ
)

Executes the composite sample measurement process internally in a Simulation using a tuple of relative standard deviations for analytes and a relative standard deviation for the mass

source
Monty.Simulating.analyze!Function
analyze!(
    rng::Random.AbstractRNG,
    sim::Simulation{𝒯, 𝒩, 𝒦},
    σ::NamedTuple{𝒦, Tuple{Vararg{𝒯, 𝒩}}},
    args...
)

Executes the entire core collection, compositing, and measurement sequence. That is, the analyze! function

  1. calls core!
  2. calls composite!
  3. calls measure, passing inputs through to that function
source
Monty.Simulating.simulationstackFunction
simulationstack(
    simulate!::Function,
    nrealization::Integer,
    sim::Simulation{𝒯},
    samp::CoreSet{𝒯},
    plan::SamplePlan{𝒯};
    show_progress
) -> DimensionalData.DimStack{(:data, :x, :y, :control, :location, :round, :time), T, _A, L, _B, Tuple{}, LD, DimensionalData.Dimensions.Lookups.NoMetadata, @NamedTuple{data::DimensionalData.Dimensions.Lookups.NoMetadata, x::DimensionalData.Dimensions.Lookups.NoMetadata, y::DimensionalData.Dimensions.Lookups.NoMetadata, control::DimensionalData.Dimensions.Lookups.NoMetadata, location::DimensionalData.Dimensions.Lookups.NoMetadata, round::DimensionalData.Dimensions.Lookups.NoMetadata, time::DimensionalData.Dimensions.Lookups.NoMetadata}} where {T<:(NamedTuple{(:data, :x, :y, :control, :location, :round, :time), T} where T), _A, L<:(NamedTuple{(:data, :x, :y, :control, :location, :round, :time), <:Tuple{AbstractArray{_A, 3} where _A, Matrix, Matrix, ReadOnlyArrays.ReadOnlyVector{Bool, Vector{Bool}}, ReadOnlyArrays.ReadOnlyVector{UInt16, Vector{UInt16}}, ReadOnlyArrays.ReadOnlyVector{UInt16, Vector{UInt16}}, ReadOnlyArrays.ReadOnlyArray{_A, 1, Vector{_A}} where _A}}), _B<:Tuple, LD<:(NamedTuple{(:data, :x, :y, :control, :location, :round, :time), <:Tuple{Any, Tuple{Any, Any}, Tuple{Any, Any}, Vararg{Tuple{Any}, 4}}})}

Runs repeated simulations. See the Efficient Simulation example.

source
Monty.Simulating.tocsvFunction
tocsv(
    fn::AbstractString,
    sims::DimensionalData.DimStack,
    realization::Integer
)

Writes one realization of a simulation stack to csv format

source

Container

Monty.Simulating.SimulationType

The Simulation type is a container for running simulations. See the simulationstack function for more detail.

The fields are

  • nsamp::UInt16

  • ncore::UInt16

  • γ::Matrix

  • d::Matrix

  • a::Any

  • Q::Matrix

  • ρf::Matrix

  • cf::NamedTuple{𝒦, Tuple{Vararg{Matrix{𝒯}, 𝒩}}} where {𝒯, 𝒩, 𝒦}

  • ρs::Matrix

  • cs::NamedTuple{𝒦, Tuple{Vararg{Matrix{𝒯}, 𝒩}}} where {𝒯, 𝒩, 𝒦}

  • 𝓁::NamedTuple{𝒦, Tuple{Vararg{Matrix{𝒯}, 𝒩}}} where {𝒯, 𝒩, 𝒦}

  • ℒ::Matrix

  • cores::Array{Sample{𝒩, 𝒦, 𝒯, 𝒯}, 2} where {𝒯, 𝒩, 𝒦}

  • composites::Array{Sample{𝒩, 𝒦, 𝒯, 𝒯}, 1} where {𝒯, 𝒩, 𝒦}

  • measurements::Array{Measurement{𝒩, 𝒦, 𝒯}, 1} where {𝒯, 𝒩, 𝒦}

source

Gaussian Simulators

There are two types for simulating from multivariate gaussian distributions, which are useful for generating vectors with correlated elements. Both of them can be updated from a Covariance model using the updategaussian! methods, which recomputes the necessary Cholesky factorization in-place using the covariance model and a group of points. Both types can also be sampled with rand and rand!.

Monty.Gaussian.GaussianSimulatorType

The GaussianSimulator type is for simulating a multivariate distribution over points in space and efficiently reloading the correlation matrix with a new set of points. See the Efficient Simulation example.

Constructors

GaussianSimulator(N::Integer, μ::AbstractVector{𝒯}) where {𝒯}

GaussianSimulator(samp::CoreSet{𝒯}, μ::AbstractVector{𝒯}) where {𝒯}

GaussianSimulator(samp::CoreSet{𝒯}, μ::𝒯) where {𝒯}
source
Monty.Gaussian.GaussianCosimulatorType

The GaussianCosimulator type is for simulating a multivariate distribution over points for two fields simultaneously, with cross-correlation, and efficiently reloading the correlation matrix with a new set of points. See the Efficient Simulation example.

Constructors

GaussianCosimulator(
    N::Integer,
    μ::NamedTuple{𝒦,NTuple{2,Vector{𝒯}}},
    ρ::𝒯,
)

GaussianCosimulator(
    samp::CoreSet{𝒯},
    μ::NamedTuple{𝒦,NTuple{2,Vector{𝒯}}},
    ρ::𝒯,
)

GaussianCosimulator(
    samp::CoreSet{𝒯},
    μ::NamedTuple{𝒦,NTuple{2,𝒯}},
    ρ::𝒯,
)
source
Monty.Gaussian.updategaussian!Function
updategaussian!(
    gs::GaussianSimulator{𝒯},
    points::AbstractArray{Meshes.Point{2, 𝒯}},
    c::GeoStatsFunctions.Covariance
)

Updates the covariance matrix for the Simulatorusing aCovariance` model and a group of points.

source
updategaussian!(
    gc::GaussianCosimulator{𝒯},
    points::AbstractArray{Meshes.Point{2, 𝒯}},
    c::GeoStatsFunctions.Covariance
)

Updates the covariance matrix for the Cosimulator using a Covariance model and a group of points.

source
Random.rand!Function
rand!(
    rng::Random.AbstractRNG,
    gs::GaussianSimulator{𝒯},
    y::AbstractArray{𝒯, 1}
)

Samples from the Simulator in-place

source
rand!(
    rng::Random.AbstractRNG,
    gc::GaussianCosimulator{𝒯, 𝒦},
    y::NamedTuple{𝒦}
)

Samples from the Cosimulator in-place, where y is a named tuple that includes the two vectors to fill. The keys of the named tuple must include the analytes that the Cosimulator expects.

source
Base.randFunction
rand(
    rng::Random.AbstractRNG,
    gs::GaussianSimulator{𝒯}
) -> Vector

Samples from the Simulator, returning a new vector

source
rand(
    rng::Random.AbstractRNG,
    gc::GaussianCosimulator{𝒯, 𝒦}
) -> NamedTuple{_A, <:Tuple{Any, Any}} where _A

Samples from the Cosimulator, returning a new vector

source

Measurement

Monty.Measuring.noiseFunction
noise(rng::Random.AbstractRNG, x::Number, σᵣ::Number) -> Any

Apply normally distributed noise to a number x, where the noise magnitude is expressed by the relative standard devation (σᵣ) of the number (the coefficient of variation or cv).

source
Monty.Measuring.MeasurementType

A Measurement behaves much like a Sample but has no core count. It represents observed values for a sample, after measurement noise is applied, and is produced by the measure methods.

The fields are

  • concentrations

  • mass

source
Monty.Measuring.measureFunction
measure(
    rng::Random.AbstractRNG,
    sample::Sample{𝒩, 𝒦},
    σᵣ::NamedTuple{𝒦, Tuple{Vararg{𝒯<:Real, 𝒩}}},
    σₘ::Real
) -> Measurement

Computes measured analyte concentrations from a Sample by applying random normally distributed measurement noise to the exact values in the sample. Noise magnitude for analyte concentrations is defined by the relative standard deviation σᵣ, a named tuple with one value for each analyte in the sample. The measured sample mass noise is defined by relative standard deviation σᵣ. Returns a Measurement instance.

source

Tabulation

Each of the main composite types in Monty can be exported to a GeoTable, which can then be exported to a number of file formats using GeoIO.jl.

GeoTables.GeoTableType
GeoTable(
    sim::Simulation,
    plan::SamplePlan
) -> GeoTable{T} where T<:(NamedTuple{names, T} where {T<:Tuple, names})

Creates a tabular representation of the simulation using the GeoTable format. The measurement for each composited location is assigned from the sample plan.

source
GeoTable(
    sim::Simulation,
    samp::CoreSet,
    plan::SamplePlan
) -> Any

Creates a tabular representation of the simulation using the GeoTable format. The measurement for each composited location is assigned by averaging the locations of each core in the core set.

source
GeoTable(
    plan::SamplePlan
) -> GeoTable{T} where T<:(NamedTuple{(:location, :round, :time, :control), <:Tuple{ReadOnlyArrays.ReadOnlyVector{UInt16, Vector{UInt16}}, ReadOnlyArrays.ReadOnlyVector{UInt16, Vector{UInt16}}, ReadOnlyArrays.ReadOnlyArray{𝒯, 1, Vector{𝒯}} where 𝒯, ReadOnlyArrays.ReadOnlyVector{Bool, Vector{Bool}}}})

Creates a tabular representation of the sample plan using the GeoTable format.

source
GeoTable(samp::CoreSet, plan::SamplePlan) -> Any

Creates a tabular representation of the core set using the GeoTable format. The locations of each core in the CoreSet are tabulated along with the metadata for each group from the sample plan.

source

CDR Potential

There are a few convenience functions for computing the CDR potential of a feedstock.

Monty.CDRPotential.cationCO2Function
cationCO2(cation::Symbol) -> Float64

Computes the mass of CO2 captured per unit mass of a mobile cation. The cation must be one of [:Ca, :Mg, :Na, :K].

source
Monty.CDRPotential.cdrpotentialFunction
cdrpotential(
    cation::Union{String, Symbol},
    concentration
) -> Any

Computes the maximum amount of CDR available for a given feedstock composition.

source
cdrpotential(
    conc::NamedTuple{𝒦, Tuple{Vararg{𝒯, 𝒩}}}
) -> Any

Computes CDR potential from a named tuple of feedstock concentrations.

source
cdrpotential(conc::Dict) -> Any

Computes CDR potential from a dict of feedstock concentrations.

source