sewsnet_predict: S-EWSNet Predict

View source: R/sewsnet_predict.R

sewsnet_predictR Documentation

S-EWSNet Predict

Description

Communicates with S-EWSNet (https://doi.org/10.1098/rsos.231767), a deep learning framework for modelling and anticipating regime shifts in dynamical spatial systems, and returns the model's prediction for the inputted spatial time series.

Usage

sewsnet_predict(
  x,
  id = NULL,
  envname,
  delta = 0.1,
  inp_size = 25,
  model_path = default_sewsnet_path()
)

Arguments

x

A list of square integer matrices representing presence/absence pixels. Pixels could be vegetation presence. Ensure entires are integers not numeric.

id

Vector identifying each entry in x. Could be year, plot identity etc.

envname

A string naming the Python environment prepared by ewsnet_init().

delta

Numeric. Difference in densities.

inp_size

Numeric. Size of clipped Fourier transformed square matrix.

model_path

A string naming the path to the S-EWSnet model installed by sewsnet_reset().

Value

A dataframe of S-EWSNet predictions. Values represent the estimated probability that the quoted event will occur.

Source

Deb, S., Ekansh, M., Paras, G. et al. (2024) Optimal sampling of spatial patterns improves deep learning-based early warning signals of critical transitions. Royal Society Open Science. 11, 231767.

Examples

#A dummy dataset of a patchy savanna
#monitored over 10 sites/years.

vegetation_data <- vector("list", length = 50)
vegetation_data <- lapply(vegetation_data,function(x){
matrix(rbinom(128^2,1,0.6),nrow = 128,ncol=128)
})

#Activate python environment (only necessary
#on first opening of R session).

## Not run: 
ewsnet_init(envname = "EWSNET_env")

## End(Not run)

#Generate EWSNet predictions.

## Not run: 
pred <- sewsnet_predict(
 vegetation_data,
 delta = 0.1,
 inp_size = 25,
 envname = "EWSNET_env")
 
## End(Not run)


duncanobrien/EWSmethods documentation built on Aug. 28, 2024, 4:25 a.m.