In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import os
import fnmatch
import shutil
from PIL import Image
import cmocean as cmo

%config InlineBackend.figure_format = 'svg'

ReefCore library

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.


In [ ]:
from pyReefCore.model import Model

Once the library has been loaded, the model initialisation is done using the following command:


In [ ]:
# Initialise model
reef = Model()

XmL input file

The next step consists in defining the initial conditions for our simulation. This is done by using an XmL input file which set the parameters to be used, such as:

  • the initial community population number $X0$
  • the intrinsic rate of a population species $\epsilon$
  • the interaction coefficients among the species association $\alpha$

In [ ]:
# Define the XmL input file
reef.load_xml('input-case2.xml')

Visualise the initial conditions of your model run can be done using the following command:


In [ ]:
reef.core.initialSetting(size=(10,4), fname='input')

Model simulation

The core of the code consist in solving the system of ODEs from the GLV equations using the RKF method.

Once a community association population is resolved, carbonate production is calculated using a carbonate production factor. Production factors are specified for the maximum population, and linearly scaled to the actual population.

To run the model for a given time period [years], the following function needs to be called:


In [ ]:
reef.run_to_time(0,showtime=5000.,verbose=False)

Results

All the output from the model run can be plotted on the notebook using a series of internal functions presented below.

First one can specify a colormap to use for the plot using one of the matplotlib predefined colormap proposed here:


In [ ]:
from matplotlib.cm import terrain, plasma

nbcolors = len(reef.core.coralH)+10
#colors = cmo.cm.dense(np.linspace(0, 4, nbcolors))
colors = terrain(np.linspace(0, 1, nbcolors))

#nbcolors = len(reef.core.layTime)+3
nbcolors = 2500
colors2 = cmo.cm.haline_r(np.linspace(0, 1, nbcolors)) #oxy

Communities population evolution

  • with time: reef.plot.communityTime
  • with depth: reef.plot.communityDepth

In [ ]:
reef.plot.communityTime(colors=colors, size=(10,4), font=8, dpi=100,fname='apop_t.pdf')
reef.plot.communityDepth(colors=colors, size=(10,4), font=8, dpi=100, fname ='apop_d.pdf')
reef.plot.accommodationTime(size=(10,4), font=8, dpi=100, fname ='acc_t.pdf')

Coral synthetic core

The main output of the model consists in the synthetic core which shows the evolution of the coral stratigraphic architecture obtained from the interactions among species and with their environment. The plot is obtained using the following function:

  • reef.plot.drawCore

The user has the option to save:

  • the figure using the figname parameter (figname could either have a .png or .pdf extension)
  • the model output as a CSV file using the filename parameter. This will dump all output dataset for further analysis if required.

In [ ]:
reef.plot.drawCore(lwidth = 3, colsed=colors, coltime = colors2, tstep = 20, size=(12,18), font=8, dpi=500, 
                   figname='core.pdf')

In [ ]: