Skip to content

Commit

Permalink
even more internal
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcaceres committed Jun 2, 2024
1 parent 8fec9b6 commit fdff233
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 36 deletions.
6 changes: 5 additions & 1 deletion R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ stand_LAI <- function(x, SpParams, gdd = NA_real_, bounded = TRUE) {
#' Function \code{forest2aboveground()} extracts height and species identity from plant cohorts of \code{x},
#' and calculate leaf area index and crown ratio.
#'
#' \emph{IMPORTANT NOTE}: Function names \code{forest2spwbInput()} and \code{forest2growthInput()} are now deprecated, but
#' \emph{IMPORTANT NOTE}: Function names \code{forest2spwbInput()} and \code{forest2growthInput()} are now internal and deprecated, but
#' they can still be used for back-compatibility. They correspond to functions \code{\link{spwbInput}} and \code{\link{growthInput}}
#'
#' @return
Expand Down Expand Up @@ -875,11 +875,13 @@ stand_LAI <- function(x, SpParams, gdd = NA_real_, bounded = TRUE) {
#'
#'
#' @name forest2aboveground
#' @keywords internal
forest2aboveground <- function(x, SpParams, gdd = NA_real_, loading = FALSE) {
.Call(`_medfate_forest2aboveground`, x, SpParams, gdd, loading)
}

#' @rdname forest2aboveground
#' @keywords internal
forest2belowground <- function(x, soil, SpParams) {
.Call(`_medfate_forest2belowground`, x, soil, SpParams)
}
Expand Down Expand Up @@ -2547,11 +2549,13 @@ growthInput <- function(x, soil, SpParams, control) {
}

#' @rdname forest2aboveground
#' @keywords internal
forest2spwbInput <- function(x, soil, SpParams, control) {
.Call(`_medfate_forest2spwbInput`, x, soil, SpParams, control)
}

#' @rdname forest2aboveground
#' @keywords internal
forest2growthInput <- function(x, soil, SpParams, control) {
.Call(`_medfate_forest2growthInput`, x, soil, SpParams, control)
}
Expand Down
6 changes: 3 additions & 3 deletions R/dataset_documentation.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Description of the plant cohorts of a forest stand.
#' Description of a forest stand.
#'
#' \code{exampleforest} is an example of forest stand description, whereas \code{exampleforest2} is an alternative forest description where leaf area index and crown ratio are supplied instead of structural (density, DBH and cover) parameters.
#'
Expand Down Expand Up @@ -90,7 +90,7 @@ NULL
#' @keywords data
NULL

#' Data tables with species parameter definition and values for different countries
#' Data tables with species parameter definitions and values
#'
#' A data sets of species parameter definition and values, the latter resulting from existing databases, fit to empirical data or expert-based guesses.
#'
Expand All @@ -106,7 +106,7 @@ NULL
#' }
#' @details
#' \code{SpParamsMED} was the official species parameter for package versions up to v.4.0.0, but will not be maintained in the future. Additional
#' species parameter tables for different countries are distributed via package \code{traits4models}, available from GitHub (https://emf-creaf.github.io/traits4models/).
#' species parameter tables for different countries are distributed via package [traits4models](https://emf-creaf.github.io/traits4models/).
#'
#' @examples
#' data(SpParamsDefinition)
Expand Down
3 changes: 2 additions & 1 deletion R/tree2forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
#'
#' @author Miquel De \enc{Cáceres}{Caceres} Ainsa, CREAF
#'
#' @seealso \code{\link{forest}}, \code{\link{forest_mergeTrees}}, \code{\link{plot.forest}}
#' @seealso \code{\link{forest}}, \code{\link{emptyforest}}
#' @return An object of class \code{\link{forest}}
#' @export
#'
#' @name tree2forest
#' @examples
#'
#' oak_forest <-tree2forest("Quercus ilex", Height= 200, LAI = 2)
#' oak_forest
#'
tree2forest<-function(Species, Height, LAI = NA, N = NA, DBH = NA, Z50 = NA, Z95 = NA,
CrownRatio = NA, FoliarBiomass = NA, FuelLoading = NA) {
Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ reference:
contents:
- spwbInput
- forest2aboveground
- aspwbInput
- starts_with("defaultControl")
- starts_with("defaultManagement")
- starts_with("resetInputs")
Expand Down
4 changes: 2 additions & 2 deletions man/SpParams.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/forest.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/forest2aboveground.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/tree2forest.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/forestutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ NumericVector LAIprofile(NumericVector z, List x, DataFrame SpParams, double gdd
//' Function \code{forest2aboveground()} extracts height and species identity from plant cohorts of \code{x},
//' and calculate leaf area index and crown ratio.
//'
//' \emph{IMPORTANT NOTE}: Function names \code{forest2spwbInput()} and \code{forest2growthInput()} are now deprecated, but
//' \emph{IMPORTANT NOTE}: Function names \code{forest2spwbInput()} and \code{forest2growthInput()} are now internal and deprecated, but
//' they can still be used for back-compatibility. They correspond to functions \code{\link{spwbInput}} and \code{\link{growthInput}}
//'
//' @return
Expand Down Expand Up @@ -1583,6 +1583,7 @@ NumericVector LAIprofile(NumericVector z, List x, DataFrame SpParams, double gdd
//'
//'
//' @name forest2aboveground
//' @keywords internal
// [[Rcpp::export("forest2aboveground")]]
DataFrame forest2aboveground(List x, DataFrame SpParams, double gdd = NA_REAL, bool loading = false) {
DataFrame treeData = Rcpp::as<Rcpp::DataFrame>(x["treeData"]);
Expand Down Expand Up @@ -1649,6 +1650,7 @@ DataFrame forest2aboveground(List x, DataFrame SpParams, double gdd = NA_REAL, b


//' @rdname forest2aboveground
//' @keywords internal
// [[Rcpp::export("forest2belowground")]]
NumericMatrix forest2belowground(List x, DataFrame soil, DataFrame SpParams) {
DataFrame treeData = Rcpp::as<Rcpp::DataFrame>(x["treeData"]);
Expand Down
2 changes: 2 additions & 0 deletions src/modelInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1663,12 +1663,14 @@ List growthInput(List x, DataFrame soil, DataFrame SpParams, List control) {
}

//' @rdname forest2aboveground
//' @keywords internal
// [[Rcpp::export("forest2spwbInput")]]
List forest2spwbInput(List x, DataFrame soil, DataFrame SpParams, List control) {
return(spwbInput(x, soil, SpParams, control));
}

//' @rdname forest2aboveground
//' @keywords internal
// [[Rcpp::export("forest2growthInput")]]
List forest2growthInput(List x, DataFrame soil, DataFrame SpParams, List control) {
return(growthInput(x, soil, SpParams, control));
Expand Down
49 changes: 25 additions & 24 deletions vignettes/intro/PackageOverview.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,31 @@ Changes in forest structure and composition result from the interplay of demogra

An example of simulation with `fordyn()` is provided in article [*Forest dynamics*](https://emf-creaf.github.io/medfate/articles/runmodels/ForestDynamics.html).

## Plots, summaries and post-processing

## Other package functions
Simulation models produce multiple outputs and it is important to learn how to visualize them and extract information for further analysis. Each simulation function returns an output object whose S3 class has the same name as the simulation function (e.g. `spwb()` returns an object of class `spwb`).

+ Implementations of `summary()` and `plot()` are available for simulation output objects, which facilitates displaying and summarizing information.
+ A generic function `shinyplot()` (as well as its implementation for different output objects) allows an interactive exploration of simulation results.
+ Model outputs can be extracted to simple `data.frame` objects through function `extract()`.

Additional package function are meant to be used on simulation results and produce time series of additional (derived) properties:

- `droughtStress()` : Plant/stand drought stress indices
- `waterUseEfficiency()` : Water use efficiency metrics
- `resistances()` : Hydraulic resistances to water transport
- `fireHazard()` : Potential fire behaviour (see below)

## Fuel properties and fire hazard

Vegetation functioning and dynamics have strong, but complex, effects on fire hazard. On one hand, growth and death of organs and individuals changes the amount of standing live and dead fuels, as well as downed dead fuels. On the other, day-to-day changes in soil and plant water content changes the physical properties of fuel, notably fuel moisture content.

Package `medfate` provides functions to estimate fuel properties and potential fire behaviour in forest inventory plots. Specifically, function `fuel_stratification()` estimates the division of live fuels in the stand between understory and canopy strata; and `fuel_FCCS()` calculates fuel characteristics from a `forest` object following an adaptation of the protocols described for the Fuel Characteristics Classification System (Prichard et al. 2013). In FCCS, fuelbed is divided into six strata, including canopy, shrub, herbaceous vegetation, dead woody materials, leaf litter and ground fuels. All except ground fuels are considered here. The intensity of burning depends on several factors, including topography, wind conditions, fuel structure and its moisture content, which is determined from antecedent and current meteorological conditions. A modification of the Rothermel's (1972) model is used in function `fire_FCCS()` to calculate the intensity of surface fire reaction and the rate of fire spread of surface fires assuming a steady-state fire. Both quantities are dependent on fuel characteristics, windspeed and direction, and topographic slope and aspect.


## Internal package functions

Package **medfate** contains many more functions than those visible in reference lists. Since **v.4.3.2** multiple functions are labelled as *internal*, meaning that they are accessible and documented, but they are not visible in reference list, so that the sheer number of functions does not overwhelm users.

### Plant, species and stand attributes

Expand All @@ -63,7 +86,7 @@ The package includes a number of functions to examine properties of the plants c

### Sub-model functions

Many of the functions included in **medfate** are internally called by simulation functions. Some of them are made available to the user to facilitate a deeper understanding the different sub-models and a more creative use of the package, but most users can ignore them. For this reason, since **v.4.3.2** sub-model functions are labelled as *internal*, meaning that they are accessible and documented, but they are not visible in reference list, so that the sheer number of functions does not overwhelm users.
Many of the functions included in **medfate** are internally called by simulation functions. Some of them are made available to the user to facilitate a deeper understanding the different sub-models and a more creative use of the package, but most users can ignore them.

Sub-model functions are grouped by *subject*, which is included in the name of the function. The different sub-model functions are (by subject):

Expand All @@ -83,28 +106,6 @@ Sub-model functions are grouped by *subject*, which is included in the name of t
- `wind_*`: Canopy turbulence.


### Plots, summaries and post-processing

Simulation models produce multiple outputs and it is important to learn how to visualize them and extract information for further analysis. Each simulation function returns an output object whose S3 class has the same name as the simulation function (e.g. `spwb()` returns an object of class `spwb`).

+ Implementations of `summary()` and `plot()` are available for simulation output objects, which facilitates displaying and summarizing information.
+ A generic function `shinyplot()` (as well as its implementation for different output objects) allows an interactive exploration of simulation results.
+ Model outputs can be extracted to simple `data.frame` objects through function `extract()`.

Additional package function are meant to be used on simulation results and produce time series of additional (derived) properties:

- `droughtStress()` : Plant/stand drought stress indices
- `waterUseEfficiency()` : Water use efficiency metrics
- `resistances()` : Hydraulic resistances to water transport
- `fireHazard()` : Potential fire behaviour (see below)

### Fuel properties and fire hazard

Vegetation functioning and dynamics have strong, but complex, effects on fire hazard. On one hand, growth and death of organs and individuals changes the amount of standing live and dead fuels, as well as downed dead fuels. On the other, day-to-day changes in soil and plant water content changes the physical properties of fuel, notably fuel moisture content.

Package `medfate` provides functions to estimate fuel properties and potential fire behaviour in forest inventory plots. Specifically, function `fuel_stratification()` estimates the division of live fuels in the stand between understory and canopy strata; and `fuel_FCCS()` calculates fuel characteristics from a `forest` object following an adaptation of the protocols described for the Fuel Characteristics Classification System (Prichard et al. 2013). In FCCS, fuelbed is divided into six strata, including canopy, shrub, herbaceous vegetation, dead woody materials, leaf litter and ground fuels. All except ground fuels are considered here. The intensity of burning depends on several factors, including topography, wind conditions, fuel structure and its moisture content, which is determined from antecedent and current meteorological conditions. A modification of the Rothermel's (1972) model is used in function `fire_FCCS()` to calculate the intensity of surface fire reaction and the rate of fire spread of surface fires assuming a steady-state fire. Both quantities are dependent on fuel characteristics, windspeed and direction, and topographic slope and aspect.


## Companion packages

During the development of **medfate** some functions have been originally placed there and then moved to more specialized packages which evolve together with **medfate**:
Expand Down

0 comments on commit fdff233

Please sign in to comment.