Skip to content

Commit

Permalink
Updating to 1.3.0
Browse files Browse the repository at this point in the history
See News.md for changes.
  • Loading branch information
VEZY committed Jan 20, 2020
1 parent d72fb60 commit a16ae5a
Show file tree
Hide file tree
Showing 106 changed files with 783 additions and 338 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ man/figures
^docs$
vignettes
pkgdown
references.bib
environmental-modelling-and-software.csl
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: DynACof
Type: Package
Title: Dynamic Crop Model to Simulate Coffee Crop Ecophysiology for Monospecific Stands or Agroforestry
Version: 1.2.0
Date: 2019-03-14
Title: A Process-based Model to Study Growth, Yield and Ecosystem Services of Coffee Agroforestry Systems
Version: 1.3.0
Date: 2020-02-01
Authors@R: c(person("Remi", "Vezy",, "[email protected]", c("aut", "cre", "cph"),comment = c(ORCID = "0000-0002-0808-1461")),
person("Olivier", "Roupsard",, "[email protected]", c("aut", "cph")),
person("Guerric", "le Maire", role = c("aut", "cph")))
Expand Down Expand Up @@ -33,7 +33,7 @@ Imports:
solartime,
JuliaCall,
rstudioapi
RoxygenNote: 6.1.1
RoxygenNote: 7.0.0
Roxygen: list(markdown = TRUE)
Suggests:
knitr,
Expand Down
32 changes: 32 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# DynACof 1.2.1

* Tsoil used for Rm roots now
* Remove `MaxTT` from `GDD`
* Replace `Tleaf_Coffee` by `TairCanopy` in `DegreeDays_Tcan` and `T_VG` (for `ratioNodestoLAI`) as it should be (see documentation)
* Put `CM_Fruit_Cohort_remain` to 0 when harvested
* Add option for no harvest at all
* `E_Soil` take in priority in surface layer, and then possibly in `W_1`
* `LeafWaterPotential` is now fully computed
* Rename `LeafWaterPotential` into `PSIL`
* Add `PSIL_Tree` computation
* Update default metamodels and parameters (revision of article)
* Remove `LAI_max` dependence for leaf C demand computation
* [DynACof.jl](https://github.com/VEZY/DynACof.jl) related:
* Update dynacof.jl_setup for dev versions
* Update `dynacof.jl_setup` doc + website
* Add Pkg.free when R terminates
* Update the code following modifs in julia version (from 69cd69ba69d210e0479b8749deebc9585b58c1c0 to 7239c93bc2c50eb761de330cf4c43429fe18b4ef)
* Runs shade tree model only if `Stocking_Tree > 0.0` and remove overcomplicated shade tree models (keep only one now), following [DynACof.jl](https://github.com/VEZY/DynACof.jl)
* Update docs to Roxygen 7.0.0.
* Add startup message
* Fix several bugs:
* Fix issue in the PENMON implementation
* FileName reading
* Fix format of simulation Table returned by DynACof with several cycles
* Fix error in dynacof_i
* Fix issues in the soil module
* Fix transpiration metamodel bug
* Fix the computation of the overriped fruits (could potentially count the same overriped fruits)
* Fix issue in soil RootWaterExtract_*
* Fix issue with LeafWaterPotential (was computed before T_Coffee)

# DynACof 1.2.0

* Reformat the code so the shade tree, coffee, soil and energy balance are made by separate functions sequentially
Expand Down
14 changes: 7 additions & 7 deletions R/0-Functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ GDD= function(Tmax=NULL,Tmin=NULL,MinTT=5,Round=T,Tmean=NULL){
#'
#' @note This function force \eqn{S_0= S_g} when \eqn{S_0= 0} to avoid the production of `NA`'s.
#'
#' @return \item{\eqn{Hd/H}}{Daily diffuse fraction of light (\%)}
#' @return \item{\eqn{Hd/H}}{Daily diffuse fraction of light (%)}
#'
#' @references \itemize{
#' \item Duffie, J.A. and W.A. Beckman, Solar engineering of thermal processes. 2013: John Wiley & Sons.
Expand Down Expand Up @@ -344,7 +344,7 @@ Rad_ext= function(DOY,Latitude,Gsc=Constants()$Gsc){
#' @param RAD Incident daily total radiation (\eqn{MJ\ m^{-2} d^{-1}}{MJ m-2 d-1})
#' @param Tmax Maximum daily air temperature (celsius degree)
#' @param Tmin Minimum daily air temperature (celsius degree)
#' @param Rh Average daily relative humidity (`\%`)
#' @param Rh Average daily relative humidity (`%`)
#' @param VPD Mean daily Vapor Pressure Deficit (\eqn{hPa}), only needed if `Rh` is missing
#' @param Latitude Latitude (\eqn{deg})
#' @param Elevation Elevation (\eqn{m})
Expand Down Expand Up @@ -1026,9 +1026,9 @@ logistic_deriv= function(xi,u_log,s_log){
#' @param a Parameter
#' @param b Parameter
#' @param x0 Mid-maturation (logistic function inflexion point)
#' @param y0 Sucrose content at the beginning (in \%, 1-100)
#' @param y0 Sucrose content at the beginning (in %, 1-100)
#'
#' @return Sucrose content, in \% of fruit total dry mass
#' @return Sucrose content, in % of fruit total dry mass
#'
#' @references Pezzopane et al. (2012) :
#' Pezzopane, J., et al., Agrometeorological parameters for prediction of the maturation period
Expand All @@ -1050,11 +1050,11 @@ Sucrose_cont_perc= function(x,a,b,x0,y0){
#' @description Computes the percentage of living tissue in the organ according to age
#'
#' @param Age_Max Maximum age of the organ (year)
#' @param P_Start Percentage of living tissue at first age (\% of dry mass)
#' @param P_End Percentage of living tissue at last age (\% of dry mass)
#' @param P_Start Percentage of living tissue at first age (% of dry mass)
#' @param P_End Percentage of living tissue at last age (% of dry mass)
#' @param k Rate between P_Start and P_End
#'
#' @return Living tissue at each age in \% of organ dry mass
#' @return Living tissue at each age in % of organ dry mass
#'
#' @details The percentage of living tissue is computed as follows:
#' \deqn{P_{End}+\left((P_{Start}-P_{End})\cdot e^{seq(0,-k,length.out=Age_{Max})}\right)}{
Expand Down
4 changes: 2 additions & 2 deletions R/1-Meteo.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
#' 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.
#' \tabular{llll}{
#' \strong{Var} \tab \strong{unit} \tab \strong{Definition} \tab \strong{If missing} \cr
#' *Var* \tab *unit* \tab *Definition* \tab *If missing* \cr
#' Date \tab POSIXct \tab Date in POSIXct format \tab Computed from start date parameter, or set a dummy date if missing \cr
#' year \tab year \tab Year of the simulation \tab Computed from Date \cr
#' DOY \tab day \tab day of the year \tab Computed from Date \cr
#' Rain \tab mm \tab Rainfall \tab Assume no rain \cr
#' Tair \tab Celsius \tab Air temperature (above canopy) \tab Computed from Tmax and Tmin \cr
#' Tmax \tab Celsius \tab Maximum air temperature during the day \tab Required (error) \cr
#' Tmin \tab Celsius \tab Minimum air temperature during the day \tab Required (error) \cr
#' RH \tab \% \tab Relative humidity \tab Not used, but prefered over VPD for Rn computation \cr
#' RH \tab % \tab Relative humidity \tab Not used, but prefered over VPD for Rn computation \cr
#' RAD \tab MJ m-2 d-1 \tab Incident shortwave radiation \tab Computed from PAR \cr
#' Pressure \tab hPa \tab Atmospheric pressure \tab Computed from VPD, Tair and Elevation, or alternatively from Tair and Elevation. \cr
#' WindSpeed \tab m s-1 \tab Wind speed \tab Taken as constant: `Parameters$WindSpeed` \cr
Expand Down
43 changes: 24 additions & 19 deletions R/2-main.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
#' Default input files are provided with the package as an example parameterization.
#'
#' @return Return invisibly a list containing three objects (Parameters, Meteo and Sim):
#' \itemize{
#' \item Sim: A data.frame of the simulation outputs at daily time-step: \tabular{llll}{
#' \strong{Type} \tab \strong{Var} \tab \strong{unit} \tab \strong{Definition} \cr
#'
#' * Sim: A data.frame of the simulation outputs at daily time-step:
#' \tabular{llll}{
#' *Type* \tab *Var* \tab *unit* \tab *Definition* \cr
#' General \tab Cycle \tab - \tab Plantation cycle ID \cr
#' \tab Plot_Age \tab year \tab Plantation age (starting at 1) \cr
#' \tab Plot_Age_num \tab year (numeric) \tab Numeric age of plantation \cr
Expand Down Expand Up @@ -134,29 +135,33 @@
#' \tab MThinning_x_Tree \tab gc m-2 d-1 \tab Mortality due to thining at organ scale
#'}
#'
#' \item Meteo: A data.frame of the input meteorology, potentially coming from the output of [Meteorology()]: \tabular{llll}{\strong{Var} \tab \strong{unit} \tab \strong{Definition} \tab \strong{If missing} \cr
#' Date \tab POSIXct date\tab Date in POSIXct format \tab Computed from start date parameter, or set a dummy date if missing\cr
#' * Meteo: A data.frame of the input meteorology, potentially coming from the output of [Meteorology()]:
#' \tabular{llll}{
#' *Var* \tab *unit* \tab *Definition* \tab *If missing* \cr
#' Date \tab POSIXct \tab Date in POSIXct format \tab Computed from start date parameter, or set a dummy date if missing \cr
#' year \tab year \tab Year of the simulation \tab Computed from Date \cr
#' DOY \tab day \tab day of the year \tab Computed from Date \cr
#' Rain \tab mm \tab Rainfall \tab Assume no rain \cr
#' Tair \tab deg C \tab Air temperature (above canopy) \tab Computed from Tmax and Tmin \cr
#' Tmax \tab deg C \tab Maximum air temperature during the day \tab Required (error) \cr
#' Tmin \tab deg C \tab Minimum air temperature during the day \tab Required (error) \cr
#' RH \tab \% \tab Relative humidity \tab Not used, but prefered over VPD for Rn computation \cr
#' Tair \tab Celsius \tab Air temperature (above canopy) \tab Computed from Tmax and Tmin \cr
#' Tmax \tab Celsius \tab Maximum air temperature during the day \tab Required (error) \cr
#' Tmin \tab Celsius \tab Minimum air temperature during the day \tab Required (error) \cr
#' RH \tab % \tab Relative humidity \tab Not used, but prefered over VPD for Rn computation \cr
#' RAD \tab MJ m-2 d-1 \tab Incident shortwave radiation \tab Computed from PAR \cr
#' Pressure \tab hPa \tab Atmospheric pressure \tab Try to compute from VPD, Tair and Elevation, or Tair and Elevation. \cr
#' WindSpeed \tab m s-1 \tab Wind speed \tab Try to set it to constant: `Parameters$WindSpeed` \cr
#' CO2 \tab ppm \tab Atmospheric CO2 concentration \tab Try to set it to constant: `Parameters$CO2`\cr
#' DegreeDays \tab deg C \tab Growing degree days \tab Computed using [GDD()] \cr
#' Pressure \tab hPa \tab Atmospheric pressure \tab Computed from VPD, Tair and Elevation, or alternatively from Tair and Elevation. \cr
#' WindSpeed \tab m s-1 \tab Wind speed \tab Taken as constant: `Parameters$WindSpeed` \cr
#' CO2 \tab ppm \tab Atmospheric CO2 concentration \tab Taken as constant: `Parameters$CO2` \cr
#' DegreeDays \tab Celsius \tab Growing degree days \tab Computed using [GDD()] \cr
#' PAR \tab MJ m-2 d-1 \tab Incident photosynthetically active radiation \tab Computed from RAD \cr
#' FDiff \tab Fraction \tab Diffuse light fraction \tab Computed using [Diffuse_d()] using Spitters formula \cr
#' FDiff \tab Fraction \tab Diffuse light fraction \tab Computed using [Diffuse_d()] using Spitters et al. (1986) formula \cr
#' VPD \tab hPa \tab Vapor pressure deficit \tab Computed from RH \cr
#' Rn (!=Rn_tot) \tab MJ m-2 d-1 \tab Net radiation (will soon be depreciated) \tab Computed using [Rad_net()] with RH, or VPD \cr
#' Rn \tab MJ m-2 d-1 \tab Net radiation (will be depreciated) \tab Computed using [Rad_net()] with RH, or VPD \cr
#' DaysWithoutRain \tab day \tab Number of consecutive days with no rainfall \tab Computed from Rain \cr
#' Air_Density \tab kg m-3 \tab Air density of moist air (\eqn{\rho}) above canopy \tab Computed using [bigleaf::air.density()]}
#' \item Parameters: A list of the input parameters (see [site()])
#' Air_Density \tab kg m-3 \tab Air density of moist air (\eqn{\rho}) above canopy \tab Computed using [bigleaf::air.density()] \cr
#' ZEN \tab radian \tab Solar zenithal angle at noon \tab Computed from Date, Latitude, Longitude and Timezone
#' }
#'
#' * Parameters: A list of the input parameters (see [site()])
#'
#' @details The user can import a simulation using [base::readRDS()].
#' 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,
Expand Down Expand Up @@ -363,7 +368,7 @@ mainfun= function(cy,Direction,Meteo,Parameters){
#'
#' @examples
#'\dontrun{
#' Making a regular simulation using example data:
#' # Making a regular simulation using example data:
#' S= DynACof(Period= as.POSIXct(c("1979-01-01", "1980-12-31")))
#'
#' # Value of the maintenance respiration for coffee on day i=100:
Expand All @@ -378,7 +383,7 @@ mainfun= function(cy,Direction,Meteo,Parameters){
#' # New value of the maintenance respiration for coffee:
#' S$Sim$Rm[i]
#'
#' # To re-run DynACof for several days, use a range for `i`:
#' # To re-run DynACof for several days, use a range for i:
#' S= dynacof_i(i:(i+10),S)
#'
#'}
Expand Down
2 changes: 1 addition & 1 deletion R/3-Metamodels.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' and transpiration through stomatal conductance. Therefore, we derived metamodels from MAESPA for the
#' diffuse (\eqn{K_{dif_{Tree}}}{K_dif_Tree}) and the direct (\eqn{K_{dir_{Tree}}}{K_dir_Tree}) shade tree light
#' extinction coefficients, the light use efficiency (LUE, gC MJ-1), the coffee canopy temperature (Tcan, deg Celsius)
#' and leaf water potential (MPa), the transpiration (T_\*, mm) and plant sensible heat flux (H_\*). The coffee layer was
#' and leaf water potential (MPa), the transpiration (T_x, mm) and plant sensible heat flux (H_x). The coffee layer was
#' considered homogeneous enough to compute constant extinction coefficients derived from the MAESPA simulation,
#' and the partitioning parameter between soil sensible and latent flux was also adjusted using MAESPA outputs.
#' MAESPA is a 3D explicit model for energy, carbon and water fluxes simulation, for further details, see:
Expand Down
6 changes: 3 additions & 3 deletions R/4-dynacof_julia.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' If you are using a new version of R, please use the argument `rebuild= TRUE` (see [JuliaCall::julia_setup()]).
#'
#' @param ... Parameters are passed down to [JuliaCall::julia_setup()]
#' @param dev_path the path to the `dev` folder location (*e.g.* "C:/Users/<User>/.julia/dev") if a dev version of `DynACof.jl` has to be used.
#' @param dev_path the path to the `dev` folder location (*e.g.* "C:/Users/{User}/.julia/dev") if a dev version of `DynACof.jl` has to be used.
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -186,7 +186,7 @@ dynacof.jl= function(Period=NULL,WriteIt=FALSE,Inpath=NULL,output_f=".RData",
#' # Setting up julia + DynACof.jl:
#' dynacof.jl_setup()
#'
#' Making a regular simulation using example data:
#' # Making a regular simulation using example data:
#' # First, downloading an example meteorology file:
#' met_file= tempfile()
#' m= "https://raw.githubusercontent.com/VEZY/DynACof.jl_inputs/master/meteorology.txt"
Expand All @@ -209,7 +209,7 @@ dynacof.jl= function(Period=NULL,WriteIt=FALSE,Inpath=NULL,output_f=".RData",
#' # New value of the maintenance respiration for coffee:
#' S$Sim$Rm[i]
#'
#' # To re-run DynACof for several days, use a range for `i`:
#' # To re-run DynACof for several days, use a range for i:
#' S= dynacof_i(i:(i+10),S)
#' }
dynacof_i.jl= function(i,S){
Expand Down
Loading

0 comments on commit a16ae5a

Please sign in to comment.