Compute metrics through time for specific locations.

BEE.calc.metrics_point(
  extreme_event,
  yourspatraster,
  gps,
  start_date = NULL,
  end_date = NULL,
  time_lapse_vector = NULL,
  baseline_qt = NULL,
  baseline_mean = NULL,
  baseline_fixed = NULL,
  group_by_event = FALSE
)

Arguments

extreme_event

: Is the list of data tables produced by: bee.id.extreme_events() (the second element of the output). For each pixel, it contains a data.table with dates in the rows and a column indicating whether it is a day belonging to a heatwave (1) or not (0).

yourspatraster

: Is the spatraster with the values of the studded parameter, through time and space.

gps

: Is a data frame containing the positions for which you want to compute metrics. It must contain columns labelled 'x' and 'y', which should contain longitudes and latitudes, respectively.

start_date

: First day on which you want to start computing metrics. Optional argument.

end_date

: Last day on which you want to start computing metrics. Optional argument.

time_lapse_vector

: A vector of time laps on which to compute mean evolution rate and variance of the studdied parameter. Optional argument.

baseline_qt

: Spatraster of the 90th percentile baseline (or the 10th percentile baseline). Optional argument.

baseline_mean

: Spatraster of the mean value baseline. Optional argument.

baseline_fixed

: A numerical value representing a fixed threshold for which you want to calculate the distance between the observed value and the threshold. Optional argument.

group_by_event

: Whether you want an output summarise by extreme event or not. If not, you just get daily metrics. Optional argument. Use FALSE to be able to use the output in BEE.data.merge().

Value

A list of dataframe (one per gps point), each dataframe contains informations on the date of the extrem events, mean, median, max and min values, peak day, onset-rate, off-set rate, mean anomaly, maximum category etc. Categories are defined in Hobday et al. 2018.

Note

BEE.calc.metrics_point() is not designed to work on 4D data (time + spatial 3D).

Examples

# Prepare function arguments:
file_name_1 <- system.file(file.path("extdata",
                                     "copernicus_data_celsius.tiff"),
                                     package = "BioExtremeEvent")
copernicus_data_celsius <- terra::rast(file_name_1)
file_name_2 <- system.file(file.path("extdata",
                                     "binarized_corrected_df.rds"),
                                     package = "BioExtremeEvent")
extreme_event_list <- readRDS(file_name_2)
file_name_3 <- system.file(file.path("extdata",
                                     "baseline_qt90_smth_15.tiff"),
                                     package = "BioExtremeEvent")
baseline_qt90_smth_15 <- terra::rast(file_name_3)
file_name_4 <- system.file(file.path("extdata",
                                     "baseline_mean_smth_15.tiff"),
                                     package = "BioExtremeEvent")
baseline_mean_smth_15 <- terra::rast(file_name_4)
gps <- data.frame(x = c(3.6883,4.4268), # Sète, Saintes-Marie-de-la-Mer
                  y = c(43.3786,43.4279))

# Get daily value (required for BEE.merge() and BEE.summarise()):
metrics_points_day <- BEE.calc.metrics_point(
 extreme_event = extreme_event_list,
 yourspatraster = copernicus_data_celsius,
 gps = gps,
 start_date = NULL,
 end_date = NULL,
 time_lapse_vector = NULL,
# number of time unit on which to compute the warming rates and cooling rates,
#  NULL means it will not be computated
 baseline_qt = baseline_qt90_smth_15,
 baseline_mean = baseline_mean_smth_15,
 baseline_fixed = 12.5,
 group_by_event = FALSE
)
#> You didn't specify a begining date and a ending date (see argument 
#>       'start_date' and 'end_date'), the first date and last date in your time 
#>       yourspatraster will be used.

# Get mean, min, max, sd and median per event (extreme event and btw extreme
# events):
metrics_points_ee <- BEE.calc.metrics_point(
 extreme_event = extreme_event_list,
 yourspatraster = copernicus_data_celsius,
 gps = gps,
 start_date = NULL,
 end_date = NULL,
 time_lapse_vector = NULL,
# number of time unit on which to compute the warming rates and cooling rates,
#  NULL means it will not be computated
 baseline_qt = baseline_qt90_smth_15,
 baseline_mean = baseline_mean_smth_15,
 group_by_event = TRUE
)
#> You didn't specify a begining date and a ending date (see argument 
#>       'start_date' and 'end_date'), the first date and last date in your time 
#>       yourspatraster will be used.