Skip to content

Commit

Permalink
Merge branch 'hotfix/3.3.4'
Browse files Browse the repository at this point in the history
Change download file directory
  • Loading branch information
barriern committed Apr 27, 2020
2 parents 674f33d + 941c41f commit 6a259c3
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 26 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -66,7 +66,6 @@ Imports:
utils,
ncdf4,
mgcv,
rappdirs,
fields
URL: http://www.osmose-model.org/
LazyData: FALSE
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions R/aaa-.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ NULL
NULL
#' @importFrom fields image.plot tim.colors
NULL
#' @importFrom rappdirs user_data_dir
NULL
31 changes: 21 additions & 10 deletions R/cacheManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
#' 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\\<username>\\AppData\\Local\\R\\BIOMASS\\R\\osmose`
#' - On Windows XP : `C:\\Documents and Settings\\<username>\\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
#'
#' @return the path to the file we need
#'
#' @author Arthur PERE
#' @author Nicolas BARRIER
#' @seealso [rappdirs::user_data_dir()][BIOMASS::cacheManager(nameFile)]
#'
#' @keywords Internal
#' @export
Expand Down Expand Up @@ -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) {

Expand Down
14 changes: 5 additions & 9 deletions man/cacheManager.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions vignettes/create_run_read.Rmd
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -122,4 +131,4 @@ summary(outputs)
osmose:::print.summary.osmose(osmose:::summary.osmose(outputs))
```

## References
## References

0 comments on commit 6a259c3

Please sign in to comment.