Skip to contents

This function generates prediction maps of Hmsc models for current and future climate scenarios. It also predicts an ensemble predictions for different climate models. For each species and overall species richness, the function exports three maps: mean, standard deviation (sd), and coefficient of variation (cov).

Usage

Predict_Maps(
  Path_Model = NULL,
  Hab_Abb = NULL,
  EnvFile = ".env",
  FromHPC = TRUE,
  NCores = 8L,
  Pred_Clamp = TRUE,
  Fix_Efforts = "q90",
  Fix_Rivers = "q90",
  Pred_NewSites = TRUE,
  UseTF = TRUE,
  TF_Environ = NULL,
  TF_use_single = FALSE,
  LF_NCores = NCores,
  LF_Check = FALSE,
  LF_Temp_Cleanup = TRUE,
  LF_Only = FALSE,
  LF_Commands_Only = FALSE,
  Temp_Dir = "TEMP_Pred",
  Temp_Cleanup = TRUE,
  CC_Models = c("GFDL-ESM4", "IPSL-CM6A-LR", "MPI-ESM1-2-HR", "MRI-ESM2-0",
    "UKESM1-0-LL"),
  CC_Scenario = c("ssp126", "ssp370", "ssp585")
)

Arguments

Path_Model

Character. Path to fitted Hmsc model object.

Hab_Abb

Character. Habitat abbreviation indicating the specific SynHab habitat type for which data will be prepared. Valid values are 0, 1, 2, 3, 4a, 4b, 10, 12a, 12b. For more details, see Pysek et al..

EnvFile

Character. Path to the environment file containing paths to data sources. Defaults to .env.

FromHPC

Logical indicating whether the work is being done from HPC, to adjust file paths accordingly. Default: TRUE.

NCores

Integer specifying the number of parallel cores for parallelization. Default: 8 cores.

Pred_Clamp

Logical indicating whether to clamp the sampling efforts at a single value. Defaults to TRUE. If TRUE, the Fix_Efforts argument must be provided.

Fix_Efforts

Numeric or character. Defines the value to fix sampling efforts less than the provided value. If numeric, the value is directly used (log10 scale). If character, it can be median, mean, max, or q90 (q0% Quantile). Using max can reflect extreme values caused by rare, highly sampled locations (e.g., urban centers or popular natural reserves). While using 90% quantile avoid such extreme grid cells while still capturing areas with high sampling effort. This argument is mandatory when Pred_Clamp is set to TRUE.

Fix_Rivers

Numeric or character. Similar to Fix_Efforts, but for fixing the length of rivers. If numeric, the value is directly used (log10 scale). If character, it can be median, mean, max, q90 (90% quantile). It can be also NULL for not fixing the river length predictor. Defaults to q90.

Pred_NewSites

Logical indicating whether to predict habitat suitability at new sites. Default: TRUE. Note: This parameter is temporary and will be removed in future updates.

UseTF

Logical indicating whether to use TensorFlow for calculations. Defaults to TRUE.

TF_Environ

Character string specifying the path to the Python environment. Defaults to NULL. This argument is required if UseTF is TRUE.

TF_use_single

Logical indicating whether to use single precision for the TF calculations. Defaults to FALSE.

LF_NCores

Integer specifying the number of cores to use for parallel processing. Defaults to 8.

LF_Check

Logical. If TRUE, the function checks if the output files are already created and valid. If FALSE, the function will only check if the files exist without checking their integrity. Default is FALSE.

LF_Temp_Cleanup

Logical indicating whether to delete temporary files in the Temp_Dir after finishing the LF predictions.

LF_Only

Logical. Indicates whether to predict only the latent factor. Useful for distributing processing load between GPU and CPU. When LF_Only = TRUE, the latent factor prediction can be computed on the GPU. The function can then be rerun with LF_Only = FALSE to predict habitat suitability using the predicted latent factor on the CPU. Default: FALSE.

LF_Commands_Only

logical. If TRUE, returns the command to run the Python script. Default is FALSE.

Temp_Dir

Character string specifying the path for temporary storage of intermediate files.

Temp_Cleanup

logical, indicating whether to clean up temporary files. Defaults to TRUE.

CC_Models

Character vector. Specifies the climate models for future predictions. Default: c("GFDL-ESM4", "IPSL-CM6A-LR", "MPI-ESM1-2-HR", "MRI-ESM2-0", "UKESM1-0-LL"). Note: This parameter is temporary and may be removed in future updates.

CC_Scenario

Character vector. Specifies the climate scenarios for future predictions. Default: c("ssp126", "ssp370", "ssp585"). Note: This parameter is temporary and may be removed in future updates.

Value

A tibble containing the prediction summary and file paths for output *.tif files.

Author

Ahmed El-Gabbas