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

# 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)
             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

is.vector(map0season) = TRUE 
is.character(map0season_bis) = TRUE

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

cat("is.character(map0season_bis) =", is.character(map0season_bis), "\n")

# 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)

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