API Documentation
CarboKitten.run_model — Function
run_model(f, ::Type{Model{M}}, input::AbstractInput) where M
run_model(f, ::Type{Model{M}}, input::AbstractInput, state::AbstractState) where MRun a model and send Frames 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 MRun a model and write output to HDF5.
run_model(Model{ALCAP}, ALCAP.Example.INPUT, "example.h5")run_model(::Type{Model{M}}, input::AbstractInput, output::AbstractOutput) where MRun a model and save the output to output.
CarboKitten.Box — Type
Box{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 — Function
box_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 — Type
TimeProperties(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 — Function
time_axis(time::TimeProperties)Retrieve the time values for which output was/will be written. Returns a range.
CarboKitten.n_steps — Function
n_steps(input)Returns the number of steps from a given input.
Components
CarboKitten.Components.CellularAutomaton.step_ca — Method
step_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 — Method
disintegrator(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 — Method
transporter(input::Input) -> fPrepares the transportation step. Returns a function f(state::State, active_layer), transporting the active layer, returning a transported Amount of sediment.
Output
CarboKitten.Output.Abstract.add_data_set — Function
add_data_set(out::T, name::Symbol, spec::OutputSpec)Add a data set to the output object.
CarboKitten.Output.Abstract.frame_writer — Method
frame_writer(input::AbstractInput, out::T)Returns a function (idx::Int, state::AbstractState).
Write the state of the simulation to the output object. It is the responsibility of the implementation to choose to write or not based on the set write interval.
The default implementation writes the state for all output data sets, and calls write_sediment_thickness.
CarboKitten.Output.Abstract.new_output — Function
new_output(::Type{T}, input)Create a new output object of type T, given input.
CarboKitten.Output.Abstract.state_writer — Method
state_writer(input::AbstractInput, out::T)Returns a function (idx::Int, state::AbstractState).
Write the state of the simulation to the output object. It is the responsibility of the implementation to choose to write or not based on the set write interval.
The default implementation writes the state for all output data sets, and calls write_sediment_thickness.
CarboKitten.Output.Abstract.write_deposition — Function
write_deposition(out::T, name::Symbol, idx::Int, data::AbstractArray{Amount, dim}) where {T, dim}See write_sediment_thickness. Should accept 1, 2, and 3 dimensional arrays, corresponding to writing column, slice or volume data. (first axis is facies, then x and y)
CarboKitten.Output.Abstract.write_disintegration — Function
write_disintegration(out::T, name::Symbol, idx::Int, data::AbstractArray{Amount, dim}) where {T, dim}See write_sediment_thickness. Should accept 1, 2, and 3 dimensional arrays, corresponding to writing column, slice or volume data. (first axis is facies, then x and y)
CarboKitten.Output.Abstract.write_production — Function
write_production(out::T, name::Symbol, idx::Int, data::AbstractArray{Amount, dim}) where {T, dim}See write_sediment_thickness. Should accept 1, 2, and 3 dimensional arrays, corresponding to writing column, slice or volume data. (first axis is facies, then x and y)
CarboKitten.Output.Abstract.write_sediment_thickness — Function
write_sediment_thickness(out::T, name::Symbol, idx::Int, data::AbstractArray{Amount, dim}) where {T, dim}Write the sediment thickness to the output object. The idx should be corrected for write interval. That is, idx should range from 1 to n_writes for the named data set. This function should be implemented for 0, 1, and 2 dimensional arrays, corresponding to writing column, slice or volume data.
If your output object type doesn't conform to the standard CarboKitten data layout, you may choose to not implement this function and implement state_writer and frame_writer instead. The same goes for write_production, write_disintegration and write_deposition.
CarboKitten.set_attribute — Function
set_attribute(out::T, name::String, value::Any)Set an attribute in the output object.
CarboKitten.run_model — Method
run_model(::Type{Model{M}}, input::AbstractInput, filename::AbstractString) where MRun a model and write output to HDF5.
run_model(Model{ALCAP}, ALCAP.Example.INPUT, "example.h5")Utility
CarboKitten.Utility.enumerate_seq — Method
enumerate_seq(s)Enumerates an iterator of sequences, such that the following equivalence holds:
enumerate(flatten(s)) == flatten(enumerate_seq(s))CarboKitten.Utility.find_ranges — Method
find_ranges(v::AbstractVector{Bool})Take a vector of bools, returns an iterator over all ranges for which the vector is true.
CarboKitten.Skeleton.skeleton — Method
skeleton(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! — Method
stencil!(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 — Method
age_depth_model(sediment_accumulation_curve::Vector)
age_depth_model(sediment_accumulation_curve::DataFrame)Compute the ADM from the SAC. Implemented as:
reverse ∘ accumulate(min) ∘ reverseThe DataFrame version selects SAC columns, transformed into ADM.
CarboKitten.Export.data_export — Method
data_export(spec::CSV, header::Header, data)Exports data to CSV. Here, data should be a collection or iterable of DataColumn.
CarboKitten.Export.extract_sac — Method
extract_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 — Method
extract_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 — Method
extract_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 — Method
stratigraphic_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 — Method
unitful_headers(df::DataFrame)Gets a string representation for all column names including their unit. Returns a Vector{String}.
CarboKitten.Export.write_unitful_csv — Method
write_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 — Method
ustrip(df::DataFrame)Strip units from a DataFrame. Returns a new DataFrame.
Transport
CarboKitten.Transport.Advection.transport! — Method
transport!(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 — Method
transport(box, diffusivity, wave_velocity, wave_shear,
C, w)Non-mutating version of transport!. Allocates and returns dC.
Submodules
CarboKitten.Denudation.Abstract.denudation — Method
denudation(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 — Method
denudation(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 — Method
redistribution()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 — Module
module NoDenudationDoesn't do any denudation: used for testing purposes.