FATE simulationR/PRE_FATE.params_PFGdispersal.R
    PRE_FATE.params_PFGdispersal.RdThis script is designed to create parameter files containing
dispersal distances for each PFG (one file for each of them) used in the
dispersal module of FATE.
PRE_FATE.params_PFGdispersal(
  name.simulation,
  mat.PFG.disp,
  opt.folder.name = NULL
)a string corresponding to the main directory
or simulation name of the FATE simulation
a data.frame with 4 columns : PFG,
d50, d99, ldd
(optional) 
 a string corresponding
to the name of the folder that will be created into the
name.simulation/DATA/PFGS/DISP/ directory to store the results
A .txt file per PFG into the
name.simulation/DATA/PFGS/DISP/ directory with the following
parameters :
dispersal distances (3 values) (in meters)
  
A DISP_COMPLETE_TABLE.csv file summarizing information for all
groups into the name.simulation/DATA/PFGS/ directory.
If the opt.folder.name has been used, the files will be into the
folder name.simulation/DATA/PFGS/DISP/opt.folder.name/.
A dispersal module is available to make the FATE model
spatially explicit by dispersing seeds of each PFG with a kernel (see
PRE_FATE.params_globalParameters). 
Dispersal distances are needed for each PFG to quantify the amount of seeds dispersed into 3 different concentric circles :
the distance at which 50% of seeds are dispersed
the distance at which 99% of seeds are dispersed
the long dispersal distance at which 100% of seeds are dispersed
## Create a skeleton folder with the default name ('FATE_simulation')
PRE_FATE.skeletonDirectory()
mat.disp = data.frame(PFG = paste0('PFG', 1:6)
                      , d50 = c(10, 25, 100, 100, 500, 1000)
                      , d99 = c(500, 600, 300, 300, 1250, 1200)
                      , ldd = c(1500, 1500, 900, 900, 1500, 2000))
## Create PFG dispersal parameter files -----------------------------------------------------
PRE_FATE.params_PFGdispersal(name.simulation = 'FATE_simulation'
                             , mat.PFG.disp = mat.disp)
                                                        
                                                        
## -------------------------------------------------------------------------------------------
# ## Load example data
# Champsaur_PFG = .loadData('Champsaur_PFG', 'RData')
#
# ## Build PFG traits for dispersal
# tab.traits = Champsaur_PFG$PFG.traits
# ## Dispersal values
# ##   = Short: 0.1-2m;    Medium: 40-100m;    Long: 400-500m
# ##   = Vittoz correspondance : 1-3: Short;    4-5: Medium;   6-7:Long
# corres = data.frame(dispersal = 1:7
#                     , d50 = c(0.1, 0.5, 2, 40, 100, 400, 500)
#                     , d99 = c(1, 5, 15, 150, 500, 1500, 5000)
#                     , ldd = c(1000, 1000, 1000, 5000, 5000, 10000, 10000))
# tab.traits$d50 = corres$d50[tab.traits$dispersal]
# tab.traits$d99 = corres$d99[tab.traits$dispersal]
# tab.traits$ldd = corres$ldd[tab.traits$dispersal]
# str(tab.traits)
## Load example data
Champsaur_params = .loadData('Champsaur_params', 'RData')
## Create a skeleton folder
PRE_FATE.skeletonDirectory(name.simulation = 'FATE_Champsaur')
## PFG traits for dispersal
tab.disp = Champsaur_params$tab.DISP
str(tab.disp)
## Create PFG dispersal parameter files ------------------------------------------------------
PRE_FATE.params_PFGdispersal(name.simulation = 'FATE_Champsaur'
                             , mat.PFG.disp = Champsaur_params$tab.DISP)