5.2. Reading Osmose parameters

The loading of Osmose parameters is achieved by using the readOsmoseConfiguration function. The output parameters are stored as strings in a recursive list.

The parameters are accessed by using the getOsmoseParameter function, which returns the parameter in the proper format.


You can get access to the parameters by using the list format. However, numerical variables will be returned as strings instead of a numerics


output.dir = file.path("rosmose", "_static")

# recover the reference configuration file
filename = system.file(package="osmose", "extdata", "gog", "osm_all-parameters.csv")

# load the Osmose configuration file
osmConf = readOsmoseConfiguration(filename)

# Summarize the configuration

# extracting a particular configuration object
sim = getVar(osmConf, what="simulation")

# Recovers some parameters
ncpu = getOsmoseParameter(osmConf, "simulation", "ncpu")

# proper way to recover the season parameter (returns a vector of numeric)
map0season = getOsmoseParameter(osmConf, "movement", "season", "map0")
cat("is.vector(map0season) =", is.vector(map0season), "\n")

# Bad way to recover the map0 season parameter (returns a string)
map0season_bis = osmConf$movement$season$map0
cat("is.character(map0season_bis) =", is.character(map0season_bis), "\n")
             Length Class  Mode
simulation    7     -none- list
mortality     5     -none- list
stochastic    1     -none- list
osmose        2     -none- list
output       20     -none- list
movement      7     -none- list
predation     4     -none- list
reproduction  1     -none- list
species      12     -none- list
ltl           3     -none- list
plankton      6     -none- list
grid          6     -none- list
population    1     -none- list
[1] "osmose.config.simulation" "list"                    
is.vector(map0season) = TRUE 
is.character(map0season_bis) = TRUE

Furthermore, some parameters can be plotted for a given species. This is done as follows:

# Plotting reproduction growth
png(filename = file.path(output.dir, 'species.png'))
plot(osmConf, what="species", species=0)

# Plotting reproduction seasonality
png(filename = file.path(output.dir, 'reproduction.png'))
plot(osmConf, what="reproduction", species=1) 

# Plotting size range for predation
png(filename = file.path(output.dir, 'predation.png'))
plot(osmConf, what="predation", species=2)
In [1]: import os

In [2]: import subprocess

In [3]: cwd = os.getcwd()

In [4]: fpath = "rosmose/_static/param_loading.R"

In [5]: with open(fpath) as f:
   ...:     with open(os.devnull, "w") as DEVNULL:
   ...:         subprocess.call(["Rscript", fpath], stdout=DEVNULL, stderr=DEVNULL)

Fig. 5.1 Growth parameters for species 0


Fig. 5.2 Reproduction seasonality for species 1


Fig. 5.3 Predation size range for species 2