DynACof.jl: The Dynamic Agroforestry Coffee Crop Model

logo

Stable Dev Build Status Build Status Codecov

Overview

This is a Julia version of the DynACof model. To get to the R version, please follow this link. DynACof is a process-based model that computes plot-scale Net Primary Productivity, carbon allocation, growth, yield, energy, and water balance of coffee plantations according to management, while accounting for spatial effects using metamodels from the 3D process-based MAESPA. The model also uses coffee bud and fruit cohorts for reproductive development to better represent fruit carbon demand distribution along the year.

Installation

To download DynACof, simply execute these lines of code in the REPL:

Pkg.add(DynACof)

The package is tested routinely to pass all tests using Travis-CI (linux) and AppVeyor (Windows).

Example

This is a basic example using the parameters and meteorology from Vezy et al. (2019). The default values of the parameters in DynACof are already the ones from Vezy et al. (2019). To use those default values, you have to put "package" for each parameter in file_name. The meteorology data can be downloaded from a Github repository using the download command.

Execute this line of code to run a simulation over the whole period using both parameters values and meteorology from Vezy et al. (2019):

using DynACof
file= download("https://raw.githubusercontent.com/VEZY/DynACof.jl_inputs/master/meteorology.txt")

Sim, Meteo, Parameters= dynacof(input_path= dirname(file), file_name= (constants= "package",site="package",meteo=basename(file),soil="package",coffee="package",tree="package"))

rm(file)

To use your own data, you have to tell DynACof where to find it using the input_path argument, and what are the file names with the file_name argument. A separate Github repository is available for input files templates with values from Vezy et al. (2019), and some help on how to proceed.

Example of a simulation without shade trees:

Sim, Meteo, Parameters= dynacof(input_path= "the_path_where_you_downloaded_the_data/DynACof.jl_inputs",
                                file_name= (constants= "constants.jl",site="site.jl",meteo="meteorology.txt",
                                            soil="soil.jl",coffee="coffee.jl",tree=""));

Code of conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Acknowledgments

The DynACof model was mainly developed thanks to the MACCAC project[1], which was funded by the french ANR (Agence Nationale de la Recherche). The authors were funded by CIRAD[2] and INRA[3]. The authors are grateful for the support of the Aquiares farm and the CATIE[4] for the long-term coffee agroforestry trial, the SOERE F-ORE-T which is supported annually by Ecofor, Allenvi and the French national research infrastructure ANAEE-F; the CIRAD-IRD-SAFSE project (France) and the PCP platform of CATIE. CoffeeFlux observatory was supported and managed by CIRAD researchers. We are grateful to the staff from Costa-Rica, in particular Alvaro Barquero, Alejandra Barquero, Jenny Barquero, Alexis Perez, Guillermo Ramirez, Rafael Acuna, Manuel Jara, Alonso Barquero for their technical and field support.


<sub>The DynACof logo was made using <a href="http://logomakr.com" title="Logo Makr">LogoMakr.com</a> </sub>

  1. MACACC project ANR-13-AGRO-0005, Viabilité et Adaptation des Ecosystèmes Productifs, Territoires et Ressources face aux Changements Globaux AGROBIOSPHERE 2013 program

  2. Centre de Coopération Internationale en Recherche Agronomique pour le Développement

  3. Institut National de la Recherche Agronomique

  4. Centro Agronómico Tropical de Investigación y Enseñanza

Index

DynACof.coffeeType

Parameter structures

Those structures are used to make the parameter inputs to DynACof. Default values are provided to the user (the struct are Base.@kwdef). They are mainly used under the hood from [Import_Parameters()], but can still be called by the user for conveniance (but not needed for a model run). The Parameters are divided into five structures: constants, site, soil, coffee, and tree.

site:

The site structure. The default values comes from a stand from the Aquiares farm located in Costa Rica. It is a Coffea arabica plantation in agroforestry management under Erythrina poeppigiana shade trees. The plot is visible at this address, and a full desciption is available here and here.

constants

See constants.

soil

The soil structure.

coffee

The coffee structure. The default values comes from a high density plantation (5580 coffee plants per hectares) of Coffea arabica var. Caturra pruned every year to sustain the production on three resprouts per stump in average (see same references than site).

tree

The shade tree structure. The default values come from Erythrina poeppigiana shade trees from Aquiares. They were planted at high density (250 trees ha-1) pruned to optimize light transmitted to the Coffea, and were thinned in 2000 to a low density of ~7.4 trees ha-1. Starting from 2000, these trees made a relatively large crown with an average height of 26 m in 2018 on this site. NB: the tree parameter structure is optional, and not needed for monospecific coffee plantations.

Return

An instance of a structure with Parameters needed for a DynACof simulation.

Details

The values of the instance can be read from files using import_parameters. In that case, the user can provide only the parameter values that need to be changed, and all others will be taken as the default values. Example files are provided in a specific Github repository here.

source
DynACof.constantsType

Physical constants used in the DynACof package

This function defines the following constants:

  • cp: specific heat of air for constant pressure ($J\ K^{-1}\ kg^{-1}$), Source: Allen 1998 FAO Eq. 8 p. 32
  • epsi: Ratio of the molecular weight of water vapor to dry air (=Mw/Md)
  • pressure0: reference atmospheric pressure at sea level (kPa)
  • FPAR: Fraction of global radiation that is PAR (source: MAESPA model)
  • g: gravitational acceleration ($m\ s^{-2}$)
  • Rd: gas constant of dry air ($J\ kg^{-1}\ K^{-1}$), source : Foken p. 245
  • Rgas: universal gas constant ($J\ mol^{-1}\ K^{-1}$)
  • Kelvin: conversion degree Celsius to Kelvin
  • vonkarman: von Karman constant (-)
  • MJtoW: coefficient to convert MJ into W ($W\ MJ^{-1}$)
  • Gsc: solar constant ($W\ m^{-2}=J\ m^{-2}\ s^{-1}$), source : Khorasanizadeh and Mohammadi (2016)
  • σ (sigma): Stefan-Boltzmann constant ($W\ m^{-2}\ K^{-4}$)
  • H2OMW: Conversion factor from kg to mol for H2O ($kg\ mol^{-1}$)
  • W_umol: Conversion factor from watt to micromole for H2O ($W\ \mu mol^{-1}$)
  • λ (lambda): Latent heat of vaporization ($MJ\ kg_{H2O}^{-1}$)
  • cl: Drag coefficient per unit leaf area ($m\ s^{-1}$)
  • Dheat: Molecular diffusivity for heat ($m\ s^{-1}$)
  • GBVGBH: Conversion factor from conductance to water to conductance to heat.
  • M_H20: H2O molar mass ($kg\ mol^{-1}$)

Values are partly burrowed from bigleaf::bigleaf.constants()

References

  • Allen, R. G., et al. (1998). "Crop evapotranspiration-Guidelines for computing crop water requirements-FAO Irrigation and drainage paper 56." 300(9): D05109.
  • Foken, T, 2008: Micrometeorology. Springer, Berlin, Germany.
  • Khorasanizadeh, H. and K. Mohammadi (2016). "Diffuse solar radiation on a horizontal surface: Reviewing and categorizing the empirical models." Renewable and Sustainable Energy Reviews 53: 338-362.
source
DynACof.siteType

Parameter structures

Those structures are used to make the parameter inputs to DynACof. Default values are provided to the user (the struct are Base.@kwdef). They are mainly used under the hood from [Import_Parameters()], but can still be called by the user for conveniance (but not needed for a model run). The Parameters are divided into five structures: constants, site, soil, coffee, and tree.

site:

The site structure. The default values comes from a stand from the Aquiares farm located in Costa Rica. It is a Coffea arabica plantation in agroforestry management under Erythrina poeppigiana shade trees. The plot is visible at this address, and a full desciption is available here and here.

constants

See constants.

soil

The soil structure.

coffee

The coffee structure. The default values comes from a high density plantation (5580 coffee plants per hectares) of Coffea arabica var. Caturra pruned every year to sustain the production on three resprouts per stump in average (see same references than site).

tree

The shade tree structure. The default values come from Erythrina poeppigiana shade trees from Aquiares. They were planted at high density (250 trees ha-1) pruned to optimize light transmitted to the Coffea, and were thinned in 2000 to a low density of ~7.4 trees ha-1. Starting from 2000, these trees made a relatively large crown with an average height of 26 m in 2018 on this site. NB: the tree parameter structure is optional, and not needed for monospecific coffee plantations.

Return

An instance of a structure with Parameters needed for a DynACof simulation.

Details

The values of the instance can be read from files using import_parameters. In that case, the user can provide only the parameter values that need to be changed, and all others will be taken as the default values. Example files are provided in a specific Github repository here.

source
DynACof.soilType

Parameter structures

Those structures are used to make the parameter inputs to DynACof. Default values are provided to the user (the struct are Base.@kwdef). They are mainly used under the hood from [Import_Parameters()], but can still be called by the user for conveniance (but not needed for a model run). The Parameters are divided into five structures: constants, site, soil, coffee, and tree.

site:

The site structure. The default values comes from a stand from the Aquiares farm located in Costa Rica. It is a Coffea arabica plantation in agroforestry management under Erythrina poeppigiana shade trees. The plot is visible at this address, and a full desciption is available here and here.

constants

See constants.

soil

The soil structure.

coffee

The coffee structure. The default values comes from a high density plantation (5580 coffee plants per hectares) of Coffea arabica var. Caturra pruned every year to sustain the production on three resprouts per stump in average (see same references than site).

tree

The shade tree structure. The default values come from Erythrina poeppigiana shade trees from Aquiares. They were planted at high density (250 trees ha-1) pruned to optimize light transmitted to the Coffea, and were thinned in 2000 to a low density of ~7.4 trees ha-1. Starting from 2000, these trees made a relatively large crown with an average height of 26 m in 2018 on this site. NB: the tree parameter structure is optional, and not needed for monospecific coffee plantations.

Return

An instance of a structure with Parameters needed for a DynACof simulation.

Details

The values of the instance can be read from files using import_parameters. In that case, the user can provide only the parameter values that need to be changed, and all others will be taken as the default values. Example files are provided in a specific Github repository here.

source
DynACof.treeType

Parameter structures

Those structures are used to make the parameter inputs to DynACof. Default values are provided to the user (the struct are Base.@kwdef). They are mainly used under the hood from [Import_Parameters()], but can still be called by the user for conveniance (but not needed for a model run). The Parameters are divided into five structures: constants, site, soil, coffee, and tree.

site:

The site structure. The default values comes from a stand from the Aquiares farm located in Costa Rica. It is a Coffea arabica plantation in agroforestry management under Erythrina poeppigiana shade trees. The plot is visible at this address, and a full desciption is available here and here.

constants

See constants.

soil

The soil structure.

coffee

The coffee structure. The default values comes from a high density plantation (5580 coffee plants per hectares) of Coffea arabica var. Caturra pruned every year to sustain the production on three resprouts per stump in average (see same references than site).

tree

The shade tree structure. The default values come from Erythrina poeppigiana shade trees from Aquiares. They were planted at high density (250 trees ha-1) pruned to optimize light transmitted to the Coffea, and were thinned in 2000 to a low density of ~7.4 trees ha-1. Starting from 2000, these trees made a relatively large crown with an average height of 26 m in 2018 on this site. NB: the tree parameter structure is optional, and not needed for monospecific coffee plantations.

Return

An instance of a structure with Parameters needed for a DynACof simulation.

Details

The values of the instance can be read from files using import_parameters. In that case, the user can provide only the parameter values that need to be changed, and all others will be taken as the default values. Example files are provided in a specific Github repository here.

source
DynACof.ALSMethod

American Leaf Spot

Compute the percentage of Coffea leaves dying from American Leaf Spot disease, drought excluded. The function needs at least a year of data at daily time-step.

Arguments

  • Elevation::Float64: Site elevation (m.a.s.l)
  • df_rain::DataFrame Data frame with DOY, year and Rain (mm) values at daily time-step, with a whole year (or more) of data
  • SlopeAzimut::Float64: Slope azimuth (degree)
  • Slope::Float64: Slope percentage (%)
  • RowDistance::Float64: Coffee rows distance (m)
  • Shade::Float64: Shade percentage (%)
  • height_coffee::Float64: Coffee Height (m)
  • Fertilization::Int64: N fertilization per year
  • ShadeType::Int64: Shade type:
    • 1: Legume only
    • 2: Bananas and legume
    • 3: Bananas and other plants
    • 4: Fruit and forest trees only
    • 5: No shade (Full sun)
  • CoffeePruning::String Character specifying the pruning management. Values: "tree", "row", "block" or "" (empty String, no pruning).

Note

All arguments are named. It is good practice to use shade tree transmittance to compute "Shade" percentage (Shade= 1-Transmittance).

Return

ALS: Percentage of dead leaves by ALS by day (% day-1)

References

Avelino et al. (2007) Topography and Crop Management Are Key Factors for the Development of American Leaf Spot Epidemics on Coffee in Costa Rica. File: "Iadigitized from Avelino 2007 - JAlineaire.xlsx"

Examples

using DataFrames
# Making df_rain :
df_rain= DataFrame(DOY= 1:365, year= fill(2018,365), Rain= rand(0:0.1:5, 365))
ALS(Elevation = 1000, df_rain= df_rain)
source
DynACof.CNMethod

Temperature-dependent correction coefficient for nodes (CN)

Computes the temperature-dependent correction coefficient for green nodes in the coffee plant according to Drinnan and Menzel (1995).

Arguments

  • Tair::Float64 The average air temperature during the vegetative growing period

Return

The correction coefficient to compute the number of green nodes in the coffee (see Eq. 26 from Vezy et al. (in prep.))

References

  • Drinnan, J. and C. Menzel, Temperature affects vegetative growth and flowering of coffee (Coffea arabica L.).

Journal of Horticultural Science, 1995. 70(1): p. 25-34.

Examples

CN(25.0)
source
DynACof.ET_to_LEFunction

Conversion between Latent Heat Flux and Evapotranspiration

Description

Converts evaporative water flux from mass (ET, evapotranspiration) to energy (LE, latent heat flux) units, or vice versa.

Arguments

  • LE::Float64: Latent heat flux (W m-2)
  • ET::Float64: Evapotranspiration (kg m-2 s-1)
  • Tair::Float64: Air temperature (deg C)

Details

The conversions are given by:

  • ET = LE/λ
  • LE = λ ⋅ ET

where λ is the latent heat of vaporization (J kg-1) as calculated by latent_heat_vaporization.

References

These functions are adapted from the code of bigleaf::LE.to.ET

Examples

# LE of 200 Wm-2 and air temperature of 25degC
LE_to_ET(200.0,25.0)
source
DynACof.GDDMethod
GDD(30.0,27.0,5.0)

Compute the daily growing degree days (GDD) using the maximum and minimum daily temperature.

Arguments

  • Tmax::Float64: Maximum daily temperature (Celsius degree)
  • Tmin::Float64: Minimum daily temperature (Celsius degree)
  • MinTT::Float64: Minimum temperature threshold, also called base temperature (Celsius degree), default to 5.

Please keep in mind that this function gives an approximation of the degree days. GDD are normally computed as the integral of hourly (or less) values.

Return

GDD: Growing degree days (Celsius degree)

Examples

GDD(30.0,27.0,5.0)
23.5
source
DynACof.GDDMethod
GDD(25.,5.0)

Compute the daily growing degree days (GDD) directly from the daily mean temperature.

Arguments

  • Tmean::Float64: Average daily temperature (Celsius degree).
  • MinTT::Float64: Minimum temperature threshold, also called base temperature (Celsius degree), default to 5.

Return

GDD: Growing degree days (Celsius degree)

Examples

GDD(25.0,5.0)
20.0
GDD(5.0,5.0)
0.0
source
DynACof.G_bulkMethod

Bulk aerodynamic conductance

Compute the aerodynamic conductance for sensible and latent heat above the canopy following Van de Griend and Van Boxel (1989).

Arguments

  • Wind::Float64: Average daily wind speed above canopy (m s-1)
  • LAI::Float64: Leaf area index of the upper layer (m2 leaf m-2 soil)
  • ZHT::Float64: Wind measurement height (m)
  • Z_top::Float64: Average canopy height of the taller crop (m)
  • Z0::Float64: Roughness length (m). Default: 0.1 ⋅ Z_top
  • ZPD::Float64: Zero-plane displacement (m), Default: 0.75*Z_top
  • α::Float64: Alpha, the constant for diffusivity at top canopy. Default: 1.5 following Van de Griend et al (1989).
  • ZW::Float64: Top height of the roughness sublayer (m). Default: ZPD + α ⋅ (Z_top - ZPD)
  • extwind::Float64: Extinction coefficient. Default: 0, no extinction.
  • vonkarman::Float64: Von Karman constant, default to constants().vonkarman, 0.41.
  • verbose::Bool: Print information of test_ZHT

Details

All arguments are named. α can also be computed as: α=\frac{zw-d}{Z_{top}-d} The bulk aerodynamic conductance ga_{bulk} is computed as follow: ga_{bulk}=\frac{1}{r1+r2+r3} where r1, r2 and r3 are the aerodynamic resistances of the inertial sublayer, the roughness sublayer and the top layer of the canopy respectively. Because wind speed measurements are more often made directly in the roughness sublayer, the resistance in the inertial sublayer r1 is set to 0 though. r2 and r3 are computed using the equation 43 of Van de Griend and Van Boxel (refer to the web version of the help file for Latex rendering): r2=\int_{zh}^{zw}\frac{1}{K''} with K''= kU_*(z_w-d) And: r3=\int_{(z2+z1)/2}^{zh}\frac{1}{K'''}\mathrm{d}z with K'''= U_z\frac{K_h}{U_h} Integration of r2 and r3 equations give: \frac{(\ln(ZPD-ZW)^2-\ln(ZPD-Z2)^2)}{(2kU_*)} simplified in: r2= \frac{1}{kU_*}\ln(\frac{ZPD-ZW}{ZPD-Z2}) and finaly: r3= \frac{Uh}{Kh}\ln(\frac{Uh}{U_{interlayer}})

Return

G_bulk: The bulk aerodynamic conductance (m s-1)

References

Van de Griend, A.A. and J.H. Van Boxel, Water and surface energy balance model with a multilayer canopy representation for remote sensing purposes. Water Resources Research, 1989. 25(5): p. 949-971.

See also

G_interlay and GetWind, which is used internaly.

Examples

# The bulk aerodynamic conductance for a coffee plantation managed in agroforestry system:
G_bulk(Wind=3.0,ZHT=25.0,Z_top=24.0,LAI = 0.5,extwind = 0.58)
source
DynACof.G_interlayMethod

Canopy layer to canopy layer aerodynamic conductance

Compute the aerodynamic conductance for sensible and latent heat between canopy layers following Van de Griend and Van Boxel (1989).

Arguments

  • Wind::Float64: Average daily wind speed above canopy (m s-1)
  • LAI_top::Float64: Leaf area index of the upper layer (m2 leaf m-2 soil).
  • LAI_bot::Float64: Leaf area index of the layer below the upper layer (m2 leaf m-2 soil).
  • ZHT::Float64: Wind measurement height (m)
  • Z_top::Float64: Average canopy height of the taller crop (m)
  • Z0::Float64: Roughness length (m). Default: 0.1*Z_top
  • ZPD::Float64: Zero-plane displacement (m), Default: 0.75*Z_top
  • α::Float64: Alpha, the constant for diffusivity at top canopy. Default: 1.5 following Van de Griend et al (1989).
  • ZW::Float64: Top height of the roughness sublayer (m). Default: ZPD+α*(Z_top-ZPD)
  • extwind::Float64: Extinction coefficient. Default: 0, no extinction.
  • vonkarman::Float64: Von Karman constant, default to constants().vonkarman, 0.41.
  • verbose::Bool: Print information of test_ZHT

All arguments are named.

Details

α can also be computed as: α=\frac{zw-d}{Z_{top}-d} The aerodynamic conductance between canopy layers is computed as: g_{af}= \frac{1}{\frac{U_h}{K_h}\ln(U_{mid}/U_{inter})} where usually U_{mid} is the wind speed at (median) cumulated LAI between the top and the soil, and U_{inter} the wind speed at the height between the two canopy layers. In this function, U_{mid} and U_{inter} are computed relative to the leaf area instead of the height of the vegetation layers.

Return

g_af: The aerodynamic conductance of the air between two canopy layers (m s-1)

References

Van de Griend, A.A. and J.H. Van Boxel, Water and surface energy balance model with a multilayer canopy representation for remote sensing purposes. Water Resources Research, 1989. 25(5): p. 949-971.

See also

G_bulk and GetWind, which is used internaly.

Examples

# G_af for a coffee plantation managed in agroforestry system:
G_interlay(Wind = 3,ZHT = 25,Z_top = 2,LAI_top = 0.5,LAI_bot = 4)
source
DynACof.G_soilcanMethod

Canopy to soil aerodynamic conductance

Compute the aerodynamic conductance for sensible and latent heat between the center of the lowest canopy layer and the soil surface following Van de Griend and Van Boxel (1989).

Arguments

  • Wind::Float64: Average daily wind speed above canopy (m s-1)
  • LAI::Float64: Total leaf area index above the soil (m2 leaf m-2 soil).
  • ZHT::Float64: Wind measurement height (m)
  • Z_top::Float64: Average canopy height of the taller crop (m)
  • Z0::Float64: Roughness length (m). Default: 0.1*Z_top
  • ZPD::Float64: Zero-plane displacement (m), Default: 0.75*Z_top
  • α::Float64: Alpha, the constant for diffusivity at top canopy. Default: 1.5 following Van de Griend et al (1989).
  • ZW::Float64: Top height of the roughness sublayer (m). Default: ZPD + α ⋅ (Z_top - ZPD)
  • extwind::Float64: Extinction coefficient. Default: 0.0, no extinction.
  • vonkarman::Float64: Von Karman constant, default to constants().vonkarman, 0.41.
  • verbose::Bool: Print information of test_ZHT

All arguments are named.

Details

α can also be computed as: α=\frac{zw-d}{Z_{top}-d} The aerodynamic conductance between the lowest canopy layer and the soil is computed as: g_{a0}= \frac{1}{\frac{U_h}{K_h}\ln(U_{mid}/U_{0})} where U_{mid} is the wind speed at median cumulated LAI between the top and the soil, and U_0 the wind speed at soil surface.

Return

g_a0: The aerodynamic conductance of the air between the lowest canopy layer and the soil surface (m s-1)}

References

Van de Griend, A.A. and J.H. Van Boxel, Water and surface energy balance model with a multilayer canopy representation for remote sensing purposes. Water Resources Research, 1989. 25(5): p. 949-971.

See also

G_bulk and GetWind, which is used internaly.

Examples

# G_a0 for a coffee plantation managed in agroforestry system:
G_soilcan(Wind= 1.0, ZHT= 25.0, Z_top= 24.0,LAI= 4.5, extwind= 0.58)
source
DynACof.Gb_hMethod

Leaf boundary layer conductance for heat.

Compute the bulk leaf boundary layer conductance for heat using the wind speed, the leaf dimension, and leaf area distribution following Jones (1992).

Arguments

  • Wind::Float64: Average daily wind speed above canopy (m s-1)
  • wleaf::Float64: Average leaf width (m)
  • LAI_lay::Float64: Leaf area index of the layer (m2 leaves m-2 soil)
  • LAI_abv::Float64: Cumulated leaf area index above the layer (m2 leaves m-2 soil)
  • extwind::Float64: Extinction coefficient. Default: 0, no extinction.
  • Z_top::Float64: Average canopy height of the taller crop (m)
  • ZHT::Float64: Wind measurement height (m)
  • Z0::Float64: Roughness length (m). Default: 0.1 ⋅ Z_top
  • ZPD::Float64: Zero-plane displacement (m), Default: 0.75 ⋅ Z_top
  • α::Float64: Alpha, the constant for diffusivity at top canopy. Default: 1.5 following Van de Griend et al (1989).
  • ZW::Float64: Top height of the roughness sublayer (m). Default: ZPD + α ⋅ (Z_top - ZPD)

Details

The leaf boundary layer conductance for heat can be transformed into leaf boundary layer conductance for water vapour as follow: Gb_w= 1.075*gb_h Note that Gb_w should be doubled for amphistomatous plants (stomata on both sides of the leaves).

Return

Gb: The leaf boundary layer conductance for heat (m s-1)

References

  • Mahat, V., D.G. Tarboton, and N.P. Molotch, Testing above‐ and below‐canopy represetations of turbulent fluxes in an

energy balance snowmelt model. Water Resources Research, 2013. 49(2): p. 1107-1122.

See also

G_bulk, G_soilcan, G_interlay and GetWind, which is used internaly.

Examples

# Gb for a coffee plantation managed in agroforestry system:
Gb_h(Wind=3.0,wleaf=0.068,LAI_lay=4.0,LAI_abv=0.5,ZHT=25.0,Z_top=24.0,extwind=0.58)
source
DynACof.GetWindMethod

Get the average wind speed at center of canopy layer by computing the wind speed decrease in two steps:

  • Decrease the measured wind speed from measurement height until top of the canopy using the formula of

Van de Griend and Van Boxel (1989)

  • Decrease wind speed further with increasing canopy depth using an exponential extinction coefficient and a

cumulated LAI above the target point.

Arguments

  • Wind::Float64: Above canopy wind speed (m s-1)
  • LAI_lay::Float64: Leaf area index of the layer (m2 leaves m-2 soil)
  • LAI_abv::Float64: Cumulated leaf area index above the layer (m2 leaves m-2 soil)
  • extwind::Float64: Extinction coefficient. Default: 0, no extinction.
  • Z_top::Float64: Average canopy height of the taller crop (m)
  • ZHT::Float64: Wind measurement height (m)
  • Z0::Float64: Roughness length (m). Default: 0.1 ⋅ Z_top
  • ZPD::Float64: Zero-plane displacement (m), Default: 0.75 ⋅ Z_top
  • α::Float64: Alpha, the constant for diffusivity at top canopy. Default: 1.5 following Van de Griend et al (1989).
  • ZW::Float64: Top height of the roughness sublayer (m). Default: ZPD + α ⋅ (Z2 - ZPD)
  • vonkarman::Float64: Von Karman constant, default to constants().vonkarman, 0.41.
  • verbose::Bool: Print information of test_ZHT

Details

The function computes the average wind speed at the center of the canopy layer. It is considered that the leaf distibution is homogeneous in the layer, so the LAI_lay parameter is used to add half of the target layer to the cumulated LAI above: WindLay=Wh*e^{^{\left(-extwind*\left(LAI_{abv}+\frac{LAI_{lay}}{2}\right)\right)}} with Wh the wind speed at top of the canopy. Note: the α parameter can also be computed as: α=\frac{zw-d}{Z2-d}

Return

WindLay: The winspeed at the center of the layer (m s-1)

References

Van de Griend, A.A. and J.H. Van Boxel, Water and surface energy balance model with a multilayer canopy representation for remote sensing purposes. Water Resources Research, 1989. 25(5): p. 949-971.

Part of the code is taken from the MAESPA model.

Examples

# Windspeed in a coffee layer managed in agroforestry system
GetWind(Wind=3.0,LAI_lay=4.0,LAI_abv=0.3,extwind= 0.58,Z_top = 24.0,ZHT = 25.0)
source
DynACof.LE_to_ETFunction

Conversion between Latent Heat Flux and Evapotranspiration

Description

Converts evaporative water flux from mass (ET, evapotranspiration) to energy (LE, latent heat flux) units, or vice versa.

Arguments

  • LE::Float64: Latent heat flux (W m-2)
  • ET::Float64: Evapotranspiration (kg m-2 s-1)
  • Tair::Float64: Air temperature (deg C)

Details

The conversions are given by:

  • ET = LE/λ
  • LE = λ ⋅ ET

where λ is the latent heat of vaporization (J kg-1) as calculated by latent_heat_vaporization.

References

These functions are adapted from the code of bigleaf::LE.to.ET

Examples

# LE of 200 Wm-2 and air temperature of 25degC
LE_to_ET(200.0,25.0)
source
DynACof.PENMONMethod
PENMON(;Rn,Wind,Tair,ZHT,Z_top,Pressure,Gs,VPD,LAI,extwind=0,wleaf=0.068,Parameters= constants())

Evapotranspiration

Compute the daily evaporation or transpiration of the surface using the Penman-Monteith equation.

Arguments

  • Rn::Float64: Net radiation (MJ m-2 d-1)
  • Wind::Float64: Wind speed (m s-1)
  • Tair::Float64: Air temperature (Celsius degree)
  • ZHT::Float64: Wind measurement height (m)
  • Z_top::Float64: Canopy top height (m)
  • Pressure::Float64: Atmospheric pressure (hPa)
  • Gs::Float64: Stomatal conductance (mol m-2 s-1)
  • VPD::Float64: Vapor pressure deficit (kPa)
  • LAI::Float64: Leaf area index of the upper layer (m2 leaf m-2 soil)
  • extwind::Float64: Extinction coefficient. Default: 0, no extinction.
  • wleaf::Float64: Average leaf width (m)
  • Parameters: Constant parameters, default to constants, if different values are needed, simply make a named tuple with:
    • cp: specific heat of air for constant pressure (J K-1 kg-1)
    • Rgas: universal gas constant (J mol-1 K-1)
    • Kelvin: conversion degree Celsius to Kelvin
    • H2OMW: conversion from kg to mol for H2O (kg mol-1)
    • GBVGBH: conversion from water conductance to heat conductance

All arguments are named.

Details

The daily evapotranspiration is computed using the Penman-Monteith equation, and a set of conductances as : ET=\frac{Δ\cdot Rn\cdot10^6+ρ\cdot cp\cdot\frac{VPD}{10\ }\cdot GH}{\ Δ +\frac{\gamma}{λ\ }\cdot(1+\frac{GH}{GV})}\ } where Δ is the slope of the saturation vapor pressure curve (kPa K-1), ρ is the air density (kg m-3), GH the canopy boundary layer conductance (m s-1), γ the psychrometric constant (kPa K-1) and GV the boundary + stomatal conductance to water vapour (m s-1). To simulate evaporation, the input stomatal conductance Gs can be set to nearly infinite (e.g. Gs= 1\cdot e^9).

@note If wind=0, it is replaced by a low value of 0.01

Return

ET, the daily (evapo|transpi)ration (mm d-1)

References

Allen R.G., Pereira L.S., Raes D., Smith M., 1998: Crop evapotranspiration - Guidelines for computing crop water requirements - FAO Irrigation and drainage paper 56.

See also

bigleaf::potential.ET and the MAESPA model

Examples

# leaf evaporation of a forest :
PENMON(Rn= 12.0, Wind= 0.5, Tair= 16.0, ZHT= 26.0, Z_top= 25.0, Pressure= 900.0, Gs = 1E09, VPD= 2.41,
       LAI=3.0, extwind= 0.58, wleaf=0.068)
source
DynACof.Rad_extFunction
Rad_ext(1000.0, 25.0, 1.5)

Computes the virtual temperature, i.e. the temperature at which dry air would have the same density as moist air at its actual temperature.

Arguments

  • DOY::Int64: Ordinal date (integer): day of year from 1st January (day)
  • Latitude::Float64: Latitude (deg)
  • Gsc::Float64: The solar constant (W m-2), default to constants().Gsc (= 1367).

Returns

S0, the daily extra-terrestrial radiation ($MJ\ m^{-2}\ d^{-1}$)

References

Khorasanizadeh, H. and K. Mohammadi, Diffuse solar radiation on a horizontal surface: Reviewing and categorizing the empirical models. Renewable and Sustainable Energy Reviews,

  1. 53: p. 338-362.

Examples

# Daily extra-terrestrial radiation on january 1st at latitude 35 N :
Rad_ext(1,35.0)
source
DynACof.Rad_netFunction
Rad_net(DOY::Int64,RAD::Float64,Tmax::Float64,Tmin::Float64,VPD::Float64,Latitude::Float64,
 Elevation::Float64,albedo::Float64,formula::String;
 σ::Float64= constants().σ, Gsc::Float64= constants().Gsc)

Compute the daily net radiation of the system using incident radiation, air temperature, wind speed, relative humidity and the albedo. A clear description of this methodology can be found in Allen et al. (1998) or in An et al. (2017).

Arguments

  • DOY::Int64: Ordinal day, which is the day of year from 1st January (day)
  • RAD::Float64: Incident total radiation (MJ m-2 d-1)- Tmax::Float64: Maximum daily air temperature (°C)
  • Tmin::Float64: Minimum daily air temperature (°C)
  • VPD::Float64: Vapor pressure deficit (kPa)
  • Latitude::Float64: Latitude (°)
  • Elevation::Float64: Elevation (m)
  • albedo::Float64: Shortwave surface albedo (-)
  • formula::String: (optional) Formula to be used for the calculation of esat. One of "Sonntag_1990" (Default),

"Alduchov1996", or "Allen1998".

  • σ::Float64: (sigma) Stefan-Boltzmann constant ($W\ m^{-2} K^{-4}$), default to constants().σ.
  • Gsc::Float64: The solar constant (W m-2), default to constants().Gsc (= 1367).

Returns

Rn, the daily net radiation (MJ m-2 d-1)

Details

The daily net radiation is computed using the surface albedo. This method is only a simple estimation. Several parameters (ac, bc, a1 and b1) are taken from Evett et al. (2011). The net radiation is computed as: $Rn=(1-\alpha)\cdot RAD-(ac\cdot\frac{RAD}{Rso}+bc)\cdot(a1+b1\cdot ea^{0.5})\cdot\sigma\cdot\frac{T_{\max}^4+T_{\min}^4}{2}$ And is derived from the equation : $Rn= (1-\alpha)\cdot RAD-Rln$ where \eqn{Rln} is the net upward longwave radiation flux, \eqn{\alpha} is the albedo, \eqn{R{so}} the daily total clear sky solar irradiance, computed as follow: ``R{so}= (0.75+0.00002\cdot Elevation)\cdot R{sa}$where$R{sa}`is the daily extra-terrestrial radiation, computed using [Radext](@ref). The actual vapor pressureea` can be computed using either VPD or the relative humidity and the maximum and minimum daily temperature. If both are provided, Rh will be used.

References

An, N., S. Hemmati, and Y.-J. Cui, Assessment of the methods for determining net radiation at different time-scales of meteorological variables. Journal of Rock Mechanics and Geotechnical Engineering, 2017. 9(2): p. 239-246.

Examples

dew_point(20.0,1.0)
source
DynACof.Sucrose_cont_percMethod

Fruit sucrose accumulation

Computes a the sucrose accumulation into coffee fruits through time following a logistic curve

Arguments

  • x::Float64: Cumulated degree days
  • a::Float64: Parameter
  • b::Float64: Parameter
  • x0::Float64: Mid-maturation (logistic function inflexion point)
  • y0::Float64: Sucrose content at the beginning (in %, 1-100)

Return

The sucrose content, in % of fruit total dry mass.

References

Pezzopane, J., et al., Agrometeorological parameters for prediction of the maturation period of Arabica coffee cultivars. International Journal of Biometeorology, 2012. 56(5): p. 843-851.

Examples

Sucrose_cont_perc(1:10,5.3207,-28.5561,191,3.5)
source
DynACof.VPD_to_eFunction
VPD_to_e(1.5, 25.0, "Sonntag_1990")

Computes the vapor pressure (e) from the vapor pressure deficit (VPD) and the air temperature (Tair)

Arguments

  • VPD::Float64: Vapor pressure deficit (kPa)
  • Tair::Float64: Air temperature (°C)
  • formula::String: (optional) Formula to be used for the calculation of esat. One of "Sonntag_1990" (Default),

"Alduchov1996", or "Allen1998".

Returns

e, the vapor pressure (kPa)

Examples

VPD_to_e(1.5, 25.0, "Sonntag_1990")

Reference

This function is translated from the R package bigleaf.

source
DynACof.acos°Function

Trigonometric Functions (degree)

These functions give the obvious trigonometric functions. They respectively compute the cosine, sine, tangent, arc-cosine, arc-sine, arc-tangent with input and output in degree.

Returns

The output in degree

Details

The conversions between radian to degree is:

\[x \cdot \frac{pi,180}\]

Examples

# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
source
DynACof.air_densityFunction

Air Density (ρ)

Computes the air density of moist air from air temperature and pressure.

Arguments

  • Tair::Float64: Air temperature (deg C)
  • pressure::Float64: Atmospheric pressure (kPa)
  • Parameters: Constant parameters, default to constants, if different values are needed, simply make a named tuple with:
    • Kelvin: conversion degC to Kelvin
    • Rd: gas constant of dry air (J kg-1 K-1)

Details

Air density (ρ) is calculated as: ρ = pressure / (Rd * Tair)

Return

ρ: the air density (kg m-3)

References

This function is adapted from the code of bigleaf::air.density

  • Foken, T, 2008: Micrometeorology. Springer, Berlin, Germany.

Examples

# air density at 25degC and standard pressure (101.325kPa)
air_density(25.0,101.325)
source
DynACof.asin°Function

Trigonometric Functions (degree)

These functions give the obvious trigonometric functions. They respectively compute the cosine, sine, tangent, arc-cosine, arc-sine, arc-tangent with input and output in degree.

Returns

The output in degree

Details

The conversions between radian to degree is:

\[x \cdot \frac{pi,180}\]

Examples

# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
source
DynACof.atan°Function

Trigonometric Functions (degree)

These functions give the obvious trigonometric functions. They respectively compute the cosine, sine, tangent, arc-cosine, arc-sine, arc-tangent with input and output in degree.

Returns

The output in degree

Details

The conversions between radian to degree is:

\[x \cdot \frac{pi,180}\]

Examples

# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
source
DynACof.balance_model!Method

Energy balance

Computes the different components of the energy balance considering the shade tree, the coffee and the soil.

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

source
DynACof.bud_init_period!Method

Bud induction window computation

Bud induction can start only at FTffb degree-days after vegetative growth stops (Rodriguez et al., 2011). The following function finds the vegetative growth end day, and add the FTffb parameter (Time of first floral buds, in dd), then find the very first flowering of the year and set the vector BudInitPeriod to TRUE between the two dates. So buds will appear between plant F_Tffb parameter and the first flowering day only.

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

References

Rodríguez, D., Cure, J., Cotes, J., Gutierrez, A. and Cantor, F., 2011. A coffee agroecosystem model: I. Growth and development of the coffee plant. Ecological Modelling, 222(19): 3626-3639.

source
DynACof.coffee_model!Function

Coffee crop model

Computes the coffee crop growth and yield. This function is called from dynacof and should not be called by the user.

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

source
DynACof.cos°Function

Trigonometric Functions (degree)

These functions give the obvious trigonometric functions. They respectively compute the cosine, sine, tangent, arc-cosine, arc-sine, arc-tangent with input and output in degree.

Returns

The output in degree

Details

The conversions between radian to degree is:

\[x \cdot \frac{pi,180}\]

Examples

# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
source
DynACof.days_without_rainMethod
days_without_rain(Rain::Array{Float64,1})

Computes the number of days without rain from a rainfall data Array. It is assumed the Array is sorted following ascending dates.

Arguments

  • Rain::Array{Float64,1}: An Array of daily rainfall data (whatever the unit) in ascending day order.

Returns

An Array{Int64,1} determining how many days there was without rainfall before the given day.

Examples

rainfall= [0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.2,0.6]
days_without_rain(rainfall)
source
DynACof.dew_pointFunction
dew_point(Tair::Float64, VPD::Float64, formula::String="Sonntag_1990")

Computes the dew point, i.e. the temperature to which air must be cooled to become saturated

Arguments

  • Tair::Float64: Air temperature (°C)
  • VPD::Float64: Vapor pressure deficit (kPa)
  • formula::String: (optional) Formula to be used for the calculation of esat. One of "Sonntag_1990" (Default),

"Alduchov1996", or "Allen1998".

Returns

T_d, the dew point (°C)

Examples

dew_point(20.0,1.0)
source
DynACof.diffuse_fractionFunction
diffuse_fraction(DOY::Int64, RAD::Float64, Latitude::Float64; formula::String="Spitters",Gsc::Float64=constants().Gsc)

Computes the daily diffuse fraction from the total daily incident radiation

Arguments

  • DOY::Int64: Day Of Year from 1st January (day)
  • RAD::Float64: Incident total radiation (MJ m-2 d-1)
  • Latitude::Float64: Latitude (deg)
  • formula::String: (Optionnal) Model type, one of Spitters, Page or Gopinathan
  • Gsc::Float64: (Optionnal) The solar constant (W m-2), default to constants().Gsc (= 1367).

Details

The daily extra-terrestrial radiation at a plane parallel to the earth surface (S0 or H0 depending on the source) is computed following Khorasanizadeh and Mohammadi (2016). The daily diffuse fraction is computed following DB models from :

  • Spitters et al. (1986): used in de Bilt in Netherlands, stated that their model is

valid for a wide range of climate conditions

  • Page (1967) using the data from 10 widely-spread sites in the 40N to 40S latitude belt
  • Gopinathan and Soler (1995) from 40 widely distributed locations in the latitude range of 36S to 60N.

Note

C_to_K and epsi can be found using constants()

Returns

$Hd/H$: the daily diffuse fraction of light (%)

References

  • Duffie, J.A. and W.A. Beckman, Solar engineering of thermal processes. 2013: John Wiley & Sons.

Gopinathan, K. and A. Soler, Diffuse radiation models and monthly-average, daily, diffuse data for a wide latitude range. Energy, 1995. 20(7): p. 657-667.

  • Kalogirou, S.A., Solar energy engineering: processes and systems. 2013: Academic Press.

Khorasanizadeh, H. and K. Mohammadi, Diffuse solar radiation on a horizontal surface: Reviewing and categorizing the empirical models. Renewable and Sustainable Energy Reviews,

  1. 53: p. 338-362.
  • Liu, B.Y.H. and R.C. Jordan, The interrelationship and characteristic distribution of direct,

diffuse and total solar radiation. Solar Energy, 1960. 4(3): p. 1-19.

  • Page, J. The estimation of monthly mean values of daily total short wave radiation on vertical

and inclined surfaces from sunshine records 40S-40N. in Proceedings of the United Nations Conference on New Sources of Energy: Solar Energy, Wind Power and Geothermal Energy, Rome, Italy. 1967.

  • Spitters, C.J.T., H.A.J.M. Toussaint, and J. Goudriaan, Separating the diffuse and direct

component of global radiation and its implications for modeling canopy photosynthesis Part I. Components of incoming radiation. Agricultural and Forest Meteorology, 1986. 38(1): p. 217-229.

Examples

# Daily diffuse fraction of january 1st at latitude 35 N, with a RAD of 25 MJ m-2 day-1 :
diffuse_fraction(1,25.0,35.0)
source
DynACof.dynacofMethod
dynacof(;period::Array{String,1}= ["0000-01-01", "0000-01-02"], input_path="package",
         file_name= (constants= "constants.jl",site="site.jl",meteo="meteorology.txt",soil="soil.jl",coffee="coffee.jl",tree="tree.jl")

Dynamic Agroforestry Coffee Crop Model

The DynACof process-based model computes plot-scale Net Primary Productivity, carbon allocation, growth, yield, energy, and water balance of coffee plantations according to management, while accounting for spatial effects using metamodels from the 3D process-based model MAESPA. The model also uses cohorts for the development of the coffee buds and fruits to better represent fruit carbon demand distribution along the year.

Arguments

  • period::Array{String,1}: A vector of two character string as POSIX dates that correspond to the min and max dates for the desired time

period to be returned. The default value ["0000-01-01", "0000-01-02"] makes the function take the min and max values from the meteorology file.

  • input_path::String: Path to the input parameter list folder. Default to "package", wich makes DynACof use the package default parameter values.

  • file_name::NamedTuple{(:constants, :site, :meteo, :soil, :coffee, :tree),NTuple{6,String}}: A list of input file names :

    • constants: Physical constants file. Default: "constants.jl". More info in the corresponding structure: constants.
    • site: Site parameters file name, see details. Default: "site.jl". More info in the corresponding structure: site
    • meteo: Meteorology file name, see details section. Default: "meteorology.txt". More info in the meteorology reading function meteorology.
    • Soil: Soil parameters file name, see details. Default: "soil.jl". More info in the corresponding structure: soil.
    • Coffee: Coffee parameters file name, see details. Default: "coffee.jl". More info in the corresponding structure: coffee.
    • Tree: Shade tree parameters file name, see details. Default: "tree.jl". More info in the corresponding structure: tree.

Default input files are provided with the package as an example parameterization. To use the default parameters, you can either set inputpath="package" for using all defaults, or set the desired default file to "package" in `filename, *e.g.* to use the default constants, but user-defined other parameters:file_name= (constants= "package",site="site.jl",meteo="meteorology.txt",soil="soil.jl",coffee="coffee.jl",tree="tree.jl")`

Return

Return a three objects Sim, Meteo and Parameters. To get the objects from a dynacof call: Sim, Meteo, Parameters= dynacof(...)

  • Sim: A data.frame of the simulation outputs at daily time-step:
TypeVarunitDefinition
GeneralCycle-Plantation cycle ID
datePosix date (Y-m-d)Simulation date
yearYearSimulation year
Plot_AgeyearPlantation age (starting at 1)
PlotAgenumyear (numeric)Numeric age of plantation
LAIplotm2 leaves m-2 soilPlot (Coffee + Shade Tree if any) Leaf Area Index
Suffixes for Coffee organsx_RE-Reserves
x_SCR-Stump and Coarse roots
x_Fruit-Fruit
x_Shoot-Resprout wood (= branches)
x_FRoot-Fine roots
x_LeafLeaves
Suffixes for Shade Tree org.xRETree-Reserves
xStemTree-Stem (= trunk)
xBranchTree-Branches
xCoarseRootTree-Coarse roots
xFRootTree-Fine roots
xLeafTreeLeaves
EnergyRn_totMJ m-2 d-1System net radiation
Rn_TreeMJ m-2 d-1Shade tree net radiation
Rn_CoffeeMJ m-2 d-1Coffee net radiation
Rn_SoilMJ m-2 d-1Soil net radiation
RnSoilSWMJ m-2 d-1Soil net radiation computed using Shuttleworth & Wallace (1985) for reference
LE_xMJ m-2 d-1System / Coffee / Tree / Soil latent heat
H_xMJ m-2 d-1System / Coffee / Tree / Soil sensible heat
Q_SoilMJ m-2 d-1Soil heat transport
Transmittance_TreefractionFraction of light transmitted by the shade trees
PARTransTreeMJ m-2 d-1Light transmitted by the shade trees canopy
PAR_TransMJ m-2 d-1Light transmitted by the Coffea canopy
K_Dir-Direct light extinction coefficient
K_Dif-Diffuse light extinction coefficient
APARMJ m-2 d-1Absorbed PAR by the plant
APAR_DifMJ m-2 d-1Absorbed diffuse PAR (Direct is APAR-APAR_Dif)
luegC MJLight use efficiency
Tleaf_Coffeedeg CCoffee canopy temperature computed by DynACof
TairCanopy_xdeg CAir tempetature at the center of the layer
Gbhxm s-1Coffee / Tree conductance to heat
Gbaircanopym s-1Bulk (no tree) or canopy layer to canopy layer aerodynamic conductance
airdensityxkg m-3Air density inside the canopy of the tree or the coffee (see air_density)
WindSpeed_xm s-1Wind speed at the center of the layer
DegreeDays_Tcandeg CGrowing degree days computed using Coffee Canopy Temperature
CarbonGPPgC m-2 d-1Gross primary productivity
Consumption_REgC m-2 d-1Daily reserve consumption
CarbonLackMortalitygC m-2 d-1Mortality from a higher carbon consumption than Supply
RmgC m-2 d-1Total Coffee maintenance respiration
Rm_xgC m-2 d-1Maintenance respiration at organ scale
RggC m-2 d-1Total Coffee growth respiration
Rg_xgC m-2 d-1Growth respiration at organ scale
RagC m-2 d-1Coffee layer autotrophic respiration (=Rm+Rg)
Demand_xgC m-2 d-1C demand at organ scale (fruit, leaf and fine root only)
Alloc_xgC m-2 d-1C allocation to organ net of Rm (NPP+Rg)
SupplygC m-2 d-1C supply at the begining of the day at layer scale (GPP+Reserve consumption-Rm)
Supply_xgC m-2 d-1C supply to organ, net of Rm
NPPgC m-2 d-1Net primary productivity at layer scale
NPP_xgC m-2 d-1Net primary productivity at organ scale
Mnat_xgC m-2 d-1Organ natural mortality (= due to lifespan)
Mprun_xgC m-2 d-1Organ mortality due to pruning
M_ALSgC m-2 d-1Coffee leaf mortality from American Leaf Spot
Mortality_xgC m-2 d-1Total organ mortality
LAIm2 leaves m-2 soilLeaf Area Index
CM_xgC m-2 d-1Organ C mass
DM_xgDM m-2 d-1Organ dry mass
Fruit developmentBudInitPeriodbooleanBud initiation period (BIP)
BudinitBuds d-1Total Number of Buds Initiated per day
ratioNodestoLAINodes LAI-1Number of fruiting nodes per LAI unit
TempcorBudfractionTemperature correction factor for bud development
pbreak0-1Daily probability of bud dormancy break
BudBreakBuds d-1Total number of buds breaking dormancy per day
SMg m-2 d-1Coffee Fruit Sucrose Mass
SCg Sugar gDMCoffee Fruit Sucrose Content
Maturation_durationdays Fruit cohort-1Coffee Fruit Total Maturation Duration for each cohort
HarvestMaturityPotFractionDaily average fruit maturity (0-1)
Date_harvestday of yeardate of harvest
Harvest_FruitgC m-2Total fruit carbon mass at harvest
Yield_greenkg ha-1Yield of green coffee bean
Harvest_MaturityFractionAverage fruit maturity at harvest (0-1)
Overriped_FruitgC m-2 d-1Overriped fruits that fall onto the ground
WaterIntercMaxmmMaximum potential rainfall interception by canopy
CanopyHumectmmRainfall interception by canopy
ThroughfallmmRainfall not intercepted by the canopy, coming to the soil
SuperficialRunoffmmWater runoff from the superficial soil layer
ExcessRunoffmmDischarge from the superficial soil layer
TotSuperficialRunoffmmSum of discharge+ExcessRunoff
InfilCapammSuperficial water infiltration capacity to first layer of soil
InfiltrationmmSuperficial water infiltration to first layer of soil
Drain_[1-3]mmWater drainage from soil layer 1, 2 or 3
WSurfaceResmmSoil water content from the surface layer
W_totmmTotal soil profile water content
W_[1-3]mmSoil water content from the layer 1, 2 or 3
REW_tot-Relative extractable water from the soil
REW_[1-3]-Relative extractable water from the layer 1, 2 or 3
EW_totmmExtractable water from the soil
EW_[1-3]mmExtractable water from the layer 1, 2 or 3
SWDmmsoil water deficit
RootWaterExtract_[1-3]mmRoot water extraction for soil layer 1 to 3
IntercRevapormmEvaporation by canopy
T_xmmTranspiration at system / Coffee / Tree scale
E_SoilmmSoil evaporation
ETRmmSystem evapotranspiration
SoilWaterPotMPaSoil water potential
PSIL_*MpaCoffee leaf water potential
Special shade tree variablesLA_Treem2 leaves tree-1shade tree leaf area
CrownHTreemCrown height
TrunkHTreemTrunk height
Height_TreemShade tree total height (used for boundary conductance), set to 0 if no shade trees
DBH_TreemDiameter at breast height
LAD_Treem2 m-3Shade tree Leaf Area Density
CrownRad_TreemCrown radius
CrownProj_Treem2 crown tree-1Crown projection
Stocking_Treetree m-2Shade tree density
TimetoThin_TreebooleanDays on which tree is thinned
MThinningxTreegc m-2 d-1Mortality due to thining at organ scale
  • Meteo: A data.frame of the input meteorology, potentially coming from the output of [Meteorology()]:
VarunitDefinitionIf missing
DatePOSIXctDate in POSIXct formatComputed from start date parameter, or set a dummy date if missing
yearyearYear of the simulationComputed from Date
DOYdayday of the yearComputed from Date
RainmmRainfallAssume no rain
TairCelsiusAir temperature (above canopy)Computed from Tmax and Tmin
TmaxCelsiusMaximum air temperature during the dayRequired (error)
TminCelsiusMinimum air temperature during the dayRequired (error)
RH%Relative humidityNot used, but prefered over VPD for Rn computation
RADMJ m-2 d-1Incident shortwave radiationComputed from PAR
PressurehPaAtmospheric pressureComputed from VPD, Tair and Elevation, or alternatively from Tair and Elevation.
WindSpeedm s-1Wind speedTaken as constant: Parameters -> WindSpeed
CO2ppmAtmospheric CO2 concentrationTaken as constant: Parameters -> CO2
DegreeDaysCelsiusGrowing degree daysComputed using GDD
PARMJ m-2 d-1Incident photosynthetically active radiationComputed from RAD
FDiffFractionDiffuse light fractionComputed using diffuse_fraction using Spitters et al. (1986) formula
VPDhPaVapor pressure deficitComputed from RH
RnMJ m-2 d-1Net radiation (will be depreciated)Computed using Rad_net with RH, or VPD
DaysWithoutRaindayNumber of consecutive days with no rainfallComputed from Rain
Air_Densitykg m-3Air density of moist air (ρ) above canopyComputed using air_density
ZENradianSolar zenithal angle at noonComputed from Date, Latitude, Longitude and Timezone

Details

Almost all variables for coffee exist also for shade trees with the suffix _Tree after the name of the variable, e.g.: LAI = coffee LAI, LAITree = shade tree LAI. Special shade tree variables (see return section) are only optional, and there may have more variables upon parameterization because variables can be added in the parameter file for metamodelstree or Allometries for example.

Note

For simulations with custom initialisations (e.g. at age > 0), or running a simulation day by day, see dynacof_i!.

Examples

# A simulation with the default parameter files from the package, and an example meteorology file from the `DynACof.jl_inputs` repository:
file= download("https://raw.githubusercontent.com/VEZY/DynACof.jl_inputs/master/meteorology.txt")
Sim, Meteo, Parameters= dynacof(input_path= dirname(file), file_name= (constants= "package",site="package",meteo=basename(file),soil="package",
coffee="package",tree="package"))
rm(file)
source
DynACof.dynacof_i!Function
dynacof_i!(i,Sim::DataFrame,Met_c::DataFrame,Parameters)

Using DynACof one iteration after another. Allows to run a DynACof simulation with starting at age > 0 with initializations.

Arguments

  • i: Either an integer, or a range giving the day of simulation needed. Match the row index, so i=366 make a simulation

for the 366th row of Sim and Met.

Examples


# Making a regular simulation using example data:
file= download("https://raw.githubusercontent.com/VEZY/DynACof.jl_inputs/master/meteorology.txt")

# Initialize the simulation:
Sim, Meteo, Parameters= dynacof_i_init(1:365,input_path= dirname(file), file_name= (constants= "package",site="package",meteo=basename(file),soil="package",coffee="package",tree="package"))
rm(file)

Sim2= copy(Sim)
Meteo2= copy(Meteo)
# Changing the value of Tair in the meteorology for day 366 for S2:
Meteo2.Tair[366]= Meteo2.Tair[366]+10.0

# Make a computation for each:
dynacof_i!(366,Sim,Meteo,Parameters)
dynacof_i!(366,Sim2,Meteo2,Parameters)

# Compare the values of e.g. the maitenance respiration:
Sim.Rm[366]
Sim2.Rm[366]

# To run DynACof for several days, use a range for i:
S= dynacof_i(367:size(Meteo,1),Sim,Meteo,Parameters)
# NB: size(Meteo,1) or size(Sim,1) is the maximum length we can simulate. To increase a simulation,
# initialize it with a wider range for the "Period" argument (see [`dynacof_i_init`](@ref)).
source
DynACof.dynacof_i_initMethod
dynacof_i_init(i,Sim::DataFrame,Met_c::DataFrame,Parameters)

Initialize a DynACof simulation to be used in dynacof_i.

Arguments

  • i: A range giving the days that will be simulated for initialization. Should be >= 365 days.

Arguments

  • period::Array{String,1}: A vector of two character string as POSIX dates corresponding to the min and max dates for the whole simulation (used

to pre-allocate the simulation Data.Frame). It is not the days that will be simulated during initialization, but the whole range possible for simulation afterwards. The default value ["0000-01-01", "0000-01-02"] makes the function take the min and max values from the meteorology file.

  • input_path::String: Path to the input parameter list folder. Default to "package", wich makes DynACof use the package default parameter values.

  • file_name::NamedTuple{(:constants, :site, :meteo, :soil, :coffee, :tree),NTuple{6,String}}: A list of input file names :

    • constants: Physical constants file. Default: "constants.jl". More info in the corresponding structure: constants.
    • site: Site parameters file name, see details. Default: "site.jl". More info in the corresponding structure: site
    • meteo: Meteorology file name, see details section. Default: "meteorology.txt". More info in the meteorology reading function meteorology.
    • Soil: Soil parameters file name, see details. Default: "soil.jl". More info in the corresponding structure: soil.
    • Coffee: Coffee parameters file name, see details. Default: "coffee.jl". More info in the corresponding structure: coffee.
    • Tree: Shade tree parameters file name, see details. Default: "tree.jl". More info in the corresponding structure: tree.

Default input files are provided with the package as an example parameterization. To use the default parameters, you can either set inputpath="package" for using all defaults, or set the desired default file to "package" in `filename, *e.g.* to use the default constants, but user-defined other parameters:file_name= (constants= "package",site="site.jl",meteo="meteorology.txt",soil="soil.jl",coffee="coffee.jl",tree="tree.jl")`

Return

Return three objects: Sim, Meteo and Parameters. To get the objects from the call: Sim, Meteo, Parameters= dynacof_i_init(...). See dynacof for more details.

Examples


# Making a regular simulation using example data:
file= download("https://raw.githubusercontent.com/VEZY/DynACof.jl_inputs/master/meteorology.txt")
Sim, Meteo, Parameters= dynacof_i_init(1:365,input_path= dirname(file), file_name= (constants= "package",site="package",meteo=basename(file),soil="package",coffee="package",tree="package"))
rm(file)
source
DynACof.energy_model_coffee!Function

Energy fluxes models

Computes the energy-related variables such as H, LE, Tleaf for the shade tree or the coffee.

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

source
DynACof.energy_model_tree!Function

Energy fluxes models

Computes the energy-related variables such as H, LE, Tleaf for the shade tree or the coffee.

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

source
DynACof.energy_water_models!Method

Energy and water models

Computes the energy and water related variables for the shade tree (if any), the coffee and the soil. Call different sub-models:

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

source
DynACof.esatFunction
esat(20.0,"Sonntag_1990")

Computes the saturation vapor pressure (Esat)

Arguments

  • Tair::Float64: Air temperature (°C)
  • formula::String: (optional) Formula to be used for the calculation of esat and the slope of esat. One of "Sonntag_1990" (Default),

"Alduchov1996", or "Allen1998".

Returns

Esat, the saturation vapor pressure (kPa)

Examples

esat(20.0,"Allen_1998")

Reference

This function is translated from the R package bigleaf.

source
DynACof.esat_slopeFunction
esat_slope(20,"Allen_1998")

Computes Δ, the slope of the saturation vapor pressure at given air temperature.

Arguments

  • Tair::Float64: Air temperature (°C)
  • formula::String: (optional) Formula to be used for the calculation of esat and the slope of esat. One of "Sonntag_1990" (Default),

"Alduchov1996", or "Allen1998".

Returns

Δ, the slope of the saturation vapor pressure curve at Tair ($kPa\ K^{-1}$)

Examples

esat_slope(20.0,"Allen_1998")

Reference

This function is translated from the R package bigleaf.

source
DynACof.import_parametersFunction

import_parameters(path::String,Names)

Import the model parameters from local files, or from default values in the parameter structures:

  • constants
  • site
  • soil
  • coffee
  • tree (for a simulation of a monocrop coffee plantation, use an empty string for the tree, see example)

Arguments

  • path::String: The path to the parameter files folder. If path= "package", take the default files from the package
  • Names::NamedTuple{(:constants, :site, :meteo, :soil, :coffee, :tree),NTuple{6,String}}: list the file names.

Details

For the full list of parameters and the format of the parameter files, see site.

Return

A list of all input parameters for DynACof

Examples

# Default from package:
import_parameters("package")

# Reading it from local files:
import_parameters("D:/parameter_files",(constants= "constants.jl",site="site.jl",meteo="meteorology.txt",soil="soil.jl",coffee="coffee.jl",tree="tree.jl"))

# For a coffee monocrop (without shade trees)
import_parameters("D:/parameter_files",(constants= "constants.jl",site="site.jl",meteo="meteorology.txt",soil="soil.jl",coffee="coffee.jl",tree=""))
source
DynACof.initialise!Method

Initialise model variables.

Arguments

  • Sim::DataFrame: The simulation DataFrame
  • Met_c::DataFrame: The meteorology DataFrame
  • Parameters: The parameters for the model
source
DynACof.is_missingMethod
is_missing(MetData, "Date")

Find if a column is missing from a DataFrame.

Arguments

  • data::DataFrame: a DataFrame
  • key::String: a column name

Return

A boolean: true if the column is missing, false if it is present.

Examples

df= DataFrame(A = 1:10)
is_missing(df,"A")
false
is_missing(df,"B")
true
source
DynACof.is_missingMethod
is_missing(data::NamedTuple,key::String)

Find if a key is missing from a tuple.

Arguments

  • data::NamedTuple: a named tuple
  • key::String: a key (parameter) name

Return

A boolean: true if the key is missing, false if it is present.

Examples

Parameters= Dict("Stocking_Coffee"=> 5580)
is_missing(Parameters,"Stocking_Coffee")
false
is_missing(Parameters,"B")
true
source
DynACof.latent_heat_vaporizationFunction

Latent Heat of Vaporization

Computes the latent heat of vaporization as a function of air temperature.

Arguments

  • Tair::Float64: Air temperature (deg C)

Details

The following formula is used: λ = (2.501 - 0.00237*Tair) * 10^6

Return

λ - The latent heat of vaporization (J kg-1)

References

This function is adapted from the code of bigleaf::latent.heat.vaporization

  • Stull, B., 1988: An Introduction to Boundary Layer Meteorology (p.641) Kluwer Academic Publishers, Dordrecht, Netherlands
  • Foken, T, 2008: Micrometeorology. Springer, Berlin, Germany.

Examples

latent_heat_vaporization(20.0)  
source
DynACof.light_model_coffee!Function

Light interception models

Computes the light interception (and transmission) for the shade tree or the coffee.

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

source
DynACof.light_model_tree!Function

Light interception models

Computes the light interception (and transmission) for the shade tree or the coffee.

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

source
DynACof.logisticFunction

Compute a logistic function or its derivative

Arguments

  • x::Float: The x value
  • u_log::Float64: Inflexion point (x-value of the sigmoid's midpoint)
  • s_log::Float64: Steepness of the curve

Return

  • logistic: the logistic function
  • logistic_deriv: the derivative of the logistic function

Seealso

More informations can be found in the wikipedia page

Examples

logistic(1:10,5,0.1)
logistic_deriv(1:10,5,0.1)
source
DynACof.logistic_derivFunction

Compute a logistic function or its derivative

Arguments

  • x::Float: The x value
  • u_log::Float64: Inflexion point (x-value of the sigmoid's midpoint)
  • s_log::Float64: Steepness of the curve

Return

  • logistic: the logistic function
  • logistic_deriv: the derivative of the logistic function

Seealso

More informations can be found in the wikipedia page

Examples

logistic(1:10,5,0.1)
logistic_deriv(1:10,5,0.1)
source
DynACof.meteorologyFunction

Meteorology(file = NULL, period = NULL, Parameters = Import_Parameters())

Import the meteorology data, check its format, and eventually compute missing variables.

Arguments

  • file::String: The daily time-step meteorology file path.
  • period::Array{String,1}: A vector of two character string as POSIX dates that correspond to the min and max dates for the desired time period to be returned.

The default value ["0000-01-01", "0000-01-02"] makes the function take the min and max values from the meteorology file.

  • Parameters: A named tuple with parameter values (see import_parameters):
    • Start_Date: optional, the Posixct date of the first meteo file record. Only needed if the Date column is missing.
    • FPAR : Fraction of global radiation corresponding to PAR radiation, only needed if either RAD or PAR is missing.
    • Elevation : elevation of the site (m), only needed if atmospheric pressure is missing
    • Latitude : latitude of the site (degree), only needed if the diffuse fraction of light is missing
    • WindSpeed : constant wind speed (m s-1), only needed if windspeed is missing
    • CO2 : constant atmospheric $CO_2$ concentration (ppm), only needed if $CO_2$ is missing
    • MinTT : minimum temperature threshold for degree days computing (Celsius), see [GDD()]
    • albedo : site shortwave surface albedo, only needed if net radiation is missing, see [Rad_net()]

Details

The imported file is expected to be at daily time-step. The albedo is used to compute the system net radiation that is then used to compute the soil net radiation using an extinction coefficient with the plot LAI following the Shuttleworth & Wallace (1985) formulation. This computation is likely to be depreciated in the near future as the computation has been replaced by a metamodel. It is kept for information for the moment.

VarunitDefinitionIf missing
DatePOSIXctDate in POSIXct formatComputed from start date parameter, or set a dummy date if missing
yearyearYear of the simulationComputed from Date
DOYdayday of the yearComputed from Date
RainmmRainfallAssume no rain
TairCelsiusAir temperature (above canopy)Computed from Tmax and Tmin
TmaxCelsiusMaximum air temperature during the dayRequired (error)
TminCelsiusMinimum air temperature during the dayRequired (error)
RH%Relative humidityNot used, but prefered over VPD for Rn computation
RADMJ m-2 d-1Incident shortwave radiationComputed from PAR
PressurehPaAtmospheric pressureComputed from VPD, Tair and Elevation, or alternatively from Tair and Elevation.
WindSpeedm s-1Wind speedTaken as constant: Parameters -> WindSpeed
CO2ppmAtmospheric CO2 concentrationTaken as constant: Parameters -> CO2
DegreeDaysCelsiusGrowing degree daysComputed using GDD
PARMJ m-2 d-1Incident photosynthetically active radiationComputed from RAD
FDiffFractionDiffuse light fractionComputed using diffuse_fraction using Spitters et al. (1986) formula
VPDhPaVapor pressure deficitComputed from RH
RnMJ m-2 d-1Net radiation (will be depreciated)Computed using Rad_net with RH, or VPD
DaysWithoutRaindayNumber of consecutive days with no rainfallComputed from Rain
Air_Densitykg m-3Air density of moist air (ρ) above canopyComputed using air_density
ZENradianSolar zenithal angle at noonComputed from Date, Latitude, Longitude and Timezone

Returns

A daily meteorology DataFrame.

See also: dynacof

Examples

# Using the example meteorology from the `DynACof.jl_inputs` repository:
file= download("https://raw.githubusercontent.com/VEZY/DynACof.jl_inputs/master/meteorology.txt")
Meteo= meteorology(file,import_parameters())
# NB: `import_parameters` without arguments uses the package default values
rm(file)
source
DynACof.paliv_disMethod
paliv_dis(Age_Max::Int64,P_Start::Float64,P_End::Float64,k::Float64)

Distributes the percentage of living tissue alonf the lifespan

Arguments

  • Age_Max::Int64: Maximum age of the organ (year)
  • P_Start::Float64: Percentage of living tissue at first age (% of dry mass)
  • P_End::Float64: Percentage of living tissue at last age (% of dry mass)
  • k::Float64: Rate between PStart and PEnd

The percentage of living tissue is computed as follows: $P_{End}+\left((P_{Start}-P_{End})\cdot e^{seq(0,-k,length.out=Age_{Max})}\right)$

Return

The living tissue at each age in % of organ dry mass in the form of a DataFrame

Examples

paliv_dis(40,0.4,0.05,5.0)

40×2 DataFrame
│ Row │ Age   │ Palive          │
│     │ Int64 │ Float64         │
├─────┼───────┼─────────────────┤
│ 1   │ 1     │ 0.4             │
│ 2   │ 2     │ 0.357886        │
│ 3   │ 3     │ 0.320839        │
│ 4   │ 4     │ 0.288249        │
⋮
│ 36  │ 36    │ 0.0539383       │
│ 37  │ 37    │ 0.0534644       │
│ 38  │ 38    │ 0.0530476       │
│ 39  │ 39    │ 0.0526809       │
│ 40  │ 40    │ 0.0523583       │
source
DynACof.pressure_from_elevationMethod
pressure_from_elevation(1000.0, 25.0, 1.5)

Computes the virtual temperature, i.e. the temperature at which dry air would have the same density as moist air at its actual temperature.

Arguments

  • Tair::Float64: Air temperature (°C)
  • pressure::Float64: Atmospheric pressure (kPa)
  • VPD::Float64: Vapor pressure deficit (kPa)
  • formula::String: (optional) Formula to be used for the calculation of esat. One of "Sonntag_1990" (Default),

"Alduchov1996", or "Allen1998".

  • C_to_K::Float64: Celsius degree to Kelvin (e.g. 273.15)
  • pressure0::Float64: reference atmospheric pressure at sea level (kPa)
  • Rd::Float64: gas constant of dry air ($J\ kg^{-1}\ K^{-1}$), source : Foken p. 245
  • g::Float64: gravitational acceleration ($m\ s^{-2}$)

Note

C_to_K and epsi can be found using constants()

Returns

The atmospheric pressure (kPa)

Examples

pressure_from_elevation(600.0, 25.0, 1.5)
source
DynACof.previous_iFunction

Find the ith previous index, avoiding 0 or negative indexes.

Arguments

  • i::DataType: Current index
  • n: Target number of indexes before x

Details

This function is used to find the nth previous index without making an error with negative or 0 index.

Examples

# Find the 10th index before 15:
previous_i(15,10)
5
# Find the 10th index before 5:
previous_i(5,10)
1
source
DynACof.psychrometric_constantFunction

Psychrometric constant (γ)

Arguments

  • Tair::Float64: Air temperature (deg C)
  • pressure::Float64: Atmospheric pressure (kPa)
  • Parameters: Constant parameters, default to constants, if different values are needed, simply make a named tuple with:
    • cp: specific heat of air for constant pressure (J K-1 kg-1)
    • epsi: ratio of the molecular weight of water vapor to dry air (-)

Details

The psychrometric constant (γ) is given as: γ = cp * pressure / (epsi * λ) where λ is the latent heat of vaporization (J kg-1), as calculated from latent_heat_vaporization.

Return

γ - the psychrometric constant (kPa K-1)

References

This function is adapted from the code of bigleaf::psychrometric.constant

  • Monteith J.L., Unsworth M.H., 2008: Principles of Environmental Physics. 3rd Edition. Academic Press, London.

Examples

psychrometric_constant(20.0, 100.0)  
source
DynACof.rH_to_VPDFunction
rH_to_VPD(0.5,20,"Allen_1998")

Conversion from relative humidity (rH) to vapor pressure deficit (VPD).

Arguments

  • rH::Float64: Relative humidity (-)
  • Tair::Float64: Air temperature (°C)
  • formula::String: (optional) Formula to be used for the calculation of esat and the slope of esat. One of "Sonntag_1990" (Default),

"Alduchov1996", or "Allen1998".

Returns

VPD, the vapor pressure deficit (kPa)

Examples

rH_to_VPD(0.5,20.0,"Allen_1998")

Reference

This function is translated from the R package bigleaf.

source
DynACof.read_param_fileFunction

readparamfile(structure::Symbol,filepath::String="package")

Read DynACof parameter files and create the structure according to its structure. If parameters are missing from the file, the structure is filled with the default values.

Arguments

  • structure::Int64: The structure type. Must be one of constants, site, soil, coffee, tree
  • filepath::Float64: The path to the parameter file

Return

The corresponding structure with the values read from the parameter file.

Examples

julia> read_param_file(:constants)
constants(0.0010130000000000007, 0.622, 101.325, 0.5, 9.81, 287.0586, 8.314, 273.15, 0.41, 1.0000000000000006e-6, 1367.0, 5.670367e-8, 0.018, 4.57, 2.45, 0.4,2.15e-5)

julia> read_param_file(:site)
DynACof.site("Aquiares", "1979/01/01", 9.93833, -83.72861, 6, 1040.0, 25.0, 0.58, 0.144)
source
DynACof.rotationMethod
rotation(Meteo, rotation_length)

Computes a DataFrame with three columns:

  • Cycle: The rotation index
  • Plot_Age: The age of the rotation (days)
  • PlotAgenum: The age in a numerical form (0 -> 1)

Return

Two objects: the DataFrame and the number of rotations.

Arguments

  • Meteo: The daily meteo file, e.g. output from meteorology
  • rotation_length: the length of the rotation (year)
source
DynACof.sin°Function

Trigonometric Functions (degree)

These functions give the obvious trigonometric functions. They respectively compute the cosine, sine, tangent, arc-cosine, arc-sine, arc-tangent with input and output in degree.

Returns

The output in degree

Details

The conversions between radian to degree is:

\[x \cdot \frac{pi,180}\]

Examples

# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
source
DynACof.soil_model!Method

Soil module subroutine

Make all computations for soil water balance for the ith day by modifying the Sim DataFrame in place.

Arguments

  • Sim::DataFrame: The main simulation DataFrame to make the computation. Is modified in place.
  • Parameters: A named tuple with parameter values (see import_parameters).
  • Met_c::DataFrame: The meteorology DataFrame (see meteorology).
  • i::Int64: The index of the day since the first day of the simulation.

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

Note

This function shouldn't be called by the user. It is made as a sub-module so it is easier for advanced users to modify the code.

See also

dynacof

source
DynACof.struct_to_tupleMethod
struct_to_tuple(structure::DataType,instance)

Transform a struct instance into a tuple, keeping the field names and values.

Arguments

  • structure::DataType: Any struct
  • instance: An instance of structure.

Returns

A named tuple with names and values from the structure.

Examples

struct_to_tuple(constants, constants())
source
DynACof.sun_zenithal_angleMethod
sun_zenithal_angle(DOY::Int64, Latitude::Float64)

Computes the sun zenithal angle at noon (solar time).

Arguments

  • DOY::Int64: Ordinal date (integer): day of year from 1st January (day)
  • Latitude::Float64: Latitude (deg)

Returns

ZEN, the sun zenithal angle (radian)

References

solartime R package from Thomas Wutzler, and more specificly the computeSunPositionDoyHour function (considering the hour at noon).

Examples

# Daily extra-terrestrial radiation on january 1st at latitude 35 N :
sun_zenithal_angle(1,35.0)
source
DynACof.tan°Function

Trigonometric Functions (degree)

These functions give the obvious trigonometric functions. They respectively compute the cosine, sine, tangent, arc-cosine, arc-sine, arc-tangent with input and output in degree.

Returns

The output in degree

Details

The conversions between radian to degree is:

\[x \cdot \frac{pi,180}\]

Examples

# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
source
DynACof.tree_model!Function

Shade Tree subroutine

Make all computations for shade trees (similar to coffee, but no fruits) for the ith day by modifying the S list in place.

Arguments

  • Sim::DataFrame: The main simulation DataFrame to make the computation. Is modified in place.
  • Parameters: A named tuple with parameter values (see import_parameters).
  • Met_c::DataFrame: The meteorology DataFrame (see meteorology).
  • i::Int64: The index of the day since the first day of the simulation.

Return

Nothing, modify the DataFrame of simulation Sim in place. See dynacof for more details.

Note

This function shouldn't be called by the user. It is made as a "sub-module" so it is easier for advanced users to modify the code. No_Shade() is used as an empty function that is called when there are no shade trees.

See also dynacof

source
DynACof.virtual_tempMethod
virtual_temp(Tair::Float64, pressure::Float64, VPD::Float64; formula::String="Sonntag_1990",C_to_K::Float64=constants().Kelvin, epsi::Float64= constants().epsi)::Float64

Computes the virtual temperature, i.e. the temperature at which dry air would have the same density as moist air at its actual temperature.

Arguments

  • Tair::Float64: Air temperature (°C)
  • pressure::Float64: Atmospheric pressure (kPa)
  • VPD::Float64: Vapor pressure deficit (kPa)
  • formula::String: (optional) Formula to be used for the calculation of esat. One of "Sonntag_1990" (Default),

"Alduchov1996", or "Allen1998".

  • C_to_K::Float64: Celsius degree to Kelvin (e.g. 273.15)
  • epsi::Float64: Ratio of the molecular weight of water vapor to dry air

Note

C_to_K and epsi can be found using constants()

Returns

T_v, the virtual temperature (°C)

Examples

virtual_temp(25.0, 1010.0, 1.5, "Sonntag_1990")
source
DynACof.warn_varFunction
warn_var("Date","Start_Date from Parameters","warn")

Warn or stop execution if mandatory meteorology input variables are not provided. It helps the user to know which variable is missing and/or if there are replacements

Arguments

  • Var::String: Input variable name
  • replacement::String: Replacement variable that is used to compute "Var"
  • type::String: Type of error to return : either

Note

  • This function helps to debug the model when some mandatory meteorological variables

are missing from input: either an error (default), or a warning.

  • If the "replacement" variable is not provided in the meteorology file either, this function

will return an error with a hint on which variables can be provided to compute "Var"

Examples

warn_var("Date","Start_Date from Parameters","warn")
source
DynACof.warn_varMethod
warn_var("Date")

Stop execution if mandatory meteorology input variable is not provided.

Arguments

  • Var::String: Input variable name
source
DynACof.test_ZHTMethod
test_ZHT(ZHT::Float64, Z_top::Float64; verbose::Bool= false)::Float64

Test if ZHT is lower than Ztop, and return 1.01 * Ztop if so (or ZHT if not).

Arguments

  • ZHT::Float64: Wind measurement height (m)
  • Z_top::Float64: Average canopy height of the taller crop (m)
  • verbose::Bool: Print information if ZHT < Z_top

Examples

test_ZHT(8.0, 10.0, verbose= true)
source