R/bee_id_extreme_day.R
BEE.id.extreme_day.RdThe function binarise a Spatraster by comparing the observed value with the baseline. If "direction" argument is "above", the values above the baseline will be converted to 1, and the value bellow baseline will be converted to 0. The process works in reverse when "direction" = below.
BEE.id.extreme_day(yourspatraster, baseline, direction): The Spatraster containing the values of the studied parameter, with one layer for each timestep.
: A Spatraster built using the BEE.calc.baseline function, which contains the baseline value for each pixel on a given day of the year (with 366 layers), or a fixed threshold that you want to use as the baseline. The fixed threshold must be a number.
: The accepted values for this argument are "above" or "below". This tells the function whether it values above baseline or below baseline are to be considered as extreme events.
The function returns a list containing a Spatraster for each day of a typical year, providing a total of 366 Spatrasters, with one layer per year. The first element of the list contains the rasters for all the first of January included in the provided time series. These rasters have the same properties as 'yourspatraster', but the values have been replaced with 1 if the pixel value was more extreme than the baseline, and with 0 if it was not.
For computational purposes in the next stages of the pipeline, the order of the layers differs from that in 'yourspatraster'. BEE.id.extreme_day is not designed to work with 4D data (3D in space and time). To do so, please refer to BEE.calc.4thD. This function only identifies days more extreme than a baseline, extra criteria to identify extreme event (e.g. minimum duration) will be apply in the BEE.id.extreme_events() function (next one in the framwork).
# Load data:
## Time series of sea surface temperature in the Gulf of Lion (France)
# between January 2023 and 31 December 2025:
file_name_1 <- system.file(file.path("extdata", "copernicus_data_celsius.tiff"),
package = "BioExtremeEvent")
copernicus_data <- terra::rast(file_name_1)
## Baseline of the sea surface temperature between January 2023 and December
# 2025 in the Gulf of Lion (France) computed using the BEE.calc.baseline()
# function, with the following the arguments quantile_value = 0.9,
# time_window = 5, smooth_window = 7. The baseline :
file_name_2 <- system.file(file.path("extdata", "baseline_qt90_smth_15.tiff"),
package = "BioExtremeEvent")
baseline_qt90 <- terra::rast(file_name_2)
# Identify the days on which the values are higher than the baseline for the
# 90th percentile.:
extreme_day <- BEE.id.extreme_day(yourspatraster=copernicus_data,
baseline=baseline_qt90,
direction = "above")
# Identify days on which the value is lower than a fixed threshold.
extreme_day <- BEE.id.extreme_day(yourspatraster=copernicus_data,
baseline=12,
direction = "below")