diff --git a/DESCRIPTION b/DESCRIPTION
index b9a9d5c..2d2aa69 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
Package: RFate
Type: Package
Title: FATE with R
-Version: 1.0.1
-Date: 2021-06-14
+Version: 1.0.2
+Date: 2021-09-27
Authors@R: c(person("Wilfried", "Thuiller", role = "aut"
, email = "wilfried.thuiller@univ-grenoble-alpes.fr"),
person("Damien", "Georges", role = "aut"),
@@ -35,7 +35,7 @@ Description: Wrapper of the C++ model FATE. FATE is a vegetation model based on
1) gather, prepare and format data to be used with FATE ;
2) run FATE simulation(s)
3) process and analyze data produced by FATE.
-RoxygenNote: 7.1.1
+RoxygenNote: 7.1.2
Encoding: UTF-8
NeedsCompilation: yes
License:
@@ -59,6 +59,6 @@ Suggests:
testthat,
covr,
knitr, markdown, rmarkdown
-LinkingTo: Rcpp, RcppThread, BH (>= 1.75.0-0)
+LinkingTo: Rcpp, RcppThread, BH (>= 1.75.0-0), RangeShiftR
VignetteBuilder: knitr, rmarkdown
Language: en-US
diff --git a/NAMESPACE b/NAMESPACE
index 0891e0a..cba6e41 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -64,6 +64,7 @@ importFrom(R.utils,gunzip)
importFrom(R.utils,gzip)
importFrom(RColorBrewer,brewer.pal)
importFrom(Rcpp,sourceCpp)
+importFrom(ade4,dudi.hillsmith)
importFrom(ade4,dudi.pca)
importFrom(ade4,dudi.pco)
importFrom(ade4,inertia.dudi)
diff --git a/R/FATE_RS.R b/R/FATE_RS.R
new file mode 100644
index 0000000..4781d98
--- /dev/null
+++ b/R/FATE_RS.R
@@ -0,0 +1,305 @@
+### HEADER #####################################################################
+##' @title S
+##'
+##' @name FATE_RS
+##'
+##' @author Maya Guéguen
+##'
+##'
+##' @description ...
+##'
+##'
+##' @keywords RangeShifter
+##'
+##' @export
+##'
+##' @importFrom RangeShiftR RunRS readPop
+##' @importFrom raster stack rasterFromXYZ writeRaster rasterToPolygons disaggregate rasterize
+##' @importFrom sf st_as_sf st_buffer st_union st_area st_write
+##' @importFrom rmapshaper ms_explode
+##' @importFrom spatstat im predict
+##' @importFrom stringr str_count
+##' @importFrom scales rescale
+##'
+## END OF HEADER ###############################################################
+
+
+FATE_RS = function(name.simulation, file.simulParam, opt.no_CPU = 1, verbose.level = 2
+ , PPM.names_PFG, PPM.ras_env, PPM.xy, PPM.mod
+ , PATCH.threshold = 80, PATCH.buffer = 500, PATCH.min_m2 = 300000
+ , COST.ras_elev, COST.ras_barr, COST.wei = c(0.43, 0.53, 0.04), COST.range = c(1, 10)
+ , RS.name_simul, RS.dens_dep, RS.sim, RS.demo, RS.disp, RS.init
+ , POP.carrying_capacity = 0.115
+ , year.start, year.end, year.step)
+{
+ ## + argument pour savoir si on commence par FATE ou RS
+
+ ## LOOP over simulation years
+ for (ye in seq(year.start, year.end, 1))
+ {
+ .setParam(params.lines = file.simulParam
+ , flag = "SAVING_DIR"
+ , flag.split = "^--.*--$"
+ , value = paste0(name.simulation, "/RESULTS/SIMUL_YEAR_", ye, ""))
+
+ ## Run FATE ###################################################################################
+ FATE(simulParam = file.simulParam, no_CPU = opt.no_CPU, verboseLevel = verbose.level)
+
+ ## Get resulting FATE vegetation maps #########################################################
+ ## Get results directories ------------------------------------------------
+ GLOB_DIR = .getGraphics_results(name.simulation = name.simulation
+ , abs.simulParam = file.simulParam)
+
+ ## Get raster mask --------------------------------------------------------
+ GLOB_MASK = .getGraphics_mask(name.simulation = name.simulation
+ , abs.simulParam = file.simulParam)
+
+ ## UNZIP the raster saved -------------------------------------------------
+ raster.perPFG.allStrata = .getRasterNames(year.step, "allStrata", "ABUND", GLOB_DIR)
+ .unzip(folder_name = GLOB_DIR$dir.output.perPFG.allStrata
+ , list_files = raster.perPFG.allStrata
+ , no_cores = opt.no_CPU)
+
+ ## GET PFG abundance maps (all strata) ------------------------------------
+ file_name = paste0(GLOB_DIR$dir.output.perPFG.allStrata
+ , "Abund_YEAR_"
+ , year.step
+ , "_"
+ , PPM.names_PFG
+ , "_STRATA_all.tif")
+ gp = PPM.names_PFG[which(file.exists(file_name))]
+ file_name = file_name[which(file.exists(file_name))]
+
+ if (length(file_name) > 0)
+ {
+ ras.PFG = stack(file_name) * GLOB_MASK$ras.mask
+ names(ras.PFG) = gp
+ } else
+ {
+ stop(paste0("Missing data!\n The folder "
+ , GLOB_DIR$dir.output.perPFG.allStrata
+ , " does not contain adequate files"))
+ }
+
+ ## Combine with other variables ###############################################################
+ ras.all = stack(ras.PFG, PPM.ras_env)
+
+ env.data = as.data.frame(ras.all)
+ env.data = na.exclude(env.data)
+ for(pfg in PPM.names_PFG) {
+ env.data[which(env.data[, pfg] < 0), pfg] = 0
+ }
+
+ ### Create all explanatory variables (with interactions between vegetation and environment)
+ mess = paste0(c(paste0("env.data$", names(PPM.ras_env))
+ , paste0("sqrt(env.data$", PPM.names_PFG, ")")), collapse = ", ")
+ eval(parse(text = paste0("X.des = poly(", mess, ", degree = 2, raw = TRUE)")))
+ col_power_1 = which(str_count(colnames(X.des), "1") == 1)
+ col_power_2 = which(str_count(colnames(X.des), "1") == 0)
+ col_inter_var1 = grep("^1.", colnames(X.des))
+ col_inter_var2 = grep("^0.1.", colnames(X.des))
+ col_toKeep = sort(unique(c(
+ col_power_1, col_power_2, col_inter_var1, col_inter_var2
+ )))
+ X.des = X.des[, col_toKeep]
+
+ ### Change explanatory variables into images ------------------------------
+ ux = sort(unique(PPM.xy[, 1])) #x ordinates
+ uy = sort(unique(PPM.xy[, 2])) #y ordinates
+ nx = length(ux)
+ ny = length(uy)
+ col.ref = match(PPM.xy[, 1], ux) # indice de l'abscisse de quad dans ux
+ row.ref = match(PPM.xy[, 2], uy)
+
+ int.list = list()
+ for (n in 1:dim(X.des)[2]) {
+ all.vec = rep(NA, max(row.ref) * max(col.ref))
+ vec.ref = (col.ref - 1) * max(row.ref) + row.ref
+ all.vec[vec.ref] = X.des[, n]
+ int.list[[n]] = im(matrix(all.vec, max(row.ref), max(col.ref), dimnames = list(uy, ux)),
+ xcol = ux,
+ yrow = uy)
+ }
+ names(int.list) = paste0("V", 1:dim(X.des)[2])
+
+ ## Transform them into RS species distribution map ############################################
+ mod.pred = predict(PPM.mod, covariates = int.list, ngrid = c(ny, nx))
+ ras.pred = raster(mod.pred)
+ ras.quality = ras.pred / max(na.exclude(values(ras.pred))) * 100
+ tmp = log(ras.quality) + abs(min(log(ras.quality)[], na.rm = TRUE))
+ ras.log = tmp / max(tmp[], na.rm = TRUE) * 100
+
+
+ ## Update RS patch maps #######################################################################
+ ras.patch = ras.log > PATCH.threshold # defining patches
+ ras.patch[ras.patch[] < 1] = NA # keep only patches
+
+ pol.patch = rasterToPolygons(ras.patch, dissolve = TRUE) # converting into polygons
+ pol.patch = disaggregate(pol.patch) # separating into multiple polygons
+
+ pol.patch = st_as_sf(pol.patch)
+ pol.patch_buffer = st_buffer(pol.patch, dist = PATCH.buffer)
+ pol.patch_buffer = st_union(pol.patch_buffer) # merging overlapping polygons
+ pol.patch_buffer = ms_explode(pol.patch_buffer) # separating into multiple polygons
+
+ pol.patch_buffer$area_m2 = as.numeric(st_area(pol.patch_buffer))
+ pol.patch_buffer = pol.patch_buffer[which(pol.patch_buffer$area_m2 > PATCH.min_m2)] # excluding too small patches
+
+ ## Change into raster
+ ras.patch_buffer = rasterize(pol.patch_buffer, ras.log)
+ ## Set Habitat Suitability out of patches to NA
+ ras.log[which(is.na(ras.patch_buffer[]))] = NA
+
+ ## SAVE PATCH into ASCII
+ val.buf = ras.patch_buffer[]
+ val.buf[is.na(val.buf)] = -9
+ val.buf = as.character(val.buf)
+ seq_linestarts <- seq(from = nrow(ras.patch_buffer)
+ , to = ncell(ras.patch_buffer) - nrow(ras.patch_buffer) + 1
+ , by = nrow(ras.patch_buffer))
+ val.buf[seq_linestarts] = paste0(val.buf[seq_linestarts], "\n") # delineating rows for future character string
+ cha.buf = paste(val.buf, collapse = ' ') # concatenating in 1 character
+ cha.buf = gsub("\n ", "\n", cha.buf) # removing blank from line starts
+
+ file.rename(from = paste0(RS.name_simul, "Inputs/PatchFile.txt")
+ , to = paste0(RS.name_simul, "Inputs/PatchFile_YEAR_", ye - 1, ".txt"))
+
+ fileConn <- file(paste0(RS.name_simul, "Inputs/PatchFile.txt"))
+ writeLines(c(paste("ncols", ncol(ras.patch_buffer), sep = " "),
+ paste("nrows", nrow(ras.patch_buffer), sep = " "),
+ paste("xllcorner", extent(ras.patch_buffer)[1], sep = " "),
+ paste("yllcorner", extent(ras.patch_buffer)[3], sep = " "),
+ paste("cellsize", resolution(ras.patch_buffer)[1], sep = " "),
+ "NODATA_value -9",
+ cha.buf),
+ fileConn)
+ close(fileConn)
+
+
+ ## SAVE HS RASTER MAP AS ASCII ################################################################
+ val.log = ras.log[]
+ val.log[is.na(val.log)] = -9
+ val.log = as.character(val.log)
+ seq_linestarts <- seq(from = nrow(ras.log), to = ncell(ras.log) - nrow(ras.log) + 1, by = nrow(ras.log))
+ val.log[seq_linestarts] = paste0(val.log[seq_linestarts], "\n") # delineating rows for future character string
+ cha.log = paste(val.log, collapse = ' ') # concatenating in 1 character
+ cha.log = gsub("\n ", "\n", cha.log) # removing blank from line starts
+
+ file.rename(from = paste0(RS.name_simul, "Inputs/LandscapeFile_HabSuit.txt")
+ , to = paste0(RS.name_simul, "Inputs/LandscapeFile_HabSuit_YEAR_", ye - 1, ".txt"))
+
+ fileConn <- file(paste0(RS.name_simul, "Inputs/LandscapeFile_HabSuit.txt"))
+ writeLines(c(paste("ncols", ncol(ras.log), sep = " "),
+ paste("nrows", nrow(ras.log), sep = " "),
+ paste("xllcorner", extent(ras.log)[1], sep = " "),
+ paste("yllcorner", extent(ras.log)[3], sep = " "),
+ paste("cellsize", resolution(ras.log)[1], sep = " "),
+ "NODATA_value -9",
+ cha.log),
+ fileConn)
+ close(fileConn)
+
+
+ ## Update RS disp-cost maps ###################################################################
+ ## Function to rescale habitat suitability maps
+ fun_rescale = function(a = 1, b = 100, ras, ext) {
+ mini = min(values(ras), na.rm = TRUE)
+ maxi = max(values(ras), na.rm = TRUE)
+ res = (((b - a) * (ras - mini)) / (maxi - mini)) + a
+ res = mask(res, ext)
+ return(res)
+ }
+
+ ras.log_ = fun_rescale(a = a, b = b, ras = ras.log, ext = ras.log)
+ ras.HS = fun_rescale(a = a, b = b, ras = 100 + (-1 * ras.log_) ^ 1, ext = ras.log_)
+
+ # Compute cost map --------------------------------------------------------
+ ras.cost <- COST.wei[1] * ras.HS + COST.wei[2] * COST.ras_elev + COST.wei[3] * COST.ras_barr
+ ras.cost[] <- rescale(ras.cost[], c(COST.range[1], COST.range[2]))
+ ras.cost[] <- round(ras.cost[]) # round for SMS module
+
+ ## SAVE COST RASTER MAP AS ASCII ##############################################################
+ val.cost = ras.cost[]
+ val.cost[is.na(val.cost)] = -9
+ val.cost = as.character(val.cost)
+ seq_linestarts <- seq(from = nrow(ras.cost), to = ncell(ras.cost) - nrow(ras.cost) + 1, by = nrow(ras.cost))
+ val.cost[seq_linestarts] = paste0(val.cost[seq_linestarts], "\n") # delineating rows for future character string
+ cha.cost = paste(val.cost, collapse = ' ') # concatenating in 1 character
+ cha.cost = gsub("\n ", "\n", cha.cost) # removing blank from line starts
+
+ file.rename(from = paste0(RS.name_simul, "Inputs/LandscapeFile_CostMap.txt")
+ , to = paste0(RS.name_simul, "Inputs/LandscapeFile_CostMap_YEAR_", ye - 1, ".txt"))
+
+ fileConn <- file(paste0(RS.name_simul, "Inputs/LandscapeFile_CostMap.txt"))
+ writeLines(c(paste("ncols", ncol(ras.cost), sep = " "),
+ paste("nrows", nrow(ras.cost), sep = " "),
+ paste("xllcorner", extent(ras.cost)[1], sep = " "),
+ paste("yllcorner", extent(ras.cost)[3], sep = " "),
+ paste("cellsize", resolution(ras.cost)[1], sep = " "),
+ "NODATA_value -9",
+ cha.cost),
+ fileConn)
+ close(fileConn)
+
+
+ ## Run RangeShifter ###########################################################################
+ RS.land = ImportedLandscape(LandscapeFile = paste0(RS.name_simul, "Inputs/LandscapeFile_HabSuit.txt"),
+ Resolution = resolution(ras.log),
+ HabPercent = TRUE, # continuous values for habitat quality (and not discrete)
+ K_or_DensDep = RS.dens_dep,
+ PatchFile = paste0(RS.name_simul, "Inputs/PatchFile.txt"),
+ CostsFile = paste0(RS.name_simul, "Inputs/LandscapeFile_CostMap.txt"))
+
+ RS.params = RSsim(simul = RS.sim, land = RS.land, demog = RS.demo, dispersal = RS.disp, init = RS.init)
+
+ RunRS(RSparams = RS.params, dirpath = RS.name_simul)
+
+
+ ## Get resulting RS species density ###########################################################
+ # read population output file into a dataframe
+ pop_df = readPop(s = RS.params, dirpath = RS.name_simul)
+ pop_df = pop_df[which(pop_df$Rep == 0 & pop_df$Year == 1), ]
+
+ file.rename(from = paste0(RS.name_simul, "Outputs/Batch1_Sim1_Land1_Pop.txt")
+ , to = paste0(RS.name_simul, "Outputs/Batch1_Sim1_Land1_Pop_YEAR_", ye, ".txt"))
+
+ # Make stack of different raster layers for each year and for only one repetition (Rep==0):
+ stack_years_rep0 = ras.patch_buffer
+ stack_years_rep0[which(!is.na(stack_years_rep0[]))] = 0
+ for (pp in 1:nrow(pop_df)) {
+ stack_years_rep0[which(ras.patch_buffer[] == pop_df$PatchID[pp])] = pop_df$NInd[pp] / pop_df$Ncells[pp]
+ }
+ stack_years_rep0 = stack_years_rep0 / POP.carrying_capacity
+ stack_years_rep0[which(stack_years_rep0[] > 1)] = 1
+ name.dist = paste0(name.simulation, "/DATA/MASK/MASK_DIST_YEAR_", ye + 1, ".tif")
+ writeRaster(stack_years_rep0, filename = name.dist)
+
+ ## Update FATE disturbance maps ###############################################################
+ dist.files = .getParam(params.lines = file.simulParam
+ , flag = "DIST_MASK"
+ , flag.split = "^--.*--$"
+ , is.num = FALSE)
+ dist.files[1] = paste0(name.simulation, "/DATA/MASK/MASK_DIST_YEAR_", ye + 1, ".tif")
+
+ .setParam(params.lines = file.simulParam
+ , flag = "DIST_MASK"
+ , flag.split = "^--.*--$"
+ , value = dist.files)
+
+
+ ## Update FATE simulation to load #############################################################
+ year.save = readLines(.getParam(params.lines = file.simulParam
+ , flag = "SAVING_YEARS_OBJECTS"
+ , flag.split = "^--.*--$"
+ , is.num = FALSE))
+ file.rename(from = paste0(GLOB_DIR$dir.save, "SimulMap_", year.save[1], ".sav")
+ , to = paste0(GLOB_DIR$dir.save, "SimulMap_STEP_YEAR_", ye, ".sav"))
+
+ .setParam(params.lines = file.simulParam
+ , flag = "SAVED_STATE"
+ , flag.split = "^--.*--$"
+ , value = paste0(GLOB_DIR$dir.save, "SimulMap_STEP_YEAR_", ye, ".sav"))
+
+ }
+}
+
diff --git a/R/PRE_FATE.params_globalParameters.R b/R/PRE_FATE.params_globalParameters.R
index bd1e786..c09abd0 100644
--- a/R/PRE_FATE.params_globalParameters.R
+++ b/R/PRE_FATE.params_globalParameters.R
@@ -124,8 +124,6 @@
##' @param doAliens default \code{FALSE}. \cr If \code{TRUE}, invasive plant
##' introduction is activated in the \code{FATE} simulation, and associated
##' parameters are required
-##' @param ALIEN.no (\emph{optional}) \cr an \code{integer} corresponding to the
-##' number of introductions
##' @param ALIEN.freq (\emph{optional}) \cr a \code{vector} of \code{integer}
##' corresponding to the frequency of each introduction (\emph{in years})
##' @param doFire default \code{FALSE}. \cr If \code{TRUE}, fire
@@ -435,7 +433,6 @@
##' introduction areas. \cr If the habitat suitability filter is on,
##' suitability maps will also be needed for these new groups.
##' \describe{
-##' \item{ALIEN.no}{the number of different introductions}
##' \item{ALIEN.freq}{the frequency of each introduction (\emph{in years})}
##' }
##' }
@@ -642,7 +639,6 @@
##'
##' \itemize{
##' \item DO_ALIENS_INTRODUCTION
-##' \item ALIENS_NO
##' \item ALIENS_FREQ
##' }
##'
@@ -768,7 +764,6 @@ PRE_FATE.params_globalParameters = function(
, doDrought = FALSE
, DROUGHT.no_sub = 4
, doAliens = FALSE
- , ALIEN.no
, ALIEN.freq = 1
, doFire = FALSE
, FIRE.no
@@ -862,11 +857,10 @@ PRE_FATE.params_globalParameters = function(
}
if (doAliens)
{
- .testParam_notInteger.m("ALIEN.no", ALIEN.no)
.testParam_notInteger.m("ALIEN.freq", ALIEN.freq)
- if (length(ALIEN.freq) != ALIEN.no){
+ if (length(ALIEN.freq) != required.no_PFG){
stop(paste0("Wrong type of data!\n `ALIEN.freq` must contain as many "
- , "values as the number of introductions (`ALIEN.no`)"))
+ , "values as the number of PFG (`required.no_PFG`)"))
}
}
if (doFire)
@@ -1012,10 +1006,8 @@ PRE_FATE.params_globalParameters = function(
if (doAliens)
{
params.ALIEN = list(as.numeric(doAliens)
- , ALIEN.no
, ALIEN.freq)
names.params.list.ALIEN = c("DO_ALIENS_INTRODUCTION"
- , "ALIENS_NO"
, "ALIENS_FREQ")
} else
{
diff --git a/R/PRE_FATE.speciesClustering_step1.R b/R/PRE_FATE.speciesClustering_step1.R
index 42aaf87..468f392 100644
--- a/R/PRE_FATE.speciesClustering_step1.R
+++ b/R/PRE_FATE.speciesClustering_step1.R
@@ -193,7 +193,7 @@
## END OF HEADER ###############################################################
-PRE_FATE.speciesClustering_step1 = function(mat.species.DIST)
+PRE_FATE.speciesClustering_step1 = function(mat.species.DIST, opt.no_clust_max = 15)
{
#############################################################################
@@ -376,7 +376,7 @@ PRE_FATE.speciesClustering_step1 = function(mat.species.DIST)
## Calculated for each group, and varying the number of clusters
min_no_species_in_group = sapply(mat.species.DIST, function(x) ncol(as.matrix(x)))
- min_no_species_in_group = sapply(min_no_species_in_group, function(x) min(x, 15))
+ min_no_species_in_group = sapply(min_no_species_in_group, function(x) min(x, opt.no_clust_max))
combi = foreach(group = 1:length(group_names), .combine = "rbind") %do% {
expand.grid(no.clusters = 2:(min_no_species_in_group[group] - 1), GROUP = group)
}
diff --git a/R/PRE_FATE.speciesDistanceCombine.R b/R/PRE_FATE.speciesDistanceCombine.R
index 2111f2d..bfba4cd 100644
--- a/R/PRE_FATE.speciesDistanceCombine.R
+++ b/R/PRE_FATE.speciesDistanceCombine.R
@@ -10,6 +10,9 @@
##'
##' @param list.mat.dist a \code{list} of matrices containing dissimilarity
##' distance values between each pair of species.
+##' @param opt.min.noMat (\emph{optional}) default \code{length(list.mat.dist)}. \cr
+##' An \code{integer} corresponding to the minimal number of distance matrices for
+##' which each species should have values
##' @param opt.normal (\emph{optional}) default \code{TRUE}. \cr
##' If \code{TRUE}, all given distance matrices will be normalized
##' (see \href{PRE_FATE.speciesDistanceCombine#details}{\code{Details}})
@@ -118,6 +121,7 @@
PRE_FATE.speciesDistanceCombine = function(list.mat.dist
+ , opt.min.noMat = length(list.mat.dist)
, opt.normal = TRUE
, opt.weights = NULL
){
@@ -212,15 +216,20 @@ PRE_FATE.speciesDistanceCombine = function(list.mat.dist
cat("\n Comparison of matrix' dimensions : \n")
combi = combn(1:no_mat, 2)
- inti_all = unique(unlist(names_species))
- for(x in 1:ncol(combi)){
- inti = intersect(names_species[[combi[1, x]]], names_species[[combi[2, x]]])
- inti_all = intersect(inti_all, inti)
- cat("\n> Matrices ", names_mat[combi[1, x]], "-", names_mat[combi[2, x]], ": "
- , length(inti), "species in common")
- }
- cat("\n Number of species with values for all matrices : ", length(inti_all))
+
+ inti_all = table(unlist(names_species))
+ inti_all = names(inti_all)[which(inti_all >= opt.min.noMat)]
+ cat("\n Number of species with values for at least", opt.min.noMat, " matrices : ", length(inti_all))
cat("\n")
+ # inti_all = unique(unlist(names_species))
+ # for(x in 1:ncol(combi)){
+ # inti = intersect(names_species[[combi[1, x]]], names_species[[combi[2, x]]])
+ # inti_all = intersect(inti_all, inti)
+ # cat("\n> Matrices ", names_mat[combi[1, x]], "-", names_mat[combi[2, x]], ": "
+ # , length(inti), "species in common")
+ # }
+ # cat("\n Number of species with values for all matrices : ", length(inti_all))
+ # cat("\n")
names_species.toKeep = inti_all
}
@@ -246,6 +255,20 @@ PRE_FATE.speciesDistanceCombine = function(list.mat.dist
})
}
+ ## Fill missing species whith NA if there is any
+ mat.dist = lapply(mat.dist, function(x) {
+ if (ncol(x) < length(names_species.toKeep)) {
+ tmp.col = colnames(x)
+ tmp.row = rownames(x)
+ miss = setdiff(names_species.toKeep, colnames(x))
+ x = cbind(x, matrix(rep(NA, length(miss) * nrow(x)), ncol = length(miss)))
+ x = rbind(x, matrix(rep(NA, length(miss) * ncol(x)), nrow = length(miss)))
+ colnames(x) = c(tmp.col, miss)
+ rownames(x) = c(tmp.row, miss)
+ }
+ return(x)
+ })
+
## Multiply each distance matrix by its weight
mat.species.DIST = lapply(1:no_mat, function(x) {
tmp = as.matrix(mat.dist[[x]])
diff --git a/R/PRE_FATE.speciesDistanceOverlap.R b/R/PRE_FATE.speciesDistanceOverlap.R
index 941792b..3303754 100644
--- a/R/PRE_FATE.speciesDistanceOverlap.R
+++ b/R/PRE_FATE.speciesDistanceOverlap.R
@@ -79,7 +79,7 @@
##'
##' @importFrom stats as.dist
##' @importFrom methods as
-##' @importFrom ade4 dudi.pca suprow
+##' @importFrom ade4 dudi.hillsmith suprow
##' @importFrom raster raster extension
##' @importFrom phyloclim niche.overlap
##'
@@ -118,7 +118,7 @@ PRE_FATE.speciesDistanceOverlap = function(mat.overlap.option, mat.overlap.objec
}
## Calculate PCA for all environment
- pca.env = dudi.pca(tab.env, scannf = F, nf = 2)
+ pca.env = dudi.hillsmith(tab.env, scannf = F, nf = 2)
scores.env = pca.env$li
## Calculate overlap matrix
diff --git a/R/UTILS.loadPackage.R b/R/UTILS.loadPackage.R
index 6359c4b..914cc99 100644
--- a/R/UTILS.loadPackage.R
+++ b/R/UTILS.loadPackage.R
@@ -80,5 +80,6 @@
.onUnload = function (libpath)
{
+ library.dynam.unload("RangeShiftR", libpath)
library.dynam.unload("RFate", libpath)
}
diff --git a/R/UTILS.package_ecospat.R b/R/UTILS.package_ecospat.R
index 041b2b0..35c7e48 100644
--- a/R/UTILS.package_ecospat.R
+++ b/R/UTILS.package_ecospat.R
@@ -72,7 +72,7 @@ ecospat.kd = function (x, ext, R = 100, th = 0, env.mask = c(), method = "adehab
x.dens <- kernelUD(SpatialPoints(xr[, 1:2]), h = "href", grid = mask, kern = "bivnorm")
x.dens <- raster(xmn = ext[1], xmx = ext[2], ymn = ext[3], ymx = ext[4], matrix(x.dens$ud, nrow = R))
if (!is.null(th)) {
- th.value <- quantile(extract(x.dens, x), th)
+ th.value <- quantile(extract(x.dens, x), th, na.rm = TRUE)
x.dens[x.dens < th.value] <- 0
}
if (!is.null(env.mask)) {
@@ -86,7 +86,7 @@ ecospat.kd = function (x, ext, R = 100, th = 0, env.mask = c(), method = "adehab
}
if (!is.null(th)) {
xr <- sapply(x, findInterval, x.dens$x)
- th.value <- quantile(x.dens$y[xr], th)
+ th.value <- quantile(x.dens$y[xr], th, na.rm = TRUE)
sprm <- which(x.dens$y < th.value)
x.dens$y[sprm] <- 0
}
diff --git a/docs/reference/FATE.html b/docs/reference/FATE.html
index 41740b0..2e7e3e1 100644
--- a/docs/reference/FATE.html
+++ b/docs/reference/FATE.html
@@ -72,7 +72,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -80,7 +80,7 @@
-
+
@@ -124,21 +124,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -155,7 +155,7 @@
-
+
Reference
diff --git a/docs/reference/FATE_RS.html b/docs/reference/FATE_RS.html
new file mode 100644
index 0000000..e3bd081
--- /dev/null
+++ b/docs/reference/FATE_RS.html
@@ -0,0 +1,251 @@
+
+
+
+
+
+
+
+
+S — FATE_RS • RFate
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
FATE_RS (
+ name.simulation ,
+ file.simulParam ,
+ opt.no_CPU = 1 ,
+ verbose.level = 2 ,
+ name.simulation.RS ,
+ params.RS ,
+ year.start ,
+ year.end ,
+ year.step
+)
+
+
+
Author
+
+
Maya Guéguen
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/reference/POST_FATE.binaryMaps.html b/docs/reference/POST_FATE.binaryMaps.html
index 38f20a1..367a347 100644
--- a/docs/reference/POST_FATE.binaryMaps.html
+++ b/docs/reference/POST_FATE.binaryMaps.html
@@ -75,7 +75,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -83,7 +83,7 @@
-
+
@@ -127,21 +127,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -158,7 +158,7 @@
-
+
Reference
diff --git a/docs/reference/POST_FATE.graphic_evolutionCoverage.html b/docs/reference/POST_FATE.graphic_evolutionCoverage.html
index afd9cf0..4b87ab3 100644
--- a/docs/reference/POST_FATE.graphic_evolutionCoverage.html
+++ b/docs/reference/POST_FATE.graphic_evolutionCoverage.html
@@ -78,7 +78,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -86,7 +86,7 @@
-
+
@@ -130,21 +130,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -161,7 +161,7 @@
-
+
Reference
diff --git a/docs/reference/POST_FATE.graphic_evolutionPixels.html b/docs/reference/POST_FATE.graphic_evolutionPixels.html
index 4d69c07..015a851 100644
--- a/docs/reference/POST_FATE.graphic_evolutionPixels.html
+++ b/docs/reference/POST_FATE.graphic_evolutionPixels.html
@@ -77,7 +77,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -85,7 +85,7 @@
-
+
@@ -129,21 +129,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -160,7 +160,7 @@
-
+
Reference
diff --git a/docs/reference/POST_FATE.graphic_evolutionStability.html b/docs/reference/POST_FATE.graphic_evolutionStability.html
index f618274..af3b2b1 100644
--- a/docs/reference/POST_FATE.graphic_evolutionStability.html
+++ b/docs/reference/POST_FATE.graphic_evolutionStability.html
@@ -76,7 +76,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -84,7 +84,7 @@
-
+
@@ -128,21 +128,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -159,7 +159,7 @@
-
+
Reference
diff --git a/docs/reference/POST_FATE.graphic_mapPFG.html b/docs/reference/POST_FATE.graphic_mapPFG.html
index caaa400..650a2f0 100644
--- a/docs/reference/POST_FATE.graphic_mapPFG.html
+++ b/docs/reference/POST_FATE.graphic_mapPFG.html
@@ -78,7 +78,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -86,7 +86,7 @@
-
+
@@ -130,21 +130,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -161,7 +161,7 @@
-
+
Reference
diff --git a/docs/reference/POST_FATE.graphic_mapPFGvsHS.html b/docs/reference/POST_FATE.graphic_mapPFGvsHS.html
index bd41fcd..072d0ac 100644
--- a/docs/reference/POST_FATE.graphic_mapPFGvsHS.html
+++ b/docs/reference/POST_FATE.graphic_mapPFGvsHS.html
@@ -78,7 +78,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -86,7 +86,7 @@
-
+
@@ -130,21 +130,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -161,7 +161,7 @@
-
+
Reference
diff --git a/docs/reference/POST_FATE.graphic_validationStatistics.html b/docs/reference/POST_FATE.graphic_validationStatistics.html
index b8cd851..6414a13 100644
--- a/docs/reference/POST_FATE.graphic_validationStatistics.html
+++ b/docs/reference/POST_FATE.graphic_validationStatistics.html
@@ -78,7 +78,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -86,7 +86,7 @@
-
+
@@ -130,21 +130,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -161,7 +161,7 @@
-
+
Reference
diff --git a/docs/reference/POST_FATE.graphics.html b/docs/reference/POST_FATE.graphics.html
index f4fc54c..cc83146 100644
--- a/docs/reference/POST_FATE.graphics.html
+++ b/docs/reference/POST_FATE.graphics.html
@@ -79,7 +79,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -87,7 +87,7 @@
-
+
@@ -131,21 +131,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -162,7 +162,7 @@
-
+
Reference
diff --git a/docs/reference/POST_FATE.relativeAbund.html b/docs/reference/POST_FATE.relativeAbund.html
index 2ee81d5..5bbb9ed 100644
--- a/docs/reference/POST_FATE.relativeAbund.html
+++ b/docs/reference/POST_FATE.relativeAbund.html
@@ -76,7 +76,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -84,7 +84,7 @@
-
+
@@ -128,21 +128,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -159,7 +159,7 @@
-
+
Reference
diff --git a/docs/reference/POST_FATE.temporalEvolution.html b/docs/reference/POST_FATE.temporalEvolution.html
index f9a41e9..8d0d463 100644
--- a/docs/reference/POST_FATE.temporalEvolution.html
+++ b/docs/reference/POST_FATE.temporalEvolution.html
@@ -77,7 +77,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -85,7 +85,7 @@
-
+
@@ -129,21 +129,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -160,7 +160,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.abundBraunBlanquet.html b/docs/reference/PRE_FATE.abundBraunBlanquet.html
index d3ae094..5ecfd26 100644
--- a/docs/reference/PRE_FATE.abundBraunBlanquet.html
+++ b/docs/reference/PRE_FATE.abundBraunBlanquet.html
@@ -74,7 +74,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -82,7 +82,7 @@
-
+
@@ -126,21 +126,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -157,7 +157,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.params_PFGdispersal.html b/docs/reference/PRE_FATE.params_PFGdispersal.html
index 9aaa17c..9c9ee93 100644
--- a/docs/reference/PRE_FATE.params_PFGdispersal.html
+++ b/docs/reference/PRE_FATE.params_PFGdispersal.html
@@ -76,7 +76,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -84,7 +84,7 @@
-
+
@@ -128,21 +128,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -159,7 +159,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.params_PFGdisturbance.html b/docs/reference/PRE_FATE.params_PFGdisturbance.html
index 28bbb5b..bea9cb5 100644
--- a/docs/reference/PRE_FATE.params_PFGdisturbance.html
+++ b/docs/reference/PRE_FATE.params_PFGdisturbance.html
@@ -76,7 +76,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -84,7 +84,7 @@
-
+
@@ -128,21 +128,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -159,7 +159,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.params_PFGdrought.html b/docs/reference/PRE_FATE.params_PFGdrought.html
index 78b7e04..1d69ffa 100644
--- a/docs/reference/PRE_FATE.params_PFGdrought.html
+++ b/docs/reference/PRE_FATE.params_PFGdrought.html
@@ -76,7 +76,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -84,7 +84,7 @@
-
+
@@ -128,21 +128,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -159,7 +159,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.params_PFGlight.html b/docs/reference/PRE_FATE.params_PFGlight.html
index 4d98efc..e22e3f6 100644
--- a/docs/reference/PRE_FATE.params_PFGlight.html
+++ b/docs/reference/PRE_FATE.params_PFGlight.html
@@ -74,7 +74,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -82,7 +82,7 @@
-
+
@@ -126,21 +126,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -157,7 +157,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.params_PFGsoil.html b/docs/reference/PRE_FATE.params_PFGsoil.html
index d94ed8b..f0dc7b9 100644
--- a/docs/reference/PRE_FATE.params_PFGsoil.html
+++ b/docs/reference/PRE_FATE.params_PFGsoil.html
@@ -74,7 +74,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -82,7 +82,7 @@
-
+
@@ -126,21 +126,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -157,7 +157,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.params_PFGsuccession.html b/docs/reference/PRE_FATE.params_PFGsuccession.html
index d3104d7..bb77dbd 100644
--- a/docs/reference/PRE_FATE.params_PFGsuccession.html
+++ b/docs/reference/PRE_FATE.params_PFGsuccession.html
@@ -74,7 +74,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -82,7 +82,7 @@
-
+
@@ -126,21 +126,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -157,7 +157,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.params_changingYears.html b/docs/reference/PRE_FATE.params_changingYears.html
index 96c5132..bfc5fd3 100644
--- a/docs/reference/PRE_FATE.params_changingYears.html
+++ b/docs/reference/PRE_FATE.params_changingYears.html
@@ -77,7 +77,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -85,7 +85,7 @@
-
+
@@ -129,21 +129,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -160,7 +160,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.params_globalParameters.html b/docs/reference/PRE_FATE.params_globalParameters.html
index d41c784..8c5dc4f 100644
--- a/docs/reference/PRE_FATE.params_globalParameters.html
+++ b/docs/reference/PRE_FATE.params_globalParameters.html
@@ -75,7 +75,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -83,7 +83,7 @@
-
+
@@ -127,21 +127,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -158,7 +158,7 @@
-
+
Reference
@@ -246,7 +246,6 @@ Create Global_parameters parameter file for a FATE
doDrought = FALSE ,
DROUGHT.no_sub = 4 ,
doAliens = FALSE ,
- ALIEN.no ,
ALIEN.freq = 1 ,
doFire = FALSE ,
FIRE.no ,
@@ -487,11 +486,6 @@ Arg
default FALSE. If TRUE, invasive plant
introduction is activated in the FATE simulation, and associated
parameters are required
-
-
- ALIEN.no
- (optional ) an integer corresponding to the
-number of introductions
ALIEN.freq
@@ -679,7 +673,6 @@ Value
If the simulation includes aliens introduction :
DO_ALIENS_INTRODUCTION
-ALIENS_NO
ALIENS_FREQ
@@ -901,7 +894,6 @@ Details
introduction areas. If the habitat suitability filter is on,
suitability maps will also be needed for these new groups.
- ALIEN.no the number of different introductions
ALIEN.freq the frequency of each introduction (in years )
FIRE = to influence plant mortality and / or resprouting according
to PFG tolerances to these events (see
diff --git a/docs/reference/PRE_FATE.params_multipleSet.html b/docs/reference/PRE_FATE.params_multipleSet.html
index 282cc78..376234a 100644
--- a/docs/reference/PRE_FATE.params_multipleSet.html
+++ b/docs/reference/PRE_FATE.params_multipleSet.html
@@ -76,7 +76,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -84,7 +84,7 @@
opt.percent_maxAbund
@@ -506,7 +506,7 @@ Details
drawn in order to explore the whole space of combinations.
See also
- designLHD ,
+
@@ -83,7 +83,7 @@
-
+
@@ -127,21 +127,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -158,7 +158,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.params_simulParameters.html b/docs/reference/PRE_FATE.params_simulParameters.html
index d78b294..dcb8b13 100644
--- a/docs/reference/PRE_FATE.params_simulParameters.html
+++ b/docs/reference/PRE_FATE.params_simulParameters.html
@@ -75,7 +75,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -83,7 +83,7 @@
-
+
@@ -127,21 +127,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -158,7 +158,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.selectDominant.html b/docs/reference/PRE_FATE.selectDominant.html
index 8685da5..a8d4809 100644
--- a/docs/reference/PRE_FATE.selectDominant.html
+++ b/docs/reference/PRE_FATE.selectDominant.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.skeletonDirectory.html b/docs/reference/PRE_FATE.skeletonDirectory.html
index 3e22d6b..7d0f345 100644
--- a/docs/reference/PRE_FATE.skeletonDirectory.html
+++ b/docs/reference/PRE_FATE.skeletonDirectory.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.speciesClustering_step1.html b/docs/reference/PRE_FATE.speciesClustering_step1.html
index 949f0da..1d984ad 100644
--- a/docs/reference/PRE_FATE.speciesClustering_step1.html
+++ b/docs/reference/PRE_FATE.speciesClustering_step1.html
@@ -75,7 +75,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -83,7 +83,7 @@
-
+
@@ -127,21 +127,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -158,7 +158,7 @@
-
+
Reference
@@ -328,8 +328,8 @@ See a
Author
@@ -358,11 +358,11 @@ Examp
if ( FALSE ) {
require ( foreach )
require ( ggplot2 )
-require ( ggdendro )
+require ( ggdendro )
pp = foreach ( x = names ( sp.CLUST $ clust.dendrograms ) ) %do%
{
hc = sp.CLUST $ clust.dendrograms [[ x ] ]
- pp = ggdendrogram ( hc , rotate = TRUE ) +
+ pp = ggdendrogram ( hc , rotate = TRUE ) +
labs ( title = paste0 ( 'Hierarchical clustering based on species distance '
, ifelse ( length ( names ( sp.CLUST $ clust.dendrograms ) ) > 1
, paste0 ( '(group ' , x , ')' )
diff --git a/docs/reference/PRE_FATE.speciesClustering_step2.html b/docs/reference/PRE_FATE.speciesClustering_step2.html
index 1c90364..fd1514d 100644
--- a/docs/reference/PRE_FATE.speciesClustering_step2.html
+++ b/docs/reference/PRE_FATE.speciesClustering_step2.html
@@ -75,7 +75,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -83,7 +83,7 @@
-
+
@@ -127,21 +127,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -158,7 +158,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.speciesClustering_step3.html b/docs/reference/PRE_FATE.speciesClustering_step3.html
index 5cce1f2..67ea3e8 100644
--- a/docs/reference/PRE_FATE.speciesClustering_step3.html
+++ b/docs/reference/PRE_FATE.speciesClustering_step3.html
@@ -77,7 +77,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -85,7 +85,7 @@
-
+
@@ -129,21 +129,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -160,7 +160,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.speciesDistance.html b/docs/reference/PRE_FATE.speciesDistance.html
index 9523fc3..8a31690 100644
--- a/docs/reference/PRE_FATE.speciesDistance.html
+++ b/docs/reference/PRE_FATE.speciesDistance.html
@@ -76,7 +76,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -84,7 +84,7 @@
-
+
@@ -128,21 +128,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -159,7 +159,7 @@
-
+
Reference
@@ -388,11 +388,11 @@ Examp
str ( sp.DIST )
if ( FALSE ) {
-require ( foreach ) ; require ( ggplot2 ) ; require ( ggdendro )
+require ( foreach ) ; require ( ggplot2 ) ; require ( ggdendro )
pp = foreach ( x = names ( sp.DIST $ mat.ALL ) ) %do%
{
hc = hclust ( sp.DIST $ mat.ALL [[ x ] ] )
- pp = ggdendrogram ( hc , rotate = TRUE ) +
+ pp = ggdendrogram ( hc , rotate = TRUE ) +
labs ( title = paste0 ( 'Hierarchical clustering based on species distance '
, ifelse ( length ( names ( sp.DIST $ mat.ALL ) ) > 1
, paste0 ( '(group ' , x , ')' )
diff --git a/docs/reference/PRE_FATE.speciesDistanceCombine.html b/docs/reference/PRE_FATE.speciesDistanceCombine.html
index 6c77f5c..d4064a0 100644
--- a/docs/reference/PRE_FATE.speciesDistanceCombine.html
+++ b/docs/reference/PRE_FATE.speciesDistanceCombine.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
@@ -316,9 +316,9 @@ Examp
, is.corr = FALSE , title = names ( list.DIST ) [ li ] )
}
-require ( foreach ) ; require ( ggplot2 ) ; require ( ggdendro )
+require ( foreach ) ; require ( ggplot2 ) ; require ( ggdendro )
hc = hclust ( as.dist ( sp.DIST.n ) )
-pp = ggdendrogram ( hc , rotate = TRUE ) +
+pp = ggdendrogram ( hc , rotate = TRUE ) +
labs ( title = 'Hierarchical clustering based on species distances' )
plot ( pp )
}
diff --git a/docs/reference/PRE_FATE.speciesDistanceOverlap.html b/docs/reference/PRE_FATE.speciesDistanceOverlap.html
index 14c0030..b25f12a 100644
--- a/docs/reference/PRE_FATE.speciesDistanceOverlap.html
+++ b/docs/reference/PRE_FATE.speciesDistanceOverlap.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
diff --git a/docs/reference/PRE_FATE.speciesDistanceTraits.html b/docs/reference/PRE_FATE.speciesDistanceTraits.html
index 3140184..5d44a0c 100644
--- a/docs/reference/PRE_FATE.speciesDistanceTraits.html
+++ b/docs/reference/PRE_FATE.speciesDistanceTraits.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
@@ -307,11 +307,11 @@ Examp
str ( DIST.traits )
if ( FALSE ) {
-require ( foreach ) ; require ( ggplot2 ) ; require ( ggdendro )
+require ( foreach ) ; require ( ggplot2 ) ; require ( ggdendro )
pp = foreach ( x = names ( DIST.traits ) ) %do%
{
hc = hclust ( as.dist ( DIST.traits [[ x ] ] ) )
- pp = ggdendrogram ( hc , rotate = TRUE ) +
+ pp = ggdendrogram ( hc , rotate = TRUE ) +
labs ( title = paste0 ( 'Hierarchical clustering based on species distance '
, ifelse ( length ( names ( DIST.traits ) ) > 1
, paste0 ( '(group ' , x , ')' )
diff --git a/docs/reference/RFATE.html b/docs/reference/RFATE.html
index 4e78348..0fc225b 100644
--- a/docs/reference/RFATE.html
+++ b/docs/reference/RFATE.html
@@ -77,7 +77,7 @@
RFate
- 1.0.0
+ 1.0.2
@@ -85,7 +85,7 @@
-
+
@@ -129,21 +129,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -160,7 +160,7 @@
-
+
Reference
diff --git a/docs/reference/SAVE_FATE.step1_PFG.html b/docs/reference/SAVE_FATE.step1_PFG.html
index 3b00032..84c1ae4 100644
--- a/docs/reference/SAVE_FATE.step1_PFG.html
+++ b/docs/reference/SAVE_FATE.step1_PFG.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
diff --git a/docs/reference/SAVE_FATE.step2_parameters.html b/docs/reference/SAVE_FATE.step2_parameters.html
index c405cc1..d22e9d4 100644
--- a/docs/reference/SAVE_FATE.step2_parameters.html
+++ b/docs/reference/SAVE_FATE.step2_parameters.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
control
- list of controls: see designLHD
+ list of controls: see designLHD
See also
-
+
@@ -82,7 +82,7 @@
-
+
@@ -126,21 +126,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -157,7 +157,7 @@
-
+
Reference
diff --git a/docs/reference/dot-adaptMaps.html b/docs/reference/dot-adaptMaps.html
index d5e391a..e2af401 100644
--- a/docs/reference/dot-adaptMaps.html
+++ b/docs/reference/dot-adaptMaps.html
@@ -76,7 +76,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -84,7 +84,7 @@
-
+
@@ -128,21 +128,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -159,7 +159,7 @@
-
+
Reference
diff --git a/docs/reference/dot-createParams.html b/docs/reference/dot-createParams.html
index 2c80040..40bfbdb 100644
--- a/docs/reference/dot-createParams.html
+++ b/docs/reference/dot-createParams.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
diff --git a/docs/reference/dot-getCutoff.html b/docs/reference/dot-getCutoff.html
index a615e96..5975d96 100644
--- a/docs/reference/dot-getCutoff.html
+++ b/docs/reference/dot-getCutoff.html
@@ -74,7 +74,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -82,7 +82,7 @@
-
+
@@ -126,21 +126,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -157,7 +157,7 @@
-
+
Reference
diff --git a/docs/reference/dot-getELLIPSE.html b/docs/reference/dot-getELLIPSE.html
index 49cae35..6cad15e 100644
--- a/docs/reference/dot-getELLIPSE.html
+++ b/docs/reference/dot-getELLIPSE.html
@@ -72,7 +72,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -80,7 +80,7 @@
-
+
@@ -124,21 +124,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -155,7 +155,7 @@
-
+
Reference
diff --git a/docs/reference/dot-getOS.html b/docs/reference/dot-getOS.html
index 7fc80c1..a7976a7 100644
--- a/docs/reference/dot-getOS.html
+++ b/docs/reference/dot-getOS.html
@@ -74,7 +74,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -82,7 +82,7 @@
-
+
@@ -126,21 +126,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -157,7 +157,7 @@
-
+
Reference
diff --git a/docs/reference/dot-getParam.html b/docs/reference/dot-getParam.html
index e726ce3..cc2921d 100644
--- a/docs/reference/dot-getParam.html
+++ b/docs/reference/dot-getParam.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
diff --git a/docs/reference/dot-loadData.html b/docs/reference/dot-loadData.html
index a3224dd..eb7585e 100644
--- a/docs/reference/dot-loadData.html
+++ b/docs/reference/dot-loadData.html
@@ -84,7 +84,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -92,7 +92,7 @@
-
+
@@ -136,21 +136,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -167,7 +167,7 @@
-
+
Reference
diff --git a/docs/reference/dot-loadPackage.html b/docs/reference/dot-loadPackage.html
index 43c3fb9..24947d5 100644
--- a/docs/reference/dot-loadPackage.html
+++ b/docs/reference/dot-loadPackage.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
diff --git a/docs/reference/dot-scaleMaps.html b/docs/reference/dot-scaleMaps.html
index e131929..b9b2e2c 100644
--- a/docs/reference/dot-scaleMaps.html
+++ b/docs/reference/dot-scaleMaps.html
@@ -76,7 +76,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -84,7 +84,7 @@
-
+
@@ -128,21 +128,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -159,7 +159,7 @@
-
+
Reference
diff --git a/docs/reference/dot-setParam.html b/docs/reference/dot-setParam.html
index a9c0317..fb433f3 100644
--- a/docs/reference/dot-setParam.html
+++ b/docs/reference/dot-setParam.html
@@ -73,7 +73,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -81,7 +81,7 @@
-
+
@@ -125,21 +125,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -156,7 +156,7 @@
-
+
Reference
diff --git a/docs/reference/dot-setPattern.html b/docs/reference/dot-setPattern.html
index 154ecfe..e71f67b 100644
--- a/docs/reference/dot-setPattern.html
+++ b/docs/reference/dot-setPattern.html
@@ -75,7 +75,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -83,7 +83,7 @@
-
+
@@ -127,21 +127,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -158,7 +158,7 @@
-
+
Reference
diff --git a/docs/reference/dot-unzip_ALL.html b/docs/reference/dot-unzip_ALL.html
index 8a6e6c7..1c5cced 100644
--- a/docs/reference/dot-unzip_ALL.html
+++ b/docs/reference/dot-unzip_ALL.html
@@ -75,7 +75,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -83,7 +83,7 @@
-
+
@@ -127,21 +127,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -158,7 +158,7 @@
-
+
Reference
diff --git a/docs/reference/dunn.html b/docs/reference/dunn.html
index c79d9fc..87f3f7e 100644
--- a/docs/reference/dunn.html
+++ b/docs/reference/dunn.html
@@ -72,7 +72,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -80,7 +80,7 @@
-
+
@@ -124,21 +124,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -155,7 +155,7 @@
-
+
Reference
@@ -222,7 +222,7 @@ Arg
See also
-
+
@@ -86,7 +86,7 @@
-
+
@@ -130,21 +130,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -161,7 +161,7 @@
-
+
Reference
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 08f6ff8..a9f8f08 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -71,7 +71,7 @@
RFate
- 1.0.1
+ 1.0.2
@@ -79,7 +79,7 @@
-
+
@@ -123,21 +123,21 @@
-
+
Build PFG
-
+
Build parameter files
-
+
Build graphics
@@ -154,7 +154,7 @@
-
+
Reference
diff --git a/man/FATE_RS.Rd b/man/FATE_RS.Rd
new file mode 100644
index 0000000..983d466
--- /dev/null
+++ b/man/FATE_RS.Rd
@@ -0,0 +1,41 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/FATE_RS.R
+\name{FATE_RS}
+\alias{FATE_RS}
+\title{S}
+\usage{
+FATE_RS(
+ name.simulation,
+ file.simulParam,
+ opt.no_CPU = 1,
+ verbose.level = 2,
+ PPM.names_PFG,
+ PPM.ras_env,
+ PPM.xy,
+ PPM.mod,
+ PATCH.threshold = 80,
+ PATCH.buffer = 500,
+ PATCH.min_m2 = 3e+05,
+ COST.ras_elev,
+ COST.ras_barr,
+ COST.wei = c(0.43, 0.53, 0.04),
+ COST.range = c(1, 10),
+ RS.name_simul,
+ RS.dens_dep,
+ RS.sim,
+ RS.demo,
+ RS.disp,
+ RS.init,
+ POP.carrying_capacity = 0.115,
+ year.start,
+ year.end,
+ year.step
+)
+}
+\description{
+...
+}
+\author{
+Maya Guéguen
+}
+\keyword{RangeShifter}
diff --git a/man/PRE_FATE.params_globalParameters.Rd b/man/PRE_FATE.params_globalParameters.Rd
index c70f136..b296022 100644
--- a/man/PRE_FATE.params_globalParameters.Rd
+++ b/man/PRE_FATE.params_globalParameters.Rd
@@ -42,7 +42,6 @@ PRE_FATE.params_globalParameters(
doDrought = FALSE,
DROUGHT.no_sub = 4,
doAliens = FALSE,
- ALIEN.no,
ALIEN.freq = 1,
doFire = FALSE,
FIRE.no,
@@ -210,9 +209,6 @@ to the number of way a PFG could react to a drought disturbance}
introduction is activated in the \code{FATE} simulation, and associated
parameters are required}
-\item{ALIEN.no}{(\emph{optional}) \cr an \code{integer} corresponding to the
-number of introductions}
-
\item{ALIEN.freq}{(\emph{optional}) \cr a \code{vector} of \code{integer}
corresponding to the frequency of each introduction (\emph{in years})}
@@ -373,7 +369,6 @@ If the simulation includes \emph{aliens introduction} :
\itemize{
\item DO_ALIENS_INTRODUCTION
- \item ALIENS_NO
\item ALIENS_FREQ
}
@@ -624,7 +619,6 @@ file, and if so, some additional parameters will be required :
introduction areas. \cr If the habitat suitability filter is on,
suitability maps will also be needed for these new groups.
\describe{
- \item{ALIEN.no}{the number of different introductions}
\item{ALIEN.freq}{the frequency of each introduction (\emph{in years})}
}
}
diff --git a/man/PRE_FATE.speciesClustering_step1.Rd b/man/PRE_FATE.speciesClustering_step1.Rd
index 0774681..a60607f 100644
--- a/man/PRE_FATE.speciesClustering_step1.Rd
+++ b/man/PRE_FATE.speciesClustering_step1.Rd
@@ -4,7 +4,7 @@
\alias{PRE_FATE.speciesClustering_step1}
\title{Create clusters based on dissimilarity matrix}
\usage{
-PRE_FATE.speciesClustering_step1(mat.species.DIST)
+PRE_FATE.speciesClustering_step1(mat.species.DIST, opt.no_clust_max = 15)
}
\arguments{
\item{mat.species.DIST}{a \code{dist} object, or a \code{list} of
diff --git a/man/PRE_FATE.speciesDistanceCombine.Rd b/man/PRE_FATE.speciesDistanceCombine.Rd
index c32d6a8..f251ff7 100644
--- a/man/PRE_FATE.speciesDistanceCombine.Rd
+++ b/man/PRE_FATE.speciesDistanceCombine.Rd
@@ -6,6 +6,7 @@
\usage{
PRE_FATE.speciesDistanceCombine(
list.mat.dist,
+ opt.min.noMat = length(list.mat.dist),
opt.normal = TRUE,
opt.weights = NULL
)
@@ -14,6 +15,10 @@ PRE_FATE.speciesDistanceCombine(
\item{list.mat.dist}{a \code{list} of matrices containing dissimilarity
distance values between each pair of species.}
+\item{opt.min.noMat}{(\emph{optional}) default \code{length(list.mat.dist)}. \cr
+An \code{integer} corresponding to the minimal number of distance matrices for
+which each species should have values}
+
\item{opt.normal}{(\emph{optional}) default \code{TRUE}. \cr
If \code{TRUE}, all given distance matrices will be normalized
(see \href{PRE_FATE.speciesDistanceCombine#details}{\code{Details}})}
diff --git a/src/FG.h b/src/FG.h
index 09eb8c0..16de0cb 100644
--- a/src/FG.h
+++ b/src/FG.h
@@ -97,7 +97,7 @@ class FG
double m_SoilContrib; /*!< Contribution of PFG to refill soil nutriment resources (kind of litter index) */
double m_SoilLow; /*!< Contribution of PFG to refill soil nutriment resources (kind of litter index) */
double m_SoilHigh; /*!< Contribution of PFG to refill soil nutriment resources (kind of litter index) */
- vector m_SoilActiveGerm; /*!< Proportion of Active seeds able to germinate considering light resources [Rcount] */
+ vector m_SoilActiveGerm; /*!< Proportion of Active seeds able to germinate considering soil nutriment resources [Rcount] */
vector< vector > m_SoilTolerance; /*!< Is FG survived considering available soil nutriment resources [LScount][Rcount] */
/* Disturbance response */
diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp
index a09c958..9fc0157 100644
--- a/src/RcppExports.cpp
+++ b/src/RcppExports.cpp
@@ -1,6 +1,7 @@
// Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
+#include
#include
using namespace Rcpp;
diff --git a/src/SimulMap.cpp b/src/SimulMap.cpp
index 76cc5b8..4d1ad92 100644
--- a/src/SimulMap.cpp
+++ b/src/SimulMap.cpp
@@ -1483,46 +1483,115 @@ void SimulMap::UpdateSimulationParameters(FOPL file_of_params)
GSP old_glob_params(m_glob_params);
/* read new global parameters file */
+ logg.info("*** REBUILDING Global simulation parameters...");
m_glob_params = GSP(file_of_params.getGlobSimulParams());
- /* check some parameters compatibility */
+ /* check some parameters compatibility (between SAVED_STATE and "new" global parameter file) */
if (old_glob_params.getNoFG() != m_glob_params.getNoFG())
{
- logg.error("!!! Number of functional groups involved in saved object (",
- old_glob_params.getNoFG(),
- ") is incompatible with new parameters (",
- m_glob_params.getNoFG(), ")!");
+ logg.error("!!! Number of functional groups involved in saved object (", old_glob_params.getNoFG(),
+ ") is incompatible with new parameters (", m_glob_params.getNoFG(), ")!");
}
- if (old_glob_params.getDoHabSuitability() != m_glob_params.getDoHabSuitability())
+ if (old_glob_params.getNoStrata() != m_glob_params.getNoStrata())
{
- logg.error("!!! Succession model involved in saved object (",
- old_glob_params.getDoHabSuitability(),
- ") is incompatible with new parameters (",
- m_glob_params.getDoHabSuitability(), ")!");
+ logg.error("!!! Number of strata involved in saved object (", old_glob_params.getNoStrata(),
+ ") is incompatible with new parameters (", m_glob_params.getNoStrata(), ")!");
}
- if (old_glob_params.getNoStrata() != m_glob_params.getNoStrata())
+ if (m_glob_params.getDoDisturbances())
+ {
+ if (old_glob_params.getNoDist() != m_glob_params.getNoDist())
+ {
+ logg.error("!!! Number of disturbances involved in saved object (", old_glob_params.getNoDist(),
+ ") is incompatible with new parameters (", m_glob_params.getNoDist(), ")!");
+ }
+ if (old_glob_params.getNoDistSub() != m_glob_params.getNoDistSub())
+ {
+ logg.error("!!! Number of way to be influenced by disturbances involved in saved object (", old_glob_params.getNoDistSub(),
+ ") is incompatible with new parameters (", m_glob_params.getNoDistSub(), ")!");
+ }
+ }
+ if (m_glob_params.getDoDroughtDisturbances())
+ {
+ if (old_glob_params.getNoDroughtSub() != m_glob_params.getNoDroughtSub())
+ {
+ logg.error("!!! Number of way to be influenced by drought disturbances involved in saved object (", old_glob_params.getNoDroughtSub(),
+ ") is incompatible with new parameters (", m_glob_params.getNoDroughtSub(), ")!");
+ }
+ }
+ if (m_glob_params.getDoFireDisturbances())
+ {
+ if (old_glob_params.getNoFireDist() != m_glob_params.getNoFireDist())
+ {
+ logg.error("!!! Number of fire disturbances involved in saved object (", old_glob_params.getNoFireDist(),
+ ") is incompatible with new parameters (", m_glob_params.getNoFireDist(), ")!");
+ }
+ if (old_glob_params.getNoFireDistSub() != m_glob_params.getNoFireDistSub())
+ {
+ logg.error("!!! Number of way to be influenced by fire disturbances involved in saved object (", old_glob_params.getNoFireDistSub(),
+ ") is incompatible with new parameters (", m_glob_params.getNoFireDistSub(), ")!");
+ }
+ }
+ /* end of check parameters compatibility */
+
+ /* check some parameters compatibility (between "new" global and simul parameter files) */
+ int noFG = m_glob_params.getNoFG();
+ if (noFG != file_of_params.getFGLifeHistory().size())
+ {
+ logg.error("!!! Parameters NO_PFG (", noFG, ") and --PFG_PARAMS_LIFE_HISTORY-- (",
+ file_of_params.getFGLifeHistory().size(), ") do not match in term of number!");
+ }
+ if (m_glob_params.getDoLightInteraction() && noFG != file_of_params.getFGLight().size())
{
- logg.error("!!! Number of strata involved in saved object (",
- old_glob_params.getNoStrata(),
- ") is incompatible with new parameters (",
- m_glob_params.getNoStrata(), ")!");
+ logg.error("!!! Parameters NO_PFG (", noFG, ") and --PFG_PARAMS_LIGHT-- (",
+ file_of_params.getFGLight().size(), ") do not match in term of number!");
}
- if (old_glob_params.getNoDist() != m_glob_params.getNoDist())
+ if (m_glob_params.getDoSoilInteraction() && noFG != file_of_params.getFGSoil().size())
{
- logg.error("!!! Number of disturbances involved in saved object (",
- old_glob_params.getNoDist(),
- ") is incompatible with new parameters (",
- m_glob_params.getNoDist(), ")!");
+ logg.error("!!! Parameters NO_PFG (", noFG, ") and --PFG_PARAMS_SOIL-- (",
+ file_of_params.getFGSoil().size(), ") do not match in term of number!");
}
- if (old_glob_params.getNoDistSub() != m_glob_params.getNoDistSub())
+ if (m_glob_params.getDoDispersal() && noFG != file_of_params.getFGDispersal().size())
{
- logg.error("!!! Number of way to be influence by disturbances involved in saved object (",
- old_glob_params.getNoDistSub(),
- ") is incompatible with new parameters (",
- m_glob_params.getNoDistSub(), ")");
+ logg.error("!!! Parameters NO_PFG (", noFG, ") and --PFG_PARAMS_DISPERSAL-- (",
+ file_of_params.getFGDispersal().size(), ") do not match in term of number!");
+ }
+ if (m_glob_params.getDoDisturbances() && noFG != file_of_params.getFGDisturbance().size())
+ {
+ logg.error("!!! Parameters NO_PFG (", noFG, ") and --PFG_PARAMS_DISTURBANCES-- (",
+ file_of_params.getFGDisturbance().size(), ") do not match in term of number!");
+ }
+ if (m_glob_params.getDoDroughtDisturbances() && noFG != file_of_params.getFGDrought().size())
+ {
+ logg.error("!!! Parameters NO_PFG (", noFG, ") and --PFG_PARAMS_DROUGHT-- (",
+ file_of_params.getFGDrought().size(), ") do not match in term of number!");
+ }
+ if (m_glob_params.getDoFireDisturbances() && noFG != file_of_params.getFGFire().size())
+ {
+ logg.error("!!! Parameters NO_PFG (", noFG, ") and --PFG_PARAMS_FIRE-- (",
+ file_of_params.getFGFire().size(), ") do not match in term of number!");
+ }
+ if (m_glob_params.getDoHabSuitability() && noFG != file_of_params.getFGMapsHabSuit().size())
+ {
+ logg.error("!!! Parameters NO_PFG (", noFG, ") and --PFG_MASK_HABSUIT-- (",
+ file_of_params.getFGMapsHabSuit().size(), ") do not match in term of number!");
+ }
+ if (m_glob_params.getDoAliensIntroduction() && noFG != file_of_params.getFGMapsAliens().size())
+ {
+ logg.error("!!! Parameters NO_PFG (", noFG, ") and --PFG_MASK_ALIENS-- (",
+ file_of_params.getFGMapsAliens().size(), ") do not match in term of number!");
}
/* end of check parameters compatibility */
+ /* check for parameters file */
+ file_of_params.checkCorrectParams(m_glob_params.getDoLightInteraction(),
+ m_glob_params.getDoHabSuitability(),
+ m_glob_params.getDoDispersal(),
+ m_glob_params.getDoDisturbances(),
+ m_glob_params.getDoSoilInteraction(),
+ m_glob_params.getDoFireDisturbances(),
+ m_glob_params.getDoDroughtDisturbances(),
+ m_glob_params.getDoAliensIntroduction());
+
/* update fg environmental suitability conditions if needed */
if (file_of_params.getFGMapsHabSuit()[0] != "0")
{ // some new initial envsuit conditions given
@@ -1576,6 +1645,45 @@ void SimulMap::UpdateSimulationParameters(FOPL file_of_params)
}
}
+ /* build simulation fire disturbances masks */
+ // if (m_glob_params.getDoFireDisturbances())
+ // {
+ // if (m_glob_params.getFireIgnitMode()==5)
+ // {
+ // logg.info("> build simulation fire disturbances masks...");
+ // if (m_glob_params.getNoFireDist() == file_of_params.getMaskFire().size())
+ // {
+ // vector< vector< int > > fireMap; // fire disturbances masks
+ // fireMap.reserve(m_glob_params.getNoFireDist());
+ // for (int dist_id=0; dist_id( file_of_params.getMaskFire()[dist_id], 0.0, 1.0 ) );
+ // }
+ // m_FireMap = SpatialStack(m_Coord_ptr, fireMap);
+ // } else
+ // {
+ // logg.error("!!! Parameters FIRE_NO and --FIRE_MASK-- ",
+ // "do not match in term of number!");
+ // }
+ // } else
+ // {
+ // m_FireMap = SpatialStack(m_Coord_ptr, emptyMapInt);
+ // }
+ //
+ // /* build fire masks */
+ // logg.info("> build fire masks...");
+ // if (m_glob_params.getFirePropMode()==4)
+ // {
+ // m_DroughtMap = SpatialMap(m_Coord_ptr, ReadMask( file_of_params.getMaskDrought(), 0.0, 1.0 ) );
+ // m_ElevationMap = SpatialMap(m_Coord_ptr, ReadMask( file_of_params.getMaskElevation()) );
+ // m_SlopeMap = SpatialMap(m_Coord_ptr, ReadMask( file_of_params.getMaskSlope()) );
+ // }
+ //
+ // /* build TSLF mask (study area) */
+ // logg.info("> build TSLF mask (study area)...");
+ // m_TslfMap = SpatialMap(m_Coord_ptr, ReadMask( file_of_params.getMask(), 0.0, 1.0 ) );
+ // }
+
/* build aliens introduction masks */
if (file_of_params.getFGMapsAliens()[0] != "0")
{
@@ -1763,10 +1871,10 @@ void SimulMap::SaveRasterAbund(string saveDir, int year, string prevFile)
delete [] abunValues2;
} // end loop on PFG
- if (!positiveVal12)
- {
- logg.error("!!! ALL PFG DIED! Stopping simulation.");
- }
+ // if (!positiveVal12 && year > m_glob_params.getSeedingDuration())
+ // {
+ // logg.error("!!! ALL PFG DIED! Stopping simulation.");
+ // }
}
if (m_glob_params.getDoSavingStratum())
@@ -1829,10 +1937,10 @@ void SimulMap::SaveRasterAbund(string saveDir, int year, string prevFile)
delete [] abunValues3;
} // end loop on Stratum*/
- if (!positiveVal33)
- {
- logg.error("!!! ALL PFG DIED! Stopping simulation.");
- }
+ // if (!positiveVal33 && year > m_glob_params.getSeedingDuration())
+ // {
+ // logg.error("!!! ALL PFG DIED! Stopping simulation.");
+ // }
}
}
diff --git a/src/main_rcpp.cpp b/src/main_rcpp.cpp
index 53871be..411cb8b 100644
--- a/src/main_rcpp.cpp
+++ b/src/main_rcpp.cpp
@@ -478,45 +478,6 @@ int FATE(std::string simulParam, int no_CPU = 1, int verboseLevel = 0)
GSP glob_params = GSP(file_of_params.getGlobSimulParams());
int noFG = glob_params.getNoFG();
logg.info("*** REBUILDING Functional groups...");
- if (noFG != file_of_params.getFGLifeHistory().size())
- {
- logg.error("!!! Parameters NO_PFG (", noFG,
- ") and --PFG_PARAMS_LIFE_HISTORY-- (",
- file_of_params.getFGLifeHistory().size(),
- ") do not match in term of number!");
- }
- if (glob_params.getDoDispersal() &&
- noFG != file_of_params.getFGDispersal().size())
- {
- logg.error("!!! Parameters NO_PFG (", noFG,
- ") and --PFG_PARAMS_DISPERSAL-- (",
- file_of_params.getFGDispersal().size(),
- ") do not match in term of number!");
- }
- if (glob_params.getDoDisturbances() &&
- noFG != file_of_params.getFGDisturbance().size())
- {
- logg.error("!!! Parameters NO_PFG (", noFG,
- ") and --PFG_PARAMS_DISTURBANCES-- (",
- file_of_params.getFGDisturbance().size(),
- ") do not match in term of number!");
- }
- if (glob_params.getDoFireDisturbances() &&
- noFG != file_of_params.getFGFire().size())
- {
- logg.error("!!! Parameters NO_PFG (", noFG,
- ") and --PFG_PARAMS_FIRE-- (",
- file_of_params.getFGFire().size(),
- ") do not match in term of number!");
- }
- if (glob_params.getDoDroughtDisturbances() &&
- noFG != file_of_params.getFGDrought().size())
- {
- logg.error("!!! Parameters NO_PFG (", noFG,
- ") and --PFG_PARAMS_DROUGHT-- (",
- file_of_params.getFGDrought().size(),
- ") do not match in term of number!");
- }
vector fg_vec_tmp;
for (int fg_id=0; fg_id 0")
})
-## INPUTS
-test_that("PRE_FATE.params_globalParameters gives error with wrong data : ALIEN.no", {
-
- ## TEST ALIEN.no : integer
- expect_error(PRE_FATE.params_globalParameters(name.simulation = "FATE_simulation"
- , required.no_PFG = 5
- , required.no_strata = 2
- , required.max_abund_low = 3000
- , required.max_abund_medium = 5000
- , required.max_abund_high = 9000
- , doAliens = T
- , ALIEN.no = NA)
- , "`ALIEN.no` must be an integer > 0")
- expect_error(PRE_FATE.params_globalParameters(name.simulation = "FATE_simulation"
- , required.no_PFG = 5
- , required.no_strata = 2
- , required.max_abund_low = 3000
- , required.max_abund_medium = 5000
- , required.max_abund_high = 9000
- , doAliens = T
- , ALIEN.no = NULL)
- , "`ALIEN.no` must be an integer > 0")
- expect_error(PRE_FATE.params_globalParameters(name.simulation = "FATE_simulation"
- , required.no_PFG = 5
- , required.no_strata = 2
- , required.max_abund_low = 3000
- , required.max_abund_medium = 5000
- , required.max_abund_high = 9000
- , doAliens = T
- , ALIEN.no = "")
- , "`ALIEN.no` must be an integer > 0")
-})
## INPUTS
test_that("PRE_FATE.params_globalParameters gives error with wrong data : ALIEN.freq", {
@@ -766,9 +734,8 @@ test_that("PRE_FATE.params_globalParameters gives error with wrong data : ALIEN.
, required.max_abund_low = 3000
, required.max_abund_medium = 5000
, required.max_abund_high = 9000
- , doAliens = T
- , ALIEN.no = 2)
- , "`ALIEN.freq` must contain as many values as the number of introductions (`ALIEN.no`)"
+ , doAliens = T)
+ , "`ALIEN.freq` must contain as many values as the number of PFG (`required.no_PFG`)"
, fixed = TRUE)
expect_error(PRE_FATE.params_globalParameters(name.simulation = "FATE_simulation"
, required.no_PFG = 5
@@ -777,7 +744,6 @@ test_that("PRE_FATE.params_globalParameters gives error with wrong data : ALIEN.
, required.max_abund_medium = 5000
, required.max_abund_high = 9000
, doAliens = T
- , ALIEN.no = 2
, ALIEN.freq = NA)
, "`ALIEN.freq` must be an integer > 0")
expect_error(PRE_FATE.params_globalParameters(name.simulation = "FATE_simulation"
@@ -787,7 +753,6 @@ test_that("PRE_FATE.params_globalParameters gives error with wrong data : ALIEN.
, required.max_abund_medium = 5000
, required.max_abund_high = 9000
, doAliens = T
- , ALIEN.no = 2
, ALIEN.freq = NULL)
, "`ALIEN.freq` must be an integer > 0")
expect_error(PRE_FATE.params_globalParameters(name.simulation = "FATE_simulation"
@@ -797,7 +762,6 @@ test_that("PRE_FATE.params_globalParameters gives error with wrong data : ALIEN.
, required.max_abund_medium = 5000
, required.max_abund_high = 9000
, doAliens = T
- , ALIEN.no = 2
, ALIEN.freq = "")
, "`ALIEN.freq` must be an integer > 0")
@@ -809,9 +773,8 @@ test_that("PRE_FATE.params_globalParameters gives error with wrong data : ALIEN.
, required.max_abund_medium = 5000
, required.max_abund_high = 9000
, doAliens = T
- , ALIEN.no = 2
, ALIEN.freq = 2)
- , "`ALIEN.freq` must contain as many values as the number of introductions (`ALIEN.no`)"
+ , "`ALIEN.freq` must contain as many values as the number of PFG (`required.no_PFG`)"
, fixed = TRUE)
})
@@ -1706,7 +1669,6 @@ test_that("PRE_FATE.params_globalParameters gives correct output : scenario modu
, required.max_abund_medium = 5000
, required.max_abund_high = 9000
, doAliens = TRUE
- , ALIEN.no = 10
, ALIEN.freq = rep(1, 10))
, "The parameter file FATE_simulation/DATA/GLOBAL_PARAMETERS/Global_parameters_V1.txt has been successfully created !")
diff --git a/tests/testthat/test-PRE_FATE.params_simulParameters.R b/tests/testthat/test-PRE_FATE.params_simulParameters.R
index c11018a..6e01f88 100644
--- a/tests/testthat/test-PRE_FATE.params_simulParameters.R
+++ b/tests/testthat/test-PRE_FATE.params_simulParameters.R
@@ -116,7 +116,6 @@ test_that("PRE_FATE.params_simulParameters gives error with wrong data : folders
, doDrought = TRUE
, DROUGHT.no_sub = 2
, doAliens = TRUE
- , ALIEN.no = 1
, ALIEN.freq = 1
, doFire = TRUE
, FIRE.no = 1