Functions that allow calling local models spwb, growth or fordyn, for a set of forest stands distributed in specific locations. No spatial processes are simulated.

spwb_spatial(
  sf,
  SpParams,
  meteo = NULL,
  local_control = defaultControl(),
  dates = NULL,
  CO2ByYear = numeric(0),
  keep_results = TRUE,
  summary_function = NULL,
  summary_arguments = NULL,
  parallelize = FALSE,
  num_cores = detectCores() - 1,
  chunk_size = NULL,
  progress = TRUE
)

growth_spatial(
  sf,
  SpParams,
  meteo = NULL,
  local_control = defaultControl(),
  dates = NULL,
  CO2ByYear = numeric(0),
  keep_results = TRUE,
  summary_function = NULL,
  summary_arguments = NULL,
  parallelize = FALSE,
  num_cores = detectCores() - 1,
  chunk_size = NULL,
  progress = TRUE
)

fordyn_spatial(
  sf,
  SpParams,
  meteo = NULL,
  local_control = defaultControl(),
  dates = NULL,
  CO2ByYear = numeric(0),
  keep_results = TRUE,
  management_function = NULL,
  summary_function = NULL,
  summary_arguments = NULL,
  parallelize = FALSE,
  num_cores = detectCores() - 1,
  chunk_size = NULL,
  progress = TRUE
)

Arguments

sf

An object of class sf with the following columns:

  • geometry: Spatial geometry.

  • id: Stand identifiers.

  • elevation: Elevation above sea level (in m).

  • slope: Slope (in degrees).

  • aspect: Aspect (in degrees).

  • land_cover_type: Land cover type of each grid cell (values should be 'wildland' or 'agriculture').

  • forest: Objects of class forest.

  • soil: Objects of class soil or data frames of physical properties.

  • state: Objects of class spwbInput or growthInput (optional).

  • meteo: Data frames with weather data (required if parameter meteo = NULL).

  • crop_factor: Crop evapo-transpiration factor. Only required for 'agriculture' land cover type.

  • management_arguments: Lists with management arguments (optional, relevant for fordyn_spatial only).

SpParams

A data frame with species parameters (see SpParamsMED).

meteo

Input meteorological data (see section details). If NULL, the function will expect a column 'meteo' in parameter y.

local_control

A list of control parameters (see defaultControl) for function spwb_day or growth_day.

dates

A Date object describing the days of the period to be modeled.

CO2ByYear

A named numeric vector with years as names and atmospheric CO2 concentration (in ppm) as values. Used to specify annual changes in CO2 concentration along the simulation (as an alternative to specifying daily values in meteo).

keep_results

Boolean flag to indicate that point/cell simulation results are to be returned (set to FALSE and use summary functions for large data sets).

summary_function

An appropriate function to calculate summaries (e.g., summary.spwb).

summary_arguments

List with additional arguments for the summary function.

parallelize

Boolean flag to try parallelization (will use all clusters minus one).

num_cores

Integer with the number of cores to be used for parallel computation.

chunk_size

Integer indicating the size of chuncks to be sent to different processes (by default, the number of spatial elements divided by the number of cores).

progress

Boolean flag to display progress information for simulations.

management_function

A function that implements forest management actions (see fordyn). of such lists, one per spatial unit.

Value

An object of class 'sf' containing four elements:

  • geometry: Spatial geometry.

  • id: Stand id, taken from the input.

  • state: A list of spwbInput or growthInput objects for each simulated stand, to be used in subsequent simulations (see update_landscape) or with NULL values whenever simulation errors occurred.

  • forest: A list of forest objects for each simulated stand (only in function fordyn_spatial), to be used in subsequent simulations (see update_landscape) or with NULL values whenever simulation errors occurred.

  • management_arguments: A list of management arguments for each simulated stand (only in function fordyn_spatial if management function was supplied), to be used in subsequent simulations (see update_landscape).

  • result: A list of model output for each simulated stand. Some elements can contain an error condition if the simulation resulted in an error. Values will be NULL (or errors) if keep_results = FALSE.

  • summary: A list of model output summaries for each simulated stand (if summary_function was not NULL), with NULL values whenever simulation errors occurred.

Details

Simulation functions accept different formats for meteorological input (parameter meteo). The user may supply two kinds of daily weather sources:

  1. A data frame with meteorological data common for all spatial location (spatial variation of weather not considered).

  2. An object of class stars with interpolation data, created by package meteoland.

Alternatively, the user may leave parameter meteo = NULL and specify a weather data frame for each element of y in a column named 'meteo'.

Author

Miquel De Cáceres Ainsa, CREAF

Examples

if (FALSE) {
# Load example landscape data
data("example_ifn")
  
# Load example meteo data frame from package meteoland
data("examplemeteo")
  
# Load default medfate parameters
data("SpParamsMED")
  
# Perform simulation
dates <- seq(as.Date("2001-03-01"), as.Date("2001-03-15"), by="day")
res <- spwb_spatial(example_ifn, SpParamsMED, examplemeteo, dates = dates)
  
# Generate summaries (these could have also been specified when calling 'spwbspatial')
res_sum <- simulation_summary(res, summary_function = summary.spwb, freq="month")

# Plot summaries
plot_summary(res_sum, "Transpiration", "2001-03-01")

# Fordyn simulation for one year (one stand) without management
res_noman <- fordyn_spatial(example_ifn[1,], SpParamsMED, examplemeteo)

# Add management arguments to all stands
example_ifn$management_arguments <- vector("list", nrow(example_ifn))
for(i in 1:nrow(example_ifn)) example_ifn$management_arguments[[i]] <- defaultManagementArguments()

# Change thinning threshold for stand #1
example_ifn$management_arguments[[1]]$thinningThreshold <- 15

# Fordyn simulation for one year (one stand) with management
res_man <- fordyn_spatial(example_ifn[1,], SpParamsMED, examplemeteo,
                          management_function = defaultManagementFunction)

# Compare table of cuttings with vs. without management
res_noman$result[[1]]$CutTreeTable
res_man$result[[1]]$CutTreeTable
}