Skip to contents

This function continues running the analysis pipeline for Hmsc models. It must be called after completing Mod_Postprocess_1_CPU and Mod_Prep_TF on CPU, as well as executing VP_SLURM.slurm and LF_SLURM.slurm on GPU. The function processes Latent Factor predictions, generates spatial predictions under various climate scenarios, evaluate internal evaluation, prepares and plots response curves, and computes and visualizes variance partitioning.

Usage

Mod_Postprocess_2_CPU(
  ModelDir = NULL,
  Hab_Abb = NULL,
  NCores = 8L,
  FromHPC = TRUE,
  EnvFile = ".env",
  GPP_Dist = NULL,
  Tree = "Tree",
  Samples = 1000L,
  Thin = NULL,
  UseTF = TRUE,
  TF_Environ = NULL,
  TF_use_single = FALSE,
  LF_NCores = NCores,
  LF_Check = FALSE,
  LF_Temp_Cleanup = TRUE,
  Temp_Cleanup = TRUE,
  N_Grid = 50L,
  CC_Models = c("GFDL-ESM4", "IPSL-CM6A-LR", "MPI-ESM1-2-HR", "MRI-ESM2-0",
    "UKESM1-0-LL"),
  CC_Scenario = c("ssp126", "ssp370", "ssp585"),
  RC_NCores = 8L,
  Pred_Clamp = TRUE,
  Fix_Efforts = "q90",
  Fix_Rivers = "q90",
  Pred_NewSites = TRUE
)

Arguments

ModelDir

String. Path to the root directory of the fitted models without the trailing slash. Two folders will be created Model_Fitted and Model_Coda to store merged model and coda objects, respectively.

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..

NCores

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

FromHPC

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

EnvFile

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

GPP_Dist

Integer specifying the distance in kilometers between knots for GPP models.

Tree

Character string specifying if phylogenetic tree was used in the model. Valid values are "Tree" or "NoTree". Default is "Tree".

Samples

Integer specifying the value for the number of MCMC samples in the selected model. Defaults to 1000.

Thin

Integer specifying the value for thinning in the selected model.

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.

Temp_Cleanup

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

N_Grid

Integer specifying the number of points along the gradient for continuous focal variables. Defaults to 50. See Hmsc::constructGradient for more details.

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.

RC_NCores

Integer specifying the number of cores to use for response curve prediction. Defaults to 8.

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.

Author

Ahmed El-Gabbas