Main functions
osmose
package performs three main functions (read_osmose
, run_osmose
and get_var
) and several methods for the outputs (plot
, print
, summary
and report
).
Create example files
osmose
includes a function that allows to create basic example files in a selected folder. The files corresponds to a case study provided by Halouani et al. (2016). osmose_demo
uses two main arguments: (1) path
will be the folder path where the files will be copied and (2) config
which indicates the configuration example to be copied. To indicate Halouani et al. (2016) case study, config = "gog"
.
# Define a folder to copy files (for the example: a temporary folder)
exampleFolder <- tempdir()
cat(exampleFolder)
#> /var/folders/3c/807k30_50mv_53hr_lqb6q0c0000gn/T//RtmpdQ501N
# Copy files
demoPaths <- osmose_demo(path = exampleFolder, config = "gog")
#> Copied files:
#> [1] "Maps/corr_grid2_DIPANN.csv"
#> [2] "Maps/corr_grid2_ENGENC.csv"
#> [3] "Maps/corr_grid2_MELKER.csv"
#> [4] "Maps/corr_grid2_MERMER.csv"
#> [5] "Maps/corr_grid2_METMON.csv"
#> [6] "Maps/corr_grid2_MUSMUS.csv"
#> [7] "Maps/corr_grid2_OCTVUL.csv"
#> [8] "Maps/corr_grid2_PAGERY.csv"
#> [9] "Maps/corr_grid2_SARAUR.csv"
#> [10] "Maps/corr_grid2_SARPIL.csv"
#> [11] "Maps/corr_grid2_TRATRA.csv"
#> [12] "Maps/grid2_DIPANN.csv"
#> [13] "Maps/grid2_ENGENC.csv"
#> [14] "Maps/grid2_MELKER.csv"
#> [15] "Maps/grid2_MERMER.csv"
#> [16] "Maps/grid2_METMON.csv"
#> [17] "Maps/grid2_MUSMUS.csv"
#> [18] "Maps/grid2_OCTVUL.csv"
#> [19] "Maps/grid2_PAGERY.csv"
#> [20] "Maps/grid2_SARAUR.csv"
#> [21] "Maps/grid2_SARPIL.csv"
#> [22] "Maps/grid2_TRATRA.csv"
#> [23] "calib_config.csv"
#> [24] "corr_eco3m_gog44_conversion_factor.nc"
#> [25] "corr_grid_mask_gabes_all99.csv"
#> [26] "osm_all-parameters.csv"
#> [27] "osm_param-fishing.csv"
#> [28] "osm_param-grid.csv"
#> [29] "osm_param-init-pop.csv"
#> [30] "osm_param-ltl.csv"
#> [31] "osm_param-movement.csv"
#> [32] "osm_param-mpa.csv"
#> [33] "osm_param-natural-mortality.csv"
#> [34] "osm_param-output.csv"
#> [35] "osm_param-predation.csv"
#> [36] "osm_param-reproduction.csv"
#> [37] "osm_param-species.csv"
#> [38] "osm_param-starvation.csv"
#> [39] "predation-accessibility.csv"
#> [40] "reproduction-seasonality-sp0.csv"
#> [41] "reproduction-seasonality-sp1.csv"
#> [42] "reproduction-seasonality-sp10.csv"
#> [43] "reproduction-seasonality-sp2.csv"
#> [44] "reproduction-seasonality-sp3.csv"
#> [45] "reproduction-seasonality-sp4.csv"
#> [46] "reproduction-seasonality-sp5.csv"
#> [47] "reproduction-seasonality-sp6.csv"
#> [48] "reproduction-seasonality-sp7.csv"
#> [49] "reproduction-seasonality-sp8.csv"
#> [50] "reproduction-seasonality-sp9.csv"
#> [51] "reproduction-seasonality.csv"
Running an example
Next step involves the running of the model itself. The function run_osmose
facilitates this action asking for the required arguments to achieve a successful running. run_osmose
uses and require a .jar file, corresponding to the java executable that is going to be used. However, osmose
package includes some versions of java executables inside, so it is only necessary to indicates the version.
# Run an example using 'run_osmose' function (it will take less than 1 min)
run_osmose(input = demoPaths$config_file)
#> This is OSMOSE version 3.3.3
#> Your file osmose_3.3.3.jar has been download and/or deziped in this folder : /Users/Nicolas/Library/Application Support/R/osmose/osmose_3.3.3.jar
#> Running: 'java' -jar '/Users/Nicolas/Library/Application Support/R/osmose/osmose_3.3.3.jar' /var/folders/3c/807k30_50mv_53hr_lqb6q0c0000gn/T//RtmpdQ501N/gog/osm_all-parameters.csv
Read configuration and outputs
Once we have run an example, it is important to know what we have and the main function to do this is read_osmose
. This function will ask for the path folder of outputs and the configuration file. read_osmose
will return a list of fields with the information of whether an OSMOSE running or the configuration that is going to be used in a running, so if neither of them are indicated, the user will get an error. Output class will depend on the read info: if path
is specified, output class will be osmose
; otherwise, if ONLY input
is given, the class will be osmose.config
. If both are specified, the osmose
class output will content inside a field called config
of class osmose.config
.
# Read outputs using 'read_osmose' function
outputs <- read_osmose(path = demoPaths$output_dir,
input = demoPaths$config_file)
# Check class
class(outputs)
#> [1] "osmose"
# Check class of config level
class(outputs$config)
#> [1] "osmose.config" "list"
# Read ONLY configuration files
config <- read_osmose(input = demoPaths$config_file)
# Check class
class(config)
#> [1] "osmose.config" "list"
Print & Summary methods for osmose
class
# Print method
print(outputs)
#> OSMOSE v.3u2
#> Model 'gogosm'
#>
#> 11 species modeled (3 simulations):
#> [sp0] OctopusVulgaris
#> [sp1] MelicertusKerathurus
#> [sp2] MetapenaeusMonoceros
#> [sp3] TrachurusTrachurus
#> [sp4] SardinaPilchardus
#> [sp5] SardinellaAurita
#> [sp6] EngraulisEncrasicolus
#> [sp7] DiplodusAnnularis
#> [sp8] MustelusMustelus
#> [sp9] MerlucciusMerluccius
#> [sp10] PagellusErythrinus
#>
#> Available fields:
#>
#> "model" "yieldBySize"
#> "species" "yieldNBySize"
#> "biomass" "meanTLBySize"
#> "abundance" "mortalityBySize"
#> "yield" "dietMatrixBySize (*)"
#> "yieldN" "predatorPressureBySize"
#> "mortality" "abundanceByAge"
#> "meanTL" "biomassByAge"
#> "meanTLCatch" "yieldByAge"
#> "biomassByTL" "yieldNByAge"
#> "predatorPressure" "meanSizeByAge"
#> "predPreyIni" "meanTLByAge"
#> "dietMatrix" "mortalityByAge"
#> "meanSize" "dietMatrixByAge (*)"
#> "meanSizeCatch" "predatorPressureByAge"
#> "abundanceBySize" "config"
#> "biomassBySize" "---------"
#>
#> (*) Empty fields.
# Summary method
summary(outputs)
#> OSMOSE v.3u2
#> Model 'gogosm'
#>
#> 11 species modeled (3 simulations):
#> [sp0] OctopusVulgaris
#> [sp1] MelicertusKerathurus
#> [sp2] MetapenaeusMonoceros
#> [sp3] TrachurusTrachurus
#> [sp4] SardinaPilchardus
#> [sp5] SardinellaAurita
#> [sp6] EngraulisEncrasicolus
#> [sp7] DiplodusAnnularis
#> [sp8] MustelusMustelus
#> [sp9] MerlucciusMerluccius
#> [sp10] PagellusErythrinus
#>
#> Main indicators:
#> biomass abundance yield yieldN
#> OctopusVulgaris 52976.5 45512650 1033.1 612431.1
#> MelicertusKerathurus 178179.7 764445774767 4175.7 4429627685.2
#> MetapenaeusMonoceros 91660.7 156665157469 3079.3 217570348.2
#> TrachurusTrachurus 1719.2 27319639859 12.4 338716.7
#> SardinaPilchardus 5990.6 34513978498 71.7 4275890.3
#> SardinellaAurita 11444.7 17418773576 109.4 6802481.5
#> EngraulisEncrasicolus 1397.1 3217963220 0.4 28615.1
#> DiplodusAnnularis 107093.8 99009044858 3211.3 70902831.9
#> MustelusMustelus 25732.2 42817078 72.5 78710.4
#> MerlucciusMerluccius 43411.1 3607087504 359.8 13422285.7
#> PagellusErythrinus 55906.4 6959228688 1433.6 18106726.3