
pyReef-Core
pyReef-Core is a deterministic, one-dimensional (1-D) numerical model, that simulates the vertical coralgal growth patterns observed in a drill core, as well as the physical, environmental processes that effect coralgal growth. The model is capable of integrating ecological processes like coralgal community interactions over centennial-to-millennial scales using predator-prey or Generalised Lotka-Volterra Equations.
Schematic figure of a hypothetical reef with transitions from shallow to deep assemblages occurring down-core, illustrating growth-form responses of corals to environmental forcing including light, sea level changes (sl), uplift and subsidence (u/s), hydrodynamic energy (w wave conditions and c currents), nutrients input nu, ocean temperature (T) and acidity (pH), karstification (k) and sediment flux.
Content:
Generalized Lotka-Volterra model
The most common models of communities evolution in ecological modeling are the predator-prey Lotka-Volterra (LV) equation and its modifications.
From LV equations, one can formulate the Generalized Lotka-Volterra (GLV) equation that allows unlimited number of communities and different types of interactions among communities. The GLV equation is mainly formed by two parts, the logistic growth/decay of a communities and its interaction with the other communities,

where
is the population density of communities i;
is the intrinsic rate of increase/decrease of a population of communities i (also called Malthusian parameter);
is the interaction coefficient among the communities association i and j, (a particular case is
, the interaction of one community association with itself); and t is time. Equation 1 can be written in matrix formulation as:

where
is the vector of population densities of each community i,
is the vector of all Mathusian parameters,
is the matrix of interaction coefficients, also known as community matrix, and
is a square matrix with diagonal elements equal to
, and zeros outside the diagonal.
Back to content
Communities rate and community matrix
To solve the ODEs, the user needs to define several initial conditions:
- the initial community population number

- the intrinsic rate of a population community

- the interaction coefficients among the communities association

Several other inputs are required and will need to be set in the XmL inputfile. An example of such file is provided in the Tests folder and all the options are explained in the Input file structure.
Back to content
Solving the ODEs system
The mathematical model for the communities population evolution results in a set of differential equations (ODEs), one for each communities associations modeled. The Runge-Kutta-Fehlberg method (RKF45 or Fehlberg as defined in the odespy library) is used to solve the GLV ODE system.
Back to content
Carbonate production
Once a community association population is computed, carbonate production is calculated using a carbonate production factor. Production factors are specified for the maximum population, and linearly scaled to the actual population following the relation

where
is the carbonate production,
is time,
is the carbonate production factor when population is at its maximum, and
is the maximum population of community i, computed as

which gives:

We define the maximum carbonate production rate (m/y) for each community in the XmL input file.
Back to content
Model workflow
Illustration outlining PyReef-Core workflow (left) and of the resulting simulated core (right). First boundary conditions for sea level, sediment input, tectonics, temperature, pH, nutrients and flow velocity are set, which describes their relationship to either depth or time. The boundary conditions are used to establish the environment factor fenv which describes the proportion of the maximum growth rate that an assemblage can achieve, depending on whether the environmental conditions exceed the optimal conditions for growth. The environment factor is set to scale the Malthusian parameter, which is in turn used as input in the GLVE equations to determine assemblage populations. Larger assemblage populations contribute to a faster rate of vertical accretion (here referred to as carbonate production). In case of subaerial exposure, karstification might occur. At the end of the timestep, boundary conditions are updated and the process is repeated.
Back to content
Installation
Local install
The code is available from our github page and can be obtained either from this page or using git
git clone https://github.com/pyReef-model/pyReefCore.git
Once donwloaded, navigate to the pyReefCore folder and run the following command:
pip install -e /workspace/volume/pyReefCore/
Docker container
The code is available from Docker Hub at pyreefmodel/pyreef-Docker and can be downloaded using Kitematic. Examples are provided in the Tests folder and are ran through IPython Notebooks.
Back to content
Usage
pyReef-Core can be used from an IPython notebook or a python script directly. An example of functions available is provided below:
%matplotlib inline
import numpy as np
import cmocean as cmo
import matplotlib.pyplot as plt
%config InlineBackend.figure_format = 'svg'
from pyReefCore.model import Model
# Initialise model
reef = Model()
# Define the XmL input file
reef.load_xml('input.xml')
# Visualise initial setting parameters
reef.core.initialSetting(size=(10,4), fname='input')
# Run to a given time (for example 500 years)
reef.run_to_time(500.,showtime=500.,verbose=False)
# Define a colorscale to display the core
# Some colormaps are available from the following link:
# http://matplotlib.org/examples/color/colormaps_reference.html
from matplotlib.cm import terrain, plasma
nbcolors = len(reef.core.coralH)+10
colors = terrain(np.linspace(0, 1, nbcolors))
nbcolors = len(reef.core.layTime)+3
colors2 = plasma(np.linspace(0, 1, nbcolors))
# Plot evolution of communities population with time
reef.plot.communityTime(colors=colors, size=(10,4), font=8, dpi=100,fname='apop_t.pdf')
# Plot evolution of communities population with depth
reef.plot.communityDepth(colors=colors, size=(10,4), font=8, dpi=100, fname ='apop_d.pdf')
# Plot temporal evolution of accommodation and core thickness
reef.plot.accommodationTime(size=(10,4), font=8, dpi=100, fname ='acc_t.pdf')
# Plot coral facies distribution, assemblages as a synthetic core
reef.plot.drawCore(lwidth = 3, colsed=colors, coltime = colors2, size=(10,8), font=8, dpi=380,
figname=('core.pdf'), filename='core.csv', sep='\t')
Back to content
<?xml version="1.0" encoding="UTF-8"?>
<pyreefcore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Back to content
Time structure
REQUIRED
<time>
<start>-140000.</start>
<end>0.</end>
<tcarb>5.</tcarb>
<display>100.</display>
<laytime>25.</laytime>
</time>
Back to input structure
Habitats structure
REQUIRED
<habitats>
<depth>25.</depth>
<communityNb>3</communityNb>
<maxPopulation>10</maxPopulation>
<facOpt>0.9</facOpt>
<karstRate>0.07e-3</karstRate>
<community>
<name>shallow</name>
<malthus>0.004</malthus>
<population>0.</population>
<production>0.011</production>
</community>
<community>
<name>moderate deep</name>
<malthus>0.004</malthus>
<population>0.</population>
<production>0.012</production>
</community>
<community>
<name>deep</name>
<malthus>0.004</malthus>
<population>0.</population>
<production>0.009</production>
</community>
<communityMatrix>
<value col="0" row="0">-0.0005</value>
<value col="1" row="0">-0.0001</value>
<value col="2" row="0">0.</value>
<value col="0" row="1">-0.0001</value>
<value col="1" row="1">-0.0005</value>
<value col="2" row="1">-0.0001</value>
<value col="0" row="2">0.0</value>
<value col="1" row="2">-0.0001</value>
<value col="2" row="2">-0.0005</value>
</communityMatrix>
</habitats>
Back to input structure
Sea-level structure
OPTIONAL
<sea>
<val>0.</val>
<curve>data/grantetal.csv</curve>
</sea>
Back to input structure
Tectonic structure
OPTIONAL
<tec>
<val>-0.1e-3</val>
</tec>
Back to input structure
Temperature structure
OPTIONAL
<temp>
<curve>data/temperature.csv</curve>
</temp>
Back to input structure
pH structure
OPTIONAL
<pH>
<curve>data/pH.csv</curve>
</pH>
Back to input structure
OPTIONAL
<Nu>
<curve>data/pH.csv</curve>
</Nu>
Back to input structure
Flow structure
OPTIONAL
<flow>
<function>
<expdecay>
<fdvalue col="0" row="0">0.03</fdvalue>
<fdvalue col="1" row="0">0.05</fdvalue>
<fdvalue col="2" row="0">0.06</fdvalue>
<fdvalue col="3" row="0">0.13</fdvalue>
<fdvalue col="4" row="0">0.25</fdvalue>
<fdvalue col="0" row="1">25</fdvalue>
<fdvalue col="1" row="1">15.</fdvalue>
<fdvalue col="2" row="1">10.</fdvalue>
<fdvalue col="3" row="1">3.</fdvalue>
<fdvalue col="4" row="1">0.</fdvalue>
</expdecay>
</function>
</flow>
Back to input structure
Sediment structure
OPTIONAL
<sedinput>
<function>
<linear>
<dmax>30.</dmax>
<a>15000</a>
<b>-15.</b>
</linear>
<?ignore
<expdecay>
<!-- X coordinates (sediment input) m/d -->
<sdvalue col="0" row="0">1.e-7</sdvalue>
<sdvalue col="1" row="0">5.e-7</sdvalue>
<sdvalue col="2" row="0">1.e-6</sdvalue>
<!-- Y coordinates (depth) m -->
<sdvalue col="0" row="1">20</sdvalue>
<sdvalue col="1" row="1">3.</sdvalue>
<sdvalue col="2" row="1">0.</sdvalue>
</expdecay>
?>
</function>
</sedinput>
Back to input structure
Environmental structure
Using the XmL input file you will be able to calibrate the environmental threshold functions for different assemblages. Figure below shows an example of calibration for shallow, moderate-deep and deep assemblages characteristic of a synthetic exposed margin. The x-axis indicates the limitation on maximum vertical accretion for conditions outside the optimal.
REQUIRED
<envishape>
<depthshape>
<dvalue col="0" row="0">0.</dvalue>
<dvalue col="1" row="0">0.</dvalue>
<dvalue col="2" row="0">6.</dvalue>
<dvalue col="3" row="0">12.</dvalue>
<dvalue col="0" row="1">4.</dvalue>
<dvalue col="1" row="1">6.</dvalue>
<dvalue col="2" row="1">20.</dvalue>
<dvalue col="3" row="1">22.</dvalue>
<dvalue col="0" row="2">18.</dvalue>
<dvalue col="1" row="2">20.</dvalue>
<dvalue col="2" row="2">30.</dvalue>
<dvalue col="3" row="2">32.</dvalue>
</depthshape>
<flowshape>
<fvalue col="0" row="0">0.05</fvalue>
<fvalue col="1" row="0">0.06</fvalue>
<fvalue col="2" row="0">0.25</fvalue>
<fvalue col="3" row="0">0.3</fvalue>
<fvalue col="0" row="1">0.</fvalue>
<fvalue col="1" row="1">0.05</fvalue>
<fvalue col="2" row="1">0.09</fvalue>
<fvalue col="3" row="1">0.12</fvalue>
<fvalue col="0" row="2">0.</fvalue>
<fvalue col="1" row="2">0.</fvalue>
<fvalue col="2" row="2">0.04</fvalue>
<fvalue col="3" row="2">0.08</fvalue>
</flowshape>
<sedshape>
<svalue col="0" row="0">0.</svalue>
<svalue col="1" row="0">0.</svalue>
<svalue col="2" row="0">0.0016</svalue>
<svalue col="3" row="0">0.003</svalue>
<svalue col="0" row="1">0.0015</svalue>
<svalue col="1" row="1">0.0018</svalue>
<svalue col="2" row="1">0.0024</svalue>
<svalue col="3" row="1">0.003</svalue>
<svalue col="0" row="2">0.0023</svalue>
<svalue col="1" row="2">0.0026</svalue>
<svalue col="2" row="2">0.004</svalue>
<svalue col="3" row="2">0.0045</svalue>
</sedshape>
</envishape>
Back to input structure
Output folder structure
REQUIRED
<outfolder>output-name</outfolder>
Back to input structure
</pyreefcore>
Back to content
Examples
Example of a core sample, including a well-preserved Faviidae coral recovered from 16 m depth. The red arrows are drawn on to indicate upwards recovery direction from One Tree Reef (Geocoastal Research Group - The University of Sydney).
Two case studies are shipped with the code and can form the basis for defining your own model.
Idealised case shallowing-up fossil reef sequence
Communities & core evolution
Change in community population over time and through depth associated to sea-level fluctuations imposed using Sloss et al. (2007) curve. As well as evolution of accommodation space, elevation, cumulative thickness and communities production rates simulated using pyReef-Core.
Synthetic core
Schematic representation of synthetic data construction. (Left) Ideal shallowing-up fossil reef sequence representing a ‘catch-up’ growth strategy with associated assemblage compositions and changes, adapted from Dechnik (2016); (Right) Model output of synthetic core representing ideal shallowing-upward, ‘catch-up’ sequence.
Coral-reef records reconstruction since the last interglacial
Communities & core evolution
Change in community population over time and through depth associated to sea-level fluctuations imposed using Grant et al. (2012) curve. As well as evolution of accommodation space, elevation, cumulative thickness and communities production rates simulated using pyReef-Core.
Synthetic core
Schematic representation of synthetic data construction.
Back to content
评论