API Documentation
CarboKitten.run_model
— Functionrun_model(f, ::Type{Model{M}}, input::AbstractInput) where M
run_model(f, ::Type{Model{M}}, input::AbstractInput, state::AbstractState) where M
Run a model and send Frame
s to callback f
. The type parameter M
should be a model, being a module with both initial_state!
and step!
defined.
The second version with explicit state is used by H5Writer
so we can perform an additional action between creating the initial state and starting the model run (saving metadata to the HDF5 file).
run_model(::Type{Model{M}}, input::AbstractInput, filename::AbstractString) where M
Run a model and write output to HDF5. Here M
should be a model, i.e. a module with initial_state
, step!
and write_header
defined. Example:
run_model(Model{ALCAP}, ALCAP.Example.INPUT, "example.h5")
CarboKitten.Box
— TypeBox{BoundaryType}(grid_size, phys_scale)
Stores the spatial properties of the simulation grid, where grid_size
is a tuple of two integers and phys_scale
is a Quantity
of dimension Length
.
CarboKitten.box_axes
— Functionbox_axes(box::Box)
Return the x
and y
components of the box grid in meters. The grid starts at 0.0u"m"
and runs to (box.grid_size .- 1) .* box.phys_scale
.
CarboKitten.TimeProperties
— TypeTimeProperties(t0, Δt, steps, write_interval)
Stores properties of the time integration. Here, t0
and Δt
should be a Quantity
, steps
is the number of integration steps, and write_interval
the number of steps between writing output.
CarboKitten.time_axis
— Functiontime_axis(time::TimeProperties)
Retrieve the time values for which output was/will be written. Returns a range.
Components
CarboKitten.Components.CellularAutomaton.step_ca
— Methodstep_ca(box, facies)
Creates a propagator for the state, updating the celullar automaton in place.
Contract: the state
should have ca::Matrix{Int}
and ca_priority::Vector{Int}
members.
CarboKitten.Components.ActiveLayer.disintegrator
— Methoddisintegrator(input) -> f!
Prepares the disintegration step. Returns a function f!(state::State)
. The returned function modifies the state, popping sediment from the sediment_buffer
and returns an array of Amount
.
CarboKitten.Components.ActiveLayer.transporter
— Methodtransporter(input::Input) -> f
Prepares the transportation step. Returns a function f(state::State, active_layer)
, transporting the active layer, returning a transported Amount
of sediment.
Utility
CarboKitten.Utility.enumerate_seq
— Methodenumerate_seq(s)
Enumerates an iterator of sequences, such that the following equivalence holds:
enumerate(flatten(s)) == flatten(enumerate_seq(s))
CarboKitten.Utility.find_ranges
— Methodfind_ranges(v::AbstractVector{Bool})
Take a vector of bools, returns an iterator over all ranges for which the vector is true
.
CarboKitten.Skeleton.skeleton
— Methodskeleton(bitmap::AbstractMatrix{Bool})
Computes the skeleton of a bitmap, i.e. reduces features with some thickness to a set of line segments. This function is designed with stratigraphic application in mind: we scan each row in the bitmap for connected regions, then link neighbouring regions when they overlap. The result is a graph that represents hiatus in the sediment accumulation.
Returns a tuple of vertices
and edges
, where vertices
is a vector of 2-tuples and edges
is a nx2 matrix of indices into the vertices
.
CarboKitten.Stencil.stencil!
— Methodstencil!(f, Boundary, Size, out, inp...)
Performs stencil operation. The function f
should take a number of abstract arrays (same as the number of inp
values), and return a single value of the same type as elements in out
. The Size
parameter should be a type parameter size of the stencil, e.g. Size(3, 3)
to get a 3 by 3 stencil.
Prefer to use this version over the older implementations.
Export
CarboKitten.Export.age_depth_model
— Methodage_depth_model(sediment_accumulation_curve::Vector)
age_depth_model(sediment_accumulation_curve::DataFrame)
Compute the ADM from the SAC. Implemented as:
reverse ∘ accumulate(min) ∘ reverse
The DataFrame
version select
s SAC columns, transformed into ADM.
CarboKitten.Export.data_export
— Methoddata_export(spec::CSV, header::Header, data)
Exports data
to CSV. Here, data
should be a collection or iterable of DataColumn
.
CarboKitten.Export.extract_sac
— Methodextract_sac(header::Header, data::DataColumn)
Extract Sediment Accumumlation Curve (SAC) from the data. The SAC is directly copied from data.sediment_thickness
. Returns a DataFrame
with time
and sac_<n>
columns where <n>
is in the range 1:length(grid_locations)
.
CarboKitten.Export.extract_sc
— Methodextract_sc(header::Header, data::DataColumn)
Extract Stratigraphic Column (SC) from the data. Returns a DataFrame
with time
and sc<n>
columns where <n>
is in the range 1:length(grid_locations)
.
CarboKitten.Export.extract_wd
— Methodextract_wd(header::Header, data::DataColumn)
Extract the water depth from the data. Returns a DataFrame
with time
and wd<n>
columns where <n>
is in the range 1:length(grid_locations)
.
CarboKitten.Export.stratigraphic_column
— Methodstratigraphic_column(header::Header, column::DataColumn, facies::Int)
Compute the Stratigraphic Column for a given grid position loc
and facies
index. Returns an Array{Quantity, 2}
where the Quantity
is in units of meters.
CarboKitten.Export.unitful_headers
— Methodunitful_headers(df::DataFrame)
Gets a string representation for all column names including their unit. Returns a Vector{String}
.
CarboKitten.Export.write_unitful_csv
— Methodwrite_unitful_csv(io::IO, df::DataFrame)
Write a CSV from a DataFrame
with Unitful
units. The units will be represented in the CSV header, and stripped from the individual values.
Unitful.ustrip
— Methodustrip(df::DataFrame)
Strip units from a DataFrame
. Returns a new DataFrame
.
Transport
CarboKitten.Transport.Advection.transport!
— Methodtransport!(box, diffusivity, wave_velocity,
C, w, dC)
Computes dC
given a box
, diffusivity
constant in units of m/Myr, wave_velocity
is a function of water depth, returning both velocity in units of m/Myr, and shear in units of 1/Myr, which should be the derivative of the velocity w.r.t. water depth. C
is the concentration of entrained sediment, w
the water depth, and dC
the output derivative of C
.
CarboKitten.Transport.Advection.transport
— Methodtransport(box, diffusivity, wave_velocity, wave_shear,
C, w)
Non-mutating version of transport!
. Allocates and returns dC
.
Submodules
CarboKitten.Denudation.Abstract.denudation
— Methoddenudation(box, param, state)
Computes the denudation for a single time-step, given denudation parameters param
and a simulation state state
. param
should have a DenudationType
type and state
should contain the height
property and sealevel
.
Returns denudation mass in units of meters.
CarboKitten.Denudation.Abstract.denudation
— Methoddenudation(box::Box, param::DenudationType, water_depth, slope, facies)
Computes the amount of denudation. This function is called on a pixel by pixel basis, so all arguments can be assumed to be scalar. The param
argument should be of a subtype of DenudationType
containing all the input parameters for this specific denudation model.
CarboKitten.Denudation.Abstract.redistribution
— Methodredistribution()
Takes state
, water_depth
in meters and denudation_mass
as a 3D array (facies, x and y coordinates) in units of meters.
CarboKitten.Denudation.NoDenudationMod
— Modulemodule NoDenudation
Doesn't do any denudation: used for testing purposes.