DynACof.jl: The Dynamic Agroforestry Coffee Crop Model
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>
MACACC project ANR-13-AGRO-0005, Viabilité et Adaptation des Ecosystèmes Productifs, Territoires et Ressources face aux Changements Globaux AGROBIOSPHERE 2013 program
Centre de Coopération Internationale en Recherche Agronomique pour le Développement
Institut National de la Recherche Agronomique
Centro Agronómico Tropical de Investigación y Enseñanza
Index
DynACof.coffee
DynACof.constants
DynACof.site
DynACof.soil
DynACof.tree
DynACof.ALS
DynACof.CN
DynACof.ET_to_LE
DynACof.GDD
DynACof.GDD
DynACof.G_bulk
DynACof.G_interlay
DynACof.G_soilcan
DynACof.Gb_h
DynACof.GetWind
DynACof.LE_to_ET
DynACof.PENMON
DynACof.Rad_ext
DynACof.Rad_net
DynACof.Sucrose_cont_perc
DynACof.VPD_to_e
DynACof.acos°
DynACof.air_density
DynACof.asin°
DynACof.atan°
DynACof.balance_model!
DynACof.bud_init_period!
DynACof.coffee_model!
DynACof.cos°
DynACof.days_without_rain
DynACof.dew_point
DynACof.diffuse_fraction
DynACof.dynacof
DynACof.dynacof_i!
DynACof.dynacof_i_init
DynACof.energy_model_coffee!
DynACof.energy_model_tree!
DynACof.energy_water_models!
DynACof.esat
DynACof.esat_slope
DynACof.import_parameters
DynACof.initialise!
DynACof.is_missing
DynACof.is_missing
DynACof.latent_heat_vaporization
DynACof.light_model_coffee!
DynACof.light_model_tree!
DynACof.logistic
DynACof.logistic_deriv
DynACof.mean
DynACof.meteorology
DynACof.paliv_dis
DynACof.pressure_from_elevation
DynACof.previous_i
DynACof.psychrometric_constant
DynACof.rH_to_VPD
DynACof.read_param_file
DynACof.rotation
DynACof.sin°
DynACof.soil_model!
DynACof.struct_to_tuple
DynACof.sun_zenithal_angle
DynACof.tan°
DynACof.test_ZHT
DynACof.tree_model!
DynACof.virtual_temp
DynACof.warn_var
DynACof.warn_var
DynACof.coffee
— TypeParameter 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.
DynACof.constants
— TypePhysical 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.
DynACof.site
— TypeParameter 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.
DynACof.soil
— TypeParameter 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.
DynACof.tree
— TypeParameter 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.
DynACof.ALS
— MethodAmerican 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 dataSlopeAzimut::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 yearShadeType::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)
DynACof.CN
— MethodTemperature-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)
DynACof.ET_to_LE
— FunctionConversion 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)
DynACof.GDD
— MethodGDD(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
DynACof.GDD
— MethodGDD(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
DynACof.G_bulk
— MethodBulk 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 toconstants().vonkarman
, 0.41.verbose::Bool
: Print information oftest_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)
DynACof.G_interlay
— MethodCanopy 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 toconstants().vonkarman
, 0.41.verbose::Bool
: Print information oftest_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)
DynACof.G_soilcan
— MethodCanopy 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 toconstants().vonkarman
, 0.41.verbose::Bool
: Print information oftest_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)
DynACof.Gb_h
— MethodLeaf 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)
DynACof.GetWind
— MethodGet 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 toconstants().vonkarman
, 0.41.verbose::Bool
: Print information oftest_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)
DynACof.LE_to_ET
— FunctionConversion 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)
DynACof.PENMON
— MethodPENMON(;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 toconstants
, 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)
DynACof.Rad_ext
— FunctionRad_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 toconstants().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,
- 53: p. 338-362.
Examples
# Daily extra-terrestrial radiation on january 1st at latitude 35 N :
Rad_ext(1,35.0)
DynACof.Rad_net
— FunctionRad_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 toconstants().σ
.Gsc::Float64
: The solar constant (W m-2), default toconstants().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 pressure
ea` 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)
DynACof.Sucrose_cont_perc
— MethodFruit sucrose accumulation
Computes a the sucrose accumulation into coffee fruits through time following a logistic curve
Arguments
x::Float64
: Cumulated degree daysa::Float64
: Parameterb::Float64
: Parameterx0::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)
DynACof.VPD_to_e
— FunctionVPD_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.
DynACof.acos°
— FunctionTrigonometric 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:
Examples
# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
DynACof.air_density
— FunctionAir 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 toconstants
, 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)
DynACof.asin°
— FunctionTrigonometric 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:
Examples
# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
DynACof.atan°
— FunctionTrigonometric 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:
Examples
# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
DynACof.balance_model!
— MethodEnergy 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.
DynACof.bud_init_period!
— MethodBud 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.
DynACof.coffee_model!
— FunctionCoffee 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.
DynACof.cos°
— FunctionTrigonometric 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:
Examples
# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
DynACof.days_without_rain
— Methoddays_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}
: AnArray
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)
DynACof.dew_point
— Functiondew_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)
DynACof.diffuse_fraction
— Functiondiffuse_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 ofSpitters
,Page
orGopinathan
Gsc::Float64
: (Optionnal) The solar constant (W m-2), default toconstants().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,
- 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)
DynACof.dynacof
— Methoddynacof(;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
.
- constants: Physical constants file. Default: "constants.jl". More info in the corresponding structure:
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:
Type | Var | unit | Definition |
---|---|---|---|
General | Cycle | - | Plantation cycle ID |
date | Posix date (Y-m-d) | Simulation date | |
year | Year | Simulation year | |
Plot_Age | year | Plantation age (starting at 1) | |
PlotAgenum | year (numeric) | Numeric age of plantation | |
LAIplot | m2 leaves m-2 soil | Plot (Coffee + Shade Tree if any) Leaf Area Index | |
Suffixes for Coffee organs | x_RE | - | Reserves |
x_SCR | - | Stump and Coarse roots | |
x_Fruit | - | Fruit | |
x_Shoot | - | Resprout wood (= branches) | |
x_FRoot | - | Fine roots | |
x_Leaf | Leaves | ||
Suffixes for Shade Tree org. | xRETree | - | Reserves |
xStemTree | - | Stem (= trunk) | |
xBranchTree | - | Branches | |
xCoarseRootTree | - | Coarse roots | |
xFRootTree | - | Fine roots | |
xLeafTree | Leaves | ||
Energy | Rn_tot | MJ m-2 d-1 | System net radiation |
Rn_Tree | MJ m-2 d-1 | Shade tree net radiation | |
Rn_Coffee | MJ m-2 d-1 | Coffee net radiation | |
Rn_Soil | MJ m-2 d-1 | Soil net radiation | |
RnSoilSW | MJ m-2 d-1 | Soil net radiation computed using Shuttleworth & Wallace (1985) for reference | |
LE_x | MJ m-2 d-1 | System / Coffee / Tree / Soil latent heat | |
H_x | MJ m-2 d-1 | System / Coffee / Tree / Soil sensible heat | |
Q_Soil | MJ m-2 d-1 | Soil heat transport | |
Transmittance_Tree | fraction | Fraction of light transmitted by the shade trees | |
PARTransTree | MJ m-2 d-1 | Light transmitted by the shade trees canopy | |
PAR_Trans | MJ m-2 d-1 | Light transmitted by the Coffea canopy | |
K_Dir | - | Direct light extinction coefficient | |
K_Dif | - | Diffuse light extinction coefficient | |
APAR | MJ m-2 d-1 | Absorbed PAR by the plant | |
APAR_Dif | MJ m-2 d-1 | Absorbed diffuse PAR (Direct is APAR-APAR_Dif) | |
lue | gC MJ | Light use efficiency | |
Tleaf_Coffee | deg C | Coffee canopy temperature computed by DynACof | |
TairCanopy_x | deg C | Air tempetature at the center of the layer | |
Gbhx | m s-1 | Coffee / Tree conductance to heat | |
Gbaircanopy | m s-1 | Bulk (no tree) or canopy layer to canopy layer aerodynamic conductance | |
airdensityx | kg m-3 | Air density inside the canopy of the tree or the coffee (see air_density ) | |
WindSpeed_x | m s-1 | Wind speed at the center of the layer | |
DegreeDays_Tcan | deg C | Growing degree days computed using Coffee Canopy Temperature | |
Carbon | GPP | gC m-2 d-1 | Gross primary productivity |
Consumption_RE | gC m-2 d-1 | Daily reserve consumption | |
CarbonLackMortality | gC m-2 d-1 | Mortality from a higher carbon consumption than Supply | |
Rm | gC m-2 d-1 | Total Coffee maintenance respiration | |
Rm_x | gC m-2 d-1 | Maintenance respiration at organ scale | |
Rg | gC m-2 d-1 | Total Coffee growth respiration | |
Rg_x | gC m-2 d-1 | Growth respiration at organ scale | |
Ra | gC m-2 d-1 | Coffee layer autotrophic respiration (=Rm+Rg) | |
Demand_x | gC m-2 d-1 | C demand at organ scale (fruit, leaf and fine root only) | |
Alloc_x | gC m-2 d-1 | C allocation to organ net of Rm (NPP+Rg) | |
Supply | gC m-2 d-1 | C supply at the begining of the day at layer scale (GPP+Reserve consumption-Rm) | |
Supply_x | gC m-2 d-1 | C supply to organ, net of Rm | |
NPP | gC m-2 d-1 | Net primary productivity at layer scale | |
NPP_x | gC m-2 d-1 | Net primary productivity at organ scale | |
Mnat_x | gC m-2 d-1 | Organ natural mortality (= due to lifespan) | |
Mprun_x | gC m-2 d-1 | Organ mortality due to pruning | |
M_ALS | gC m-2 d-1 | Coffee leaf mortality from American Leaf Spot | |
Mortality_x | gC m-2 d-1 | Total organ mortality | |
LAI | m2 leaves m-2 soil | Leaf Area Index | |
CM_x | gC m-2 d-1 | Organ C mass | |
DM_x | gDM m-2 d-1 | Organ dry mass | |
Fruit development | BudInitPeriod | boolean | Bud initiation period (BIP) |
Budinit | Buds d-1 | Total Number of Buds Initiated per day | |
ratioNodestoLAI | Nodes LAI-1 | Number of fruiting nodes per LAI unit | |
TempcorBud | fraction | Temperature correction factor for bud development | |
pbreak | 0-1 | Daily probability of bud dormancy break | |
BudBreak | Buds d-1 | Total number of buds breaking dormancy per day | |
SM | g m-2 d-1 | Coffee Fruit Sucrose Mass | |
SC | g Sugar gDM | Coffee Fruit Sucrose Content | |
Maturation_duration | days Fruit cohort-1 | Coffee Fruit Total Maturation Duration for each cohort | |
HarvestMaturityPot | Fraction | Daily average fruit maturity (0-1) | |
Date_harvest | day of year | date of harvest | |
Harvest_Fruit | gC m-2 | Total fruit carbon mass at harvest | |
Yield_green | kg ha-1 | Yield of green coffee bean | |
Harvest_Maturity | Fraction | Average fruit maturity at harvest (0-1) | |
Overriped_Fruit | gC m-2 d-1 | Overriped fruits that fall onto the ground | |
Water | IntercMax | mm | Maximum potential rainfall interception by canopy |
CanopyHumect | mm | Rainfall interception by canopy | |
Throughfall | mm | Rainfall not intercepted by the canopy, coming to the soil | |
SuperficialRunoff | mm | Water runoff from the superficial soil layer | |
ExcessRunoff | mm | Discharge from the superficial soil layer | |
TotSuperficialRunoff | mm | Sum of discharge+ExcessRunoff | |
InfilCapa | mm | Superficial water infiltration capacity to first layer of soil | |
Infiltration | mm | Superficial water infiltration to first layer of soil | |
Drain_[1-3] | mm | Water drainage from soil layer 1, 2 or 3 | |
WSurfaceRes | mm | Soil water content from the surface layer | |
W_tot | mm | Total soil profile water content | |
W_[1-3] | mm | Soil 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_tot | mm | Extractable water from the soil | |
EW_[1-3] | mm | Extractable water from the layer 1, 2 or 3 | |
SWD | mm | soil water deficit | |
RootWaterExtract_[1-3] | mm | Root water extraction for soil layer 1 to 3 | |
IntercRevapor | mm | Evaporation by canopy | |
T_x | mm | Transpiration at system / Coffee / Tree scale | |
E_Soil | mm | Soil evaporation | |
ETR | mm | System evapotranspiration | |
SoilWaterPot | MPa | Soil water potential | |
PSIL_* | Mpa | Coffee leaf water potential | |
Special shade tree variables | LA_Tree | m2 leaves tree-1 | shade tree leaf area |
CrownHTree | m | Crown height | |
TrunkHTree | m | Trunk height | |
Height_Tree | m | Shade tree total height (used for boundary conductance), set to 0 if no shade trees | |
DBH_Tree | m | Diameter at breast height | |
LAD_Tree | m2 m-3 | Shade tree Leaf Area Density | |
CrownRad_Tree | m | Crown radius | |
CrownProj_Tree | m2 crown tree-1 | Crown projection | |
Stocking_Tree | tree m-2 | Shade tree density | |
TimetoThin_Tree | boolean | Days on which tree is thinned | |
MThinningxTree | gc m-2 d-1 | Mortality due to thining at organ scale |
- Meteo: A data.frame of the input meteorology, potentially coming from the output of [Meteorology()]:
Var | unit | Definition | If missing |
---|---|---|---|
Date | POSIXct | Date in POSIXct format | Computed from start date parameter, or set a dummy date if missing |
year | year | Year of the simulation | Computed from Date |
DOY | day | day of the year | Computed from Date |
Rain | mm | Rainfall | Assume no rain |
Tair | Celsius | Air temperature (above canopy) | Computed from Tmax and Tmin |
Tmax | Celsius | Maximum air temperature during the day | Required (error) |
Tmin | Celsius | Minimum air temperature during the day | Required (error) |
RH | % | Relative humidity | Not used, but prefered over VPD for Rn computation |
RAD | MJ m-2 d-1 | Incident shortwave radiation | Computed from PAR |
Pressure | hPa | Atmospheric pressure | Computed from VPD, Tair and Elevation, or alternatively from Tair and Elevation. |
WindSpeed | m s-1 | Wind speed | Taken as constant: Parameters -> WindSpeed |
CO2 | ppm | Atmospheric CO2 concentration | Taken as constant: Parameters -> CO2 |
DegreeDays | Celsius | Growing degree days | Computed using GDD |
PAR | MJ m-2 d-1 | Incident photosynthetically active radiation | Computed from RAD |
FDiff | Fraction | Diffuse light fraction | Computed using diffuse_fraction using Spitters et al. (1986) formula |
VPD | hPa | Vapor pressure deficit | Computed from RH |
Rn | MJ m-2 d-1 | Net radiation (will be depreciated) | Computed using Rad_net with RH, or VPD |
DaysWithoutRain | day | Number of consecutive days with no rainfall | Computed from Rain |
Air_Density | kg m-3 | Air density of moist air (ρ) above canopy | Computed using air_density |
ZEN | radian | Solar zenithal angle at noon | Computed from Date, Latitude, Longitude and Timezone |
- Parameters: A list of the input parameters (see
import_parameters
,constants
,soil
,coffee
,tree
)
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)
DynACof.dynacof_i!
— Functiondynacof_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, soi=366
make a simulation
for the 366th row of Sim and Met.
Sim::DataFrame
: The simulation DataFrame (seedynacof
), initialized usingdynacof_i_init
;Met_c::DataFrame
: The meteorology DataFrame (seemeteorology
), initialized usingdynacof_i_init
Parameters
: The parameters for the model (seeimport_parameters
), initialized usingdynacof_i_init
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)).
DynACof.dynacof_i_init
— Methoddynacof_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
.
- constants: Physical constants file. Default: "constants.jl". More info in the corresponding structure:
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)
DynACof.energy_model_coffee!
— FunctionEnergy 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.
DynACof.energy_model_tree!
— FunctionEnergy 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.
DynACof.energy_water_models!
— MethodEnergy 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:
light_model_tree!
for the light interception of the shade treelight_model_coffee!
for the light interception of the coffeeenergy_model_tree!
for the energy fluxes of the tree (H, LE, Tleaf...)energy_model_coffee!
for the energy fluxes of the coffee (H, LE, Tleaf...)soil_model!
the full soil model (water transport, H, T Soil...)balance_model!
the energy balance at plot scale model (H, LE, Rn...)
Return
Nothing, modify the DataFrame of simulation Sim
in place. See dynacof
for more details.
DynACof.esat
— Functionesat(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.
DynACof.esat_slope
— Functionesat_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.
DynACof.import_parameters
— Functionimport_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. Ifpath= "package"
, take the default files from the packageNames::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=""))
DynACof.initialise!
— MethodInitialise model variables.
Arguments
Sim::DataFrame
: The simulation DataFrameMet_c::DataFrame
: The meteorology DataFrameParameters
: The parameters for the model
DynACof.is_missing
— Methodis_missing(MetData, "Date")
Find if a column is missing from a DataFrame.
Arguments
data::DataFrame
: a DataFramekey::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
DynACof.is_missing
— Methodis_missing(data::NamedTuple,key::String)
Find if a key is missing from a tuple.
Arguments
data::NamedTuple
: a named tuplekey::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
DynACof.latent_heat_vaporization
— FunctionLatent 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)
DynACof.light_model_coffee!
— FunctionLight 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.
DynACof.light_model_tree!
— FunctionLight 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.
DynACof.logistic
— FunctionCompute a logistic function or its derivative
Arguments
x::Float
: The x valueu_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)
DynACof.logistic_deriv
— FunctionCompute a logistic function or its derivative
Arguments
x::Float
: The x valueu_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)
DynACof.mean
— Methodmean(x)
Mean of a vector
DynACof.meteorology
— FunctionMeteorology(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 (seeimport_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.
Var | unit | Definition | If missing |
---|---|---|---|
Date | POSIXct | Date in POSIXct format | Computed from start date parameter, or set a dummy date if missing |
year | year | Year of the simulation | Computed from Date |
DOY | day | day of the year | Computed from Date |
Rain | mm | Rainfall | Assume no rain |
Tair | Celsius | Air temperature (above canopy) | Computed from Tmax and Tmin |
Tmax | Celsius | Maximum air temperature during the day | Required (error) |
Tmin | Celsius | Minimum air temperature during the day | Required (error) |
RH | % | Relative humidity | Not used, but prefered over VPD for Rn computation |
RAD | MJ m-2 d-1 | Incident shortwave radiation | Computed from PAR |
Pressure | hPa | Atmospheric pressure | Computed from VPD, Tair and Elevation, or alternatively from Tair and Elevation. |
WindSpeed | m s-1 | Wind speed | Taken as constant: Parameters -> WindSpeed |
CO2 | ppm | Atmospheric CO2 concentration | Taken as constant: Parameters -> CO2 |
DegreeDays | Celsius | Growing degree days | Computed using GDD |
PAR | MJ m-2 d-1 | Incident photosynthetically active radiation | Computed from RAD |
FDiff | Fraction | Diffuse light fraction | Computed using diffuse_fraction using Spitters et al. (1986) formula |
VPD | hPa | Vapor pressure deficit | Computed from RH |
Rn | MJ m-2 d-1 | Net radiation (will be depreciated) | Computed using Rad_net with RH, or VPD |
DaysWithoutRain | day | Number of consecutive days with no rainfall | Computed from Rain |
Air_Density | kg m-3 | Air density of moist air (ρ) above canopy | Computed using air_density |
ZEN | radian | Solar zenithal angle at noon | Computed 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)
DynACof.paliv_dis
— Methodpaliv_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 │
DynACof.pressure_from_elevation
— Methodpressure_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. 245g::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)
DynACof.previous_i
— FunctionFind the ith previous index, avoiding 0 or negative indexes.
Arguments
i::DataType
: Current indexn
: 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
DynACof.psychrometric_constant
— FunctionPsychrometric constant (γ)
Arguments
Tair::Float64
: Air temperature (deg C)pressure::Float64
: Atmospheric pressure (kPa)Parameters
: Constant parameters, default toconstants
, 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)
DynACof.rH_to_VPD
— FunctionrH_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.
DynACof.read_param_file
— Functionreadparamfile(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 ofconstants
,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)
DynACof.rotation
— Methodrotation(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 frommeteorology
rotation_length
: the length of the rotation (year)
DynACof.sin°
— FunctionTrigonometric 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:
Examples
# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
DynACof.soil_model!
— MethodSoil 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 (seeimport_parameters
).Met_c::DataFrame
: The meteorology DataFrame (seemeteorology
).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.struct_to_tuple
— Methodstruct_to_tuple(structure::DataType,instance)
Transform a struct
instance into a tuple, keeping the field names and values.
Arguments
structure::DataType
: Anystruct
instance
: An instance ofstructure
.
Returns
A named tuple with names and values from the structure.
Examples
struct_to_tuple(constants, constants())
DynACof.sun_zenithal_angle
— Methodsun_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)
DynACof.tan°
— FunctionTrigonometric 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:
Examples
# cosinus of an angle of 120 degree:
cos°(120)
# should yield -0.5, as in the base version:
cos(120*π/180)
DynACof.tree_model!
— FunctionShade 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 (seeimport_parameters
).Met_c::DataFrame
: The meteorology DataFrame (seemeteorology
).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
DynACof.virtual_temp
— Methodvirtual_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")
DynACof.warn_var
— Functionwarn_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 namereplacement::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")
DynACof.warn_var
— Methodwarn_var("Date")
Stop execution if mandatory meteorology input variable is not provided.
Arguments
Var::String
: Input variable name
DynACof.test_ZHT
— Methodtest_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)