diff --git a/DESCRIPTION b/DESCRIPTION index 993cee7e..7679a795 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: osmose Type: Package Title: Object Oriented Simulator of Marine Ecosystems -Version: 3.3.3 +Version: 3.3.4 Date: 2020-04-03 Authors@R: c(person(given = "Yunne-Jai", @@ -66,7 +66,6 @@ Imports: utils, ncdf4, mgcv, - rappdirs, fields URL: http://www.osmose-model.org/ LazyData: FALSE diff --git a/NAMESPACE b/NAMESPACE index 33cbb12d..fe4773d0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -43,7 +43,6 @@ importFrom(ncdf4,ncdim_def) importFrom(ncdf4,ncvar_def) importFrom(ncdf4,ncvar_get) importFrom(ncdf4,ncvar_put) -importFrom(rappdirs,user_data_dir) importFrom(rlist,list.merge) importFrom(rmarkdown,render) importFrom(stats,dlnorm) diff --git a/R/aaa-.R b/R/aaa-.R index dd83ba4f..c51636ab 100644 --- a/R/aaa-.R +++ b/R/aaa-.R @@ -22,5 +22,3 @@ NULL NULL #' @importFrom fields image.plot tim.colors NULL -#' @importFrom rappdirs user_data_dir -NULL \ No newline at end of file diff --git a/R/cacheManager.R b/R/cacheManager.R index e96b8e0c..04009029 100644 --- a/R/cacheManager.R +++ b/R/cacheManager.R @@ -4,13 +4,12 @@ #' placed in this folder. #' #' @section Localisation: -#' The localisation of the folder is : -#' - On Linux : `~/.local/share/R/osmose` -#' - On Mac OS X : `~/Library/Application Support/R/osmose` -#' - On Windows 7 up to 10 : `C:\\Users\\\\AppData\\Local\\R\\BIOMASS\\R\\osmose` -#' - On Windows XP : `C:\\Documents and Settings\\\\Data\\R\\BIOMASS\\R\\osmose` +#' The localisation of the folder is defined in the `.Renviron` file, by setting the `OSMOSE_DIR` +#' environment variable: +#' - On Linux/Mac Os X : `OSMOSE_DIR=/Users/Nicolas/Desktop/OSMOSE_TEST/R` +#' - On Windows: `OSMOSE_DIR=C:\\Users\\Nicolas\\Desktop\\OSMOSE_TEST\\R` #' -#' See this function for more information : [rappdirs::user_data_dir()] [BIOMASS::cacheManager(nameFile)] +#' If this variable is not set, the files will be downloaded into a temporary directory. #' #' @param nameFile the name of the file or folder #' @@ -18,7 +17,6 @@ #' #' @author Arthur PERE #' @author Nicolas BARRIER -#' @seealso [rappdirs::user_data_dir()][BIOMASS::cacheManager(nameFile)] #' #' @keywords Internal #' @export @@ -58,17 +56,30 @@ cacheManager <- function(nameFile) { } -#' @importFrom rappdirs user_data_dir #' @keywords Internal cachePath <- function(path = NULL) { - # give the path of the cache - basePath <- user_data_dir(file.path("R", "osmose")) + + # give the path of OSMOSE_DIR + # If variable is not set, then points to a temporary directory. + if(Sys.getenv("OSMOSE_DIR") == "") { + tdir = tempdir() + Sys.setenv(OSMOSE_DIR=tdir) + message("The OSMOSE_DIR Renviron variable was set to ", tdir) + } + + # Recover the paths to the OSMOSE_DIR and creates + # it if needed + basePath = Sys.getenv("OSMOSE_DIR") + if (!is.null(path)) { basePath <- file.path(basePath, path) } + basePath + } + #' @keywords Internal flushCache <- function(filename=NULL) { diff --git a/man/cacheManager.Rd b/man/cacheManager.Rd index b9a2951e..3691e5fa 100644 --- a/man/cacheManager.Rd +++ b/man/cacheManager.Rd @@ -18,18 +18,14 @@ placed in this folder. } \section{Localisation}{ -The localisation of the folder is : - - On Linux : `~/.local/share/R/osmose` - - On Mac OS X : `~/Library/Application Support/R/osmose` - - On Windows 7 up to 10 : `C:\\Users\\\\AppData\\Local\\R\\BIOMASS\\R\\osmose` - - On Windows XP : `C:\\Documents and Settings\\\\Data\\R\\BIOMASS\\R\\osmose` +The localisation of the folder is defined in the `.Renviron` file, by setting the `OSMOSE_DIR` +environment variable: + - On Linux/Mac Os X : `OSMOSE_DIR=/Users/Nicolas/Desktop/OSMOSE_TEST/R` + - On Windows: `OSMOSE_DIR=C:\\Users\\Nicolas\\Desktop\\OSMOSE_TEST\\R` -See this function for more information : [rappdirs::user_data_dir()] [BIOMASS::cacheManager(nameFile)] +If this variable is not set, the files will be downloaded into a temporary directory. } -\seealso{ -[rappdirs::user_data_dir()][BIOMASS::cacheManager(nameFile)] -} \author{ Arthur PERE diff --git a/vignettes/create_run_read.Rmd b/vignettes/create_run_read.Rmd index 07361e50..bc0ea130 100644 --- a/vignettes/create_run_read.Rmd +++ b/vignettes/create_run_read.Rmd @@ -1,6 +1,6 @@ --- title: "Creates a folder with basic files for a running. Then, run the model and read the outputs." -author: "Yunne-Jai Shin, Travers Morgane, Verley Philippe, Ricardo Oliveros-Ramos & Laure Velez (2020)" +author: "Yunne-Jai Shin, Criscely Lujan, Wencheng Lau-Maudrano, Philippe Verley, Ricardo Oliveros-Ramos, Nicolas Barrier & Laure Velez (2020)" date: "`r Sys.Date()`" output: knitr:::html_vignette: @@ -45,6 +45,15 @@ install.packages("osmose") devtools::install_github("osmose-model/osmose") ``` +In order to set the location of the JAR and demo files, which will be automatically downloaded, you will need to set up the `OSMOSE_DIR` environment variable. +This is done by editing the `.Renviron` file, as shown [here](https://cran.r-project.org/web/packages/startup/vignettes/startup-intro.html). + +Note that in Linux/Mac OS X, the file +must be put into the `${HOME}` directory, while in Windows, it must be in the user's `Documents` folder. Below is provided an example on `.Renviron` file for Linux/Mac Os X and Windows: + +- On Linux/Mac Os X : `OSMOSE_DIR=/Users/Nicolas/Desktop/OSMOSE_TEST/R` +- On Windows: `OSMOSE_DIR=C:\\Users\\Nicolas\\Desktop\\OSMOSE_TEST\\R` + ## About OSMOSE OSMOSE is a multispecies and Individual-based model (IBM) which focuses on fish species. This model assumes opportunistic predation based on spatial co-occurrence and size adequacy between a predator and its prey (size-based opportunistic predation). It represents fish individuals grouped into schools, which are characterized by their size, weight, age, taxonomy and geographical location (2D model), and which undergo major processes of fish life cycle (growth, explicit predation, natural and starvation mortalities, reproduction and migration) and a fishing mortality distinct for each species [@shin2001exploring; @shin2004using]. OSMOSE, uncoupled version, has been first applied to the Benguela upwelling ecosystem for which 12 fish species have been specified, from small pelagic fish to large demersal species [@shin2004using; @travers2006simulating]. The model needs basic parameters that are often available for a wide range of species, and which can be found in FishBase for instance. @@ -122,4 +131,4 @@ summary(outputs) osmose:::print.summary.osmose(osmose:::summary.osmose(outputs)) ``` -## References \ No newline at end of file +## References