| Title: | Simulate Tree Light Transmission Using Ray-Tracing |
|---|---|
| Description: | Provides tools to simulate light transmission in forest stands using three-dimensional ray-tracing. The package allows users to build virtual stands from tree inventories and to estimate (1) light intercepted by individual trees, (2) light reaching the forest floor, and (3) light at virtual sensors. The package is designed for ecological and forestry applications, including the analysis of light competition, tree growth, and forest regeneration. The implementation builds on the individual-based ray-tracing model SamsaraLight developed by Courbaud et al. (2003) <doi:10.1016/S0168-1923(02)00254-X>. |
| Authors: | Natheo Beauchamp [aut, cre] (R package developer, ORCID: <https://orcid.org/0009-0007-9103-5194>), Gauthier Ligot [aut] (Java Capsis developer and algorithm improvement, ORCID: <https://orcid.org/0000-0002-5508-4358>), Francois de Coligny [aut] (Java Capsis developer, ORCID: <https://orcid.org/0000-0002-8538-3009>), Maxime Jaunatre [aut] (R package support developer, ORCID: <https://orcid.org/0009-0002-2816-1677>), Benoit Courbaud [aut, cph] (Algorithm and theory creator, ORCID: <https://orcid.org/0000-0002-3050-9559>) |
| Maintainer: | Natheo Beauchamp <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.1.0 |
| Built: | 2026-11-23 16:49:43 UTC |
| Source: | https://github.com/cran/SamsaRaLight |
This function checks whether a data frame contains valid planar
coordinates (x, y) or geographic coordinates (lon, lat).
If geographic coordinates are detected, the user is informed that
they must be converted to a planar coordinate system using
create_xy_from_lonlat().
check_coordinates(df, verbose = TRUE)check_coordinates(df, verbose = TRUE)
df |
A data.frame containing spatial coordinates. |
verbose |
Logical. If TRUE, informative messages are printed. |
Logical. Invisibly returns TRUE if coordinates must be converted
from longitude/latitude to planar coordinates, and FALSE
if planar coordinates are already present.
df_xy <- data.frame(x = 1:3, y = 4:6) check_coordinates(df_xy) df_lonlat <- data.frame(lon = c(10, 11), lat = c(45, 46)) check_coordinates(df_lonlat, verbose = TRUE)df_xy <- data.frame(x = 1:3, y = 4:6) check_coordinates(df_xy) df_lonlat <- data.frame(lon = c(10, 11), lat = c(45, 46)) check_coordinates(df_lonlat, verbose = TRUE)
This function checks whether a tree inventory data.frame is correctly formatted to be used as input for the ray-tracing model. It verifies the presence, type, and validity of mandatory and optional variables describing the geometry and attributes of trees within a forest stand.
check_inventory(trees_inv, verbose = TRUE)check_inventory(trees_inv, verbose = TRUE)
trees_inv |
A data.frame with one row per tree and the following columns:
|
verbose |
Logical; if |
The function performs the following checks and validations:
Ensures trees_inv is a non-empty data.frame with all required columns.
Checks that id_tree values are unique.
Checks that either planar coordinates (x, y) or geographic coordinates
(lon, lat) are provided. If only lon and lat are supplied, they are converted to planar UTM coordinates in create_sl_stand().
The plot_inventory() function requires planar coordinates and cannot be used before this conversion.
Validates numeric columns (dbh_cm, h_m, hbase_m, rn_m, rs_m, re_m, rw_m) are numeric and non-negative.
Verifies that crown_type values are one of "E", "P", "2E", "8E", or "4P".
Ensures crown radii are present according to crown type.
Checks that hmax_m is provided when required and lies between hbase_m and h_m.
Ensures hbase_m < h_m.
Verifies that each tree has the crown LAD defined.
Provides informative error messages and warnings for all invalid conditions.
Invisibly returns TRUE if all checks pass.
# Using the example dataset from the package data_prenovel <- SamsaRaLight::data_prenovel trees <- data_prenovel$trees # Check the inventory check_inventory(trees) # Quiet mode check_inventory(trees, verbose = FALSE)# Using the example dataset from the package data_prenovel <- SamsaRaLight::data_prenovel trees <- data_prenovel$trees # Check the inventory check_inventory(trees) # Quiet mode check_inventory(trees, verbose = FALSE)
Checks that a monthly radiation data.frame is correctly formatted and physically valid for use by the light interception and ray-tracing model. The table must contain exactly 12 months of radiation data.
check_monthly_radiations(x, verbose = TRUE)check_monthly_radiations(x, verbose = TRUE)
x |
A data.frame with monthly radiation values, typically produced by
|
verbose |
Logical; if |
The input must contain the following columns:
Integer month number (1-12)
Monthly global horizontal irradiation (MJ/m2)
Diffuse-to-global radiation ratio (unitless, 0-1)
The function checks:
The object is a data.frame.
Required columns are present.
There are exactly 12 months.
Each month (1-12) is present exactly once.
Data are numeric and finite.
Hrad strictly positive.
DGratio between 0 and 1.
Months are in increasing order.
Invisibly returns TRUE if all checks pass.
# Using the example dataset from the package data_prenovel <- SamsaRaLight::data_prenovel radiations <- data_prenovel$radiations # Check the inventory check_monthly_radiations(radiations) # Quiet mode check_monthly_radiations(radiations, verbose = FALSE)# Using the example dataset from the package data_prenovel <- SamsaRaLight::data_prenovel radiations <- data_prenovel$radiations # Check the inventory check_monthly_radiations(radiations) # Quiet mode check_monthly_radiations(radiations, verbose = FALSE)
This function converts a data.frame of polygon vertices into an sf POLYGON and checks its validity. If the polygon is invalid, it attempts to fix it.
check_polygon(core_polygon_df, trees_inv, sensors = NULL, verbose = TRUE)check_polygon(core_polygon_df, trees_inv, sensors = NULL, verbose = TRUE)
core_polygon_df |
A data.frame with columns x and y defining polygon vertices |
trees_inv |
A data.frame with one row per tree. See check_inventory for the required structure and validated columns. |
sensors |
Optional data.frame defining position and height of the sensor within the stand. See check_sensors for the required structure and validated columns. |
verbose |
Logical. If TRUE, warnings are printed |
A data.frame of polygon vertices (x, y):
unchanged if valid
modified if fixed (with a warning)
data_prenovel <- SamsaRaLight::data_prenovel # Validate polygon check_polygon(data_prenovel$core_polygon, data_prenovel$trees)data_prenovel <- SamsaRaLight::data_prenovel # Validate polygon check_polygon(data_prenovel$core_polygon, data_prenovel$trees)
This function checks whether a sensor data.frame is correctly formatted to be used as input for the ray-tracing model. It verifies the presence, type, and validity of mandatory variables describing the position and height of sensors within a forest stand.
check_sensors(sensors, verbose = TRUE)check_sensors(sensors, verbose = TRUE)
sensors |
A data.frame with one row per sensor and the following columns:
|
verbose |
Logical; if TRUE, informative messages are printed. |
Invisibly returns TRUE if all checks pass.
sensors <- data.frame( id_sensor = 1:3, x = c(10, 20, 30), y = c(5, 15, 25), h_m = c(1.5, 2.0, 1.8) ) check_sensors(sensors)sensors <- data.frame( id_sensor = 1:3, x = c(10, 20, 30), y = c(5, 15, 25), h_m = c(1.5, 2.0, 1.8) ) check_sensors(sensors)
This function builds a virtual forest stand from a user-provided tree inventory. The inventory zone (core polygon) can optionally be modified (e.g., replaced by an enclosing rectangle or an axis-aligned rectangle) before constructing the stand. Trees are spatially shifted so that the resulting inventory zone is centered within a regular grid of square cells. Optionally, additional trees can be added around the core inventory area to match its basal area per hectare.
create_sl_stand( trees_inv, cell_size, latitude, slope, aspect, north2x, sensors = NULL, core_polygon_df = NULL, modify_polygon = c("none", "rect", "aarect"), fill_around = FALSE, verbose = TRUE )create_sl_stand( trees_inv, cell_size, latitude, slope, aspect, north2x, sensors = NULL, core_polygon_df = NULL, modify_polygon = c("none", "rect", "aarect"), fill_around = FALSE, verbose = TRUE )
trees_inv |
A data.frame with one row per tree. See check_inventory for the required structure and validated columns. |
cell_size |
Numeric. Side length of square cells composing the stand (meters). |
latitude |
Numeric. Latitude of the stand (degrees). |
slope |
Numeric. Slope of the plot (degrees). |
aspect |
Numeric. Aspect of the slope, defined as the azimuth of the downslope direction, clockwise from North (degrees). (0 degrees: North-facing slope, 90 degrees: East-facing slope, 180 degrees: South-facing slope, 270 degrees: West-facing slope) |
north2x |
Numeric. Clockwise angle from North to the X-axis (degrees). The default 90 degrees corresponds to a Y-axis oriented toward true North (0 degrees: x-axis points North, 90 degrees: x-axis points East, 180 degrees: x-axis points South, 270 degrees: x-axis points West). |
sensors |
Optional data.frame defining position and height of the sensor within the stand. See check_sensors for the required structure and validated columns. |
core_polygon_df |
Optional data.frame defining the core inventory polygon.
Must contain columns |
modify_polygon |
Character. Defines how the inventory polygon is modified. One of:
|
fill_around |
Logical. If |
verbose |
Logical. If |
The function supports sloping terrain and coordinate system rotation, and returns a fully prepared stand ready for use in the ray-tracing pipeline (see run_sl).
The returned trees data.frame conforms to the inventory format checked
by check_inventory, with the following controlled modifications:
Tree vertical position z is computed from terrain slope and aspect.
Crown maximum radius height hmax_m is computed when fixed by crown
geometry conventions:
"P" and "4P": hmax_m = hbase_m
"E": hmax_m = hbase_m + 0.5 * (h_m - hbase_m)
For crown types "2E" and "8E", hmax_m must be provided by the user.
For symmetric crown types ("P", "E", "2E"), a unique crown
radius is computed as the mean of the provided radii (rn_m, rs_m,
re_m, rw_m; NA values ignored).
If missing, column crown_openness is added and filled with
NA (only needed when turbid_medium = FALSE).
If missing, column crown_lad is added and filled with
NA (only needed when turbid_medium = TRUE, the default).
All input data.frames (trees_inv, sensors, and core_polygon_df) are
automatically checked for coordinate type:
If x and y columns exist, they are assumed to be planar.
If lon and lat columns exist, they are converted into
planar UTM coordinates automatically using create_xy_from_lonlat().
The UTM projection (EPSG) is determined from the mean coordinates of
trees_inv. All inputs must share the same EPSG; otherwise, the
function stops with an error. If conversion occurred, the EPSG is stored in the output.
The function ensures that all trees fall within the core inventory polygon, applying small buffers if necessary to handle numerical precision issues. Invalid polygons are automatically repaired when possible.
When fill_around = TRUE, trees are randomly sampled from the original
inventory and positioned outside the core polygon until the target basal area
per hectare is reached for the full stand.
A named list with the following elements:
treesData.frame of the final tree inventory, including added trees if
fill_around = TRUE.
The structure matches the inventory format validated by
check_inventory, with additional derived variables required
for ray tracing. A logical column added_to_fill indicates whether
each tree originates from the initial inventory or was added to fill
around the inventory zone.
core_polygonList describing the inventory zone:
df: data.frame of polygon vertices
sf: corresponding sf POLYGON
modify_polygon: applied polygon modification
transformList of transformation and filling information, including core area, target and final basal area, number of added trees, and applied spatial transformations.
geometryList describing stand geometry and terrain parameters (cell size, number of cells, slope, aspect, and orientation).
data_prenovel <- SamsaRaLight::data_prenovel trees_inv <- data_prenovel$trees stand <- create_sl_stand( trees_inv = trees_inv, cell_size = 10, latitude = 46.52666, slope = 6, aspect = 144, north2x = 54 )data_prenovel <- SamsaRaLight::data_prenovel trees_inv <- data_prenovel$trees stand <- create_sl_stand( trees_inv = trees_inv, cell_size = 10, latitude = 46.52666, slope = 6, aspect = 144, north2x = 54 )
This function converts geographic coordinates (lon, lat)
into planar coordinates (x, y)
using an automatically selected UTM projection.
create_xy_from_lonlat(df)create_xy_from_lonlat(df)
df |
A data.frame containing geographic coordinates ( |
The input data.frame must contain geographic coordinates (lon and lat).
Planar coordinates (x, y) are automatically computed using the
UTM zone inferred from the mean longitude and hemisphere inferred from the mean latitude.
A list with the following elements:
dfThe input data.frame with added x and y columns (meters, UTM).
epsgEPSG code of the UTM projection used.
# Example data with longitude / latitude (WGS84) df <- data.frame( lon = c(4.35, 4.36), lat = c(50.85, 50.86) ) # Convert to planar coordinates (UTM) res <- create_xy_from_lonlat(df) # Access results res$df # data.frame with x, y columns res$epsg # EPSG code used# Example data with longitude / latitude (WGS84) df <- data.frame( lon = c(4.35, 4.36), lat = c(50.85, 50.86) ) # Convert to planar coordinates (UTM) res <- create_xy_from_lonlat(df) # Access results res$df # data.frame with x, y columns res$epsg # EPSG code used
Compute bottom azimut
get_bottom_azimut(aspect, north2x)get_bottom_azimut(aspect, north2x)
aspect |
double - Angle of slope bottom on the compass from the North, clockwise rotation (in degrees) northern aspect : 0, eastern aspect : 90, southern aspect : 180, western aspect : 270 |
north2x |
double - Angle from North to x axis clockwise. (in degrees) Default correspond to a Y axis oriented toward the North. |
a bottom azimuth numeric value
Fetch monthly radiation data from PVGIS website (by API) between start and end year (limit years are from 2005 to 2020). Fetched variables are Hrad = horizontal plane irradiation and DGratio = ratio of diffuse to global radiation (in horizontal plane).
! YOU NEED AN INTERNET CONNECTION TO ACCESS THE DATA BY API !
get_monthly_radiations(latitude, longitude, start_year = 2005, end_year = 2020)get_monthly_radiations(latitude, longitude, start_year = 2005, end_year = 2020)
latitude |
latitude of the plot |
longitude |
longitude of the plot |
start_year |
positive integer between 2005 and 2020 - start year on which to fetch monthly data |
end_year |
positive integer between 2005 and 2020 - end year on which to fetch monthly data |
Monthly horizontal radiation (Hrad) and diffuse to global ratio (DGratio) averaged between start_year and end_year
https://joint-research-centre.ec.europa.eu/pvgis-photovoltaic-geographical-information-system_en
# Example: fetch monthly radiation somewhere in Belgium rad <- get_monthly_radiations( latitude = 50.85, longitude = 4.35, start_year = 2010, end_year = 2015 ) head(rad)# Example: fetch monthly radiation somewhere in Belgium rad <- get_monthly_radiations( latitude = 50.85, longitude = 4.35, start_year = 2010, end_year = 2015 ) head(rad)
Compute z coordinate of a point (x,y).
get_z(x, y, slope_rad, bottom_azimut_rad)get_z(x, y, slope_rad, bottom_azimut_rad)
x |
X-coordinate of the point |
y |
Y-coordinate of the point |
slope_rad |
Slope of the stand (in radians) |
bottom_azimut_rad |
Azimuth of the vector orthogonal to the ground in the x,y system (in radians) |
a z coordinate numeric value
Visualizes a forest inventory as ellipses representing tree crowns.
plot_inventory(trees_inv, core_polygon_df = NULL, show_id = TRUE)plot_inventory(trees_inv, core_polygon_df = NULL, show_id = TRUE)
trees_inv |
A data.frame of trees that passed check_inventory. |
core_polygon_df |
Optional data.frame defining the core inventory polygon.
Must contain columns |
show_id |
Logical; if TRUE (default), displays tree identifiers at crown centers. |
Because the north2x variable is unknown, trees are plotted as circles by considering the mean radius on the four cardinals.
A ggplot object displaying the trees in a from-above view.
data_prenovel <- SamsaRaLight::data_prenovel trees_inv <- data_prenovel$trees plot_inventory(trees_inv)data_prenovel <- SamsaRaLight::data_prenovel trees_inv <- data_prenovel$trees plot_inventory(trees_inv)
Visualize ground light and tree energy metrics for a sl_output object.
## S3 method for class 'sl_output' plot( x, ..., what_trees = c("compet", "compet_rays", "intercepted", "potential"), what_cells = c("relative", "absolute"), show_trees = TRUE, direct_energy = NULL )## S3 method for class 'sl_output' plot( x, ..., what_trees = c("compet", "compet_rays", "intercepted", "potential"), what_cells = c("relative", "absolute"), show_trees = TRUE, direct_energy = NULL )
x |
An object of class |
... |
Additional arguments passed to lower-level plotting functions. |
what_trees |
Character; which tree metric to plot. Choices are:
Default is "compet". |
what_cells |
Character; which cell (ground) metric to plot. Choices are:
Default is "relative". |
show_trees |
Logical; whether to display trees on top of the ground light map. Default is TRUE. |
direct_energy |
Logical or NULL.
If NULL (default), total radiation outputs are plotted (direct + diffuse).
If TRUE, only direct radiation components are plotted.
If FALSE, only diffuse radiation components are plotted.
This option requires |
A ggplot object.
This function plots a virtual forest stand (sl_stand) produced by SamsaRaLight.
It can display a top-down view with tree crowns or a side/top view with cells and trees.
## S3 method for class 'sl_stand' plot(x, ..., top_down = FALSE, only_inv = FALSE, add_sensors = TRUE)## S3 method for class 'sl_stand' plot(x, ..., top_down = FALSE, only_inv = FALSE, add_sensors = TRUE)
x |
An object of class |
... |
Additional arguments passed to lower-level plotting functions. |
top_down |
Logical, if TRUE, creates a top-down view with multiple directions (south, north, west, east). |
only_inv |
Logical, if TRUE, plot only trees from the initial inventory (i.e. not trees added to fill around the core polygon) |
add_sensors |
Logical; if TRUE (default), sensors are drawn on the plot. In top-down mode, sensors are shown as segment from ground to their height; in map view, sensors are drawn as squares on the ground. |
For the sake of the representation in top-down plot, z are offset such as minimum altitude tree is at Y-axis height = 0
The plot function also generates a compass indicating:
Plot orientation (north2x, north in red)
Terrain aspect (downslope direction)
Slope degrees (annotation only)
A ggplot object representing the stand.
sl_output objectPrints a concise one-line summary of a SamsaRaLight simulation result, reporting the number of cells, trees, and sensors, and whether detailed outputs are available.
## S3 method for class 'sl_output' print(x, ...)## S3 method for class 'sl_output' print(x, ...)
x |
An object of class |
... |
Further arguments passed to or from other methods (ignored). |
The object x, invisibly.
sl_stand objectPrints a compact, human-readable, one-line description of a
sl_stand object, summarizing the stand size, number of trees,
number of sensors, and grid geometry.
## S3 method for class 'sl_stand' print(x, ...)## S3 method for class 'sl_stand' print(x, ...)
x |
An object of class |
... |
Unused. Included for S3 method compatibility. |
This method is automatically called when a sl_stand object
is printed in the console.
The input object x, invisibly.
Computes light interception and radiative balance for a forest stand using the SamsaRaLight ray-tracing engine.
run_sl( sl_stand, monthly_radiations, sensors_only = FALSE, detailed_output = FALSE, parallel_mode = FALSE, n_threads = NULL, verbose = TRUE )run_sl( sl_stand, monthly_radiations, sensors_only = FALSE, detailed_output = FALSE, parallel_mode = FALSE, n_threads = NULL, verbose = TRUE )
sl_stand |
An object of class |
monthly_radiations |
A data frame containing monthly horizontal
radiation ( |
sensors_only |
Logical. If |
detailed_output |
Logical. If |
parallel_mode |
Logical. If |
n_threads |
Integer or |
verbose |
Logical. If |
This function is the standard user interface to SamsaRaLight. Advanced ray-tracing, sky-discretization, and interception parameters are internally set to standard values and do not need to be provided.
Internally, run_sl() calls run_sl_advanced using standard
ray-tracing, sky-discretization, and interception parameters:
torus borders are enabled;
crowns are represented as turbid media;
the leaf extinction coefficient is 0.5;
the clumping factor is 1;
trunk interception is enabled;
the minimum ray altitude angle is 10 degrees;
direct rays use a starting offset of 0 degrees and an
angular step of 5 degrees;
diffuse rays use an angular step of 15 degrees;
the Standard Overcast Sky model is used;
the full year (days 1–365) is simulated.
These defaults are intended for standard SamsaRaLight simulations. Users requiring control over these parameters can use run_sl_advanced directly.
When parallel_mode = TRUE, SamsaRaLight uses OpenMP to parallelise
ray–target computations. BLAS is configured to use a single thread during
the simulation to avoid competing parallel execution.
An object of class "sl_output" (a list) containing:
output: A list containing the simulation results:
light: A list containing light-interception results for
trees, ground cells, and sensors.
monthly_rays: The monthly ray discretization and
associated radiation energies. Returned only when
detailed_output = TRUE.
interceptions: Detailed interception matrices. Returned
only when detailed_output = TRUE.
params: A list containing the simulation parameters,
including the simulated period, sky model, ray-discretization
parameters, and interception-model parameters.
input: A list containing the original sl_stand and
monthly_radiations objects.
When detailed_output = FALSE, the main output tables contain:
light$sensors: id_sensor, e, pacl,
and punobs;
light$cells: id_cell, e, pacl,
and punobs;
light$trees: id_tree, epot, e,
lci, eunobs, and rci.
create_sl_stand, check_inventory, check_sensors, get_monthly_radiations, check_monthly_radiations, run_sl_advanced
data_prenovel <- SamsaRaLight::data_prenovel stand <- create_sl_stand( trees_inv = data_prenovel$trees, sensors = data_prenovel$sensors, cell_size = 10, latitude = data_prenovel$info$latitude, slope = data_prenovel$info$slope, aspect = data_prenovel$info$aspect, north2x = data_prenovel$info$north2x ) out <- run_sl( sl_stand = stand, monthly_radiations = data_prenovel$radiations ) str(out)data_prenovel <- SamsaRaLight::data_prenovel stand <- create_sl_stand( trees_inv = data_prenovel$trees, sensors = data_prenovel$sensors, cell_size = 10, latitude = data_prenovel$info$latitude, slope = data_prenovel$info$slope, aspect = data_prenovel$info$aspect, north2x = data_prenovel$info$north2x ) out <- run_sl( sl_stand = stand, monthly_radiations = data_prenovel$radiations ) str(out)
Runs the full light interception and radiative balance simulation for a virtual forest stand with advanced ray-tracing and interception parameters. This function provides full control over ray discretization, sky model, crown interception model, trunk interception, and parallel computation.
run_sl_advanced( sl_stand, monthly_radiations, sensors_only = FALSE, use_torus = TRUE, turbid_medium = TRUE, extinction_coef = 0.5, clumping_factor = 1, trunk_interception = TRUE, height_anglemin = 10, direct_startoffset = 0, direct_anglestep = 5, diffuse_anglestep = 15, soc = TRUE, start_day = 1, end_day = 365, detailed_output = FALSE, parallel_mode = FALSE, n_threads = NULL, verbose = TRUE )run_sl_advanced( sl_stand, monthly_radiations, sensors_only = FALSE, use_torus = TRUE, turbid_medium = TRUE, extinction_coef = 0.5, clumping_factor = 1, trunk_interception = TRUE, height_anglemin = 10, direct_startoffset = 0, direct_anglestep = 5, diffuse_anglestep = 15, soc = TRUE, start_day = 1, end_day = 365, detailed_output = FALSE, parallel_mode = FALSE, n_threads = NULL, verbose = TRUE )
sl_stand |
An object of class |
monthly_radiations |
A data frame containing monthly horizontal
radiation ( |
sensors_only |
Logical. If |
use_torus |
Logical. If |
turbid_medium |
Logical. If |
extinction_coef |
Numeric scalar. Leaf extinction coefficient
controlling the attenuation of radiation by foliage. It represents the
effective light attenuation per unit leaf area and is related to average
leaf orientation. Higher values increase light interception. Defaults to
|
clumping_factor |
Numeric scalar controlling the aggregation of foliage
within the crown volume. A value of |
trunk_interception |
Logical. If |
height_anglemin |
Numeric. Minimum altitude angle of rays, in degrees.
Defaults to |
direct_startoffset |
Numeric. Starting angle of the first direct ray,
in degrees. Defaults to |
direct_anglestep |
Numeric. Angular step between direct rays, in
degrees. Defaults to |
diffuse_anglestep |
Numeric. Angular step between diffuse rays, in
degrees. Defaults to |
soc |
Logical. If |
start_day |
Numeric. First day of the simulated vegetative period,
between 1 and 365. Defaults to |
end_day |
Numeric. Last day of the simulated vegetative period,
between 1 and 365. Must be greater than or equal to |
detailed_output |
Logical. If |
parallel_mode |
Logical. If |
n_threads |
Integer or |
verbose |
Logical. If |
For typical use, see run_sl, which provides standard values for the ray-discretization parameters.
This advanced function exposes all ray-tracing parameters used by
create_sl_rays and the interception model used by the
underlying C++ simulation. It is intended for users who need fine control
over ray discretization, sky conditions, crown representation, or
computational settings.
Before running the simulation, the function validates the stand, monthly radiation data, interception-model configuration, logical and numeric parameters, simulation period, and number of OpenMP threads.
BLAS and OpenMP thread counts are configured to avoid competing parallel
execution. When parallel_mode = TRUE, the number of OpenMP threads
can be controlled with n_threads.
For most users, run_sl is recommended because it provides standard ray-discretization parameters.
An object of class "sl_output" (a list) containing:
output: A list containing the simulation results:
light: Light-interception results for trees, cells,
and sensors. When detailed_output = FALSE, these contain
the main output metrics only.
monthly_rays: The generated monthly ray discretization
and associated radiation energies. Returned only when
detailed_output = TRUE.
interceptions: Detailed tree/cell interception
matrices. Returned only when detailed_output = TRUE.
params: A list containing the simulation parameters,
including the simulated period, sky model, ray discretization,
crown interception model, and interception parameters.
input: A list containing the original sl_stand and
monthly_radiations objects.
When detailed_output = FALSE, the main output tables contain:
light$sensors: id_sensor, e, pacl,
and punobs;
light$cells: id_cell, e, pacl,
and punobs;
light$trees: id_tree, epot, e,
lci, eunobs, and rci.
These datasets provide example forest inventories used for light interception
simulations with the SamsaRaLight package. Each dataset is a named list
with 5 elements: trees, sensors, core_polygon, radiations, and info.
data(data_prenovel) data(data_IRRES1) data(data_bechefa) data(data_cloture20) data_prenovel data_IRRES1 data_bechefa data_cloture20data(data_prenovel) data(data_IRRES1) data(data_bechefa) data(data_cloture20) data_prenovel data_IRRES1 data_bechefa data_cloture20
A named list with 5 elements:
A data.frame with tree-level data:
Unique id of the tree (integer).
Latin species name (character).
Coordinates of the base of the tree in meters (numeric).
Diameter at breast height in cm (numeric).
Crown shape type, e.g. "P", "E", or complex types like "8E" (character).
Height of the tree trunk in meters (numeric).
Height of crown base in meters (numeric).
Height at which crown radius is maximum, NA if not used (numeric).
Crown radii in meters (numeric).
Leaf area density of the crown (m2/m3) (numeric).
A data.frame with sensor data:
Unique sensor ID (integer).
Coordinates of the sensor in meters (numeric).
Height of the sensor in meters (numeric).
Proportion of above-canopy light measured at the sensor (numeric).
May be NULL if no sensors are present.
A data.frame with vertices of the inventory polygon:
Coordinates of polygon vertices in meters (numeric).
A data.frame of monthly radiation:
Month number (integer).
Monthly radiation in MJ (numeric).
Diffuse-to-global radiation ratio (numeric).
A named list with site information:
Coordinates of the site in decimal degrees (numeric).
Mean slope in degrees (numeric).
Aspect in degrees from north (numeric).
Angle from north to x-axis clockwise in degrees (numeric).
An object of class list of length 5.
An object of class list of length 5.
An object of class list of length 5.
An object of class list of length 5.
Courbaud Benoit (INRAe LESSEM Grenoble)
Gauthier Ligot (Gembloux Agro-Bio Tech)
Gauthier Ligot (Gembloux Agro-Bio Tech)
Gauthier Ligot (Gembloux Agro-Bio Tech)
Summary of a SamsaRaLight simulation
## S3 method for class 'sl_output' summary(object, ...)## S3 method for class 'sl_output' summary(object, ...)
object |
an object of class |
... |
unused |
A list containing summary statistics of the simulation output, including tree-level intercepted light and stand-level incident light.
Summary of a SamsaRaLight stand
## S3 method for class 'sl_stand' summary(object, ...)## S3 method for class 'sl_stand' summary(object, ...)
object |
A |
... |
Unused |
Invisibly returns a list of summary tables