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)
# Here you can also select the same directory than in OSMOSE_DIR
exampleFolder <- tempdir()
cat(exampleFolder)
#> /var/folders/3c/807k30_50mv_53hr_lqb6q0c0000gn/T//Rtmp1DrbUl
# Copy files
demoPaths <- osmose_demo(path = exampleFolder, config = "gog")
#> Your file gog has been download and/or deziped in this folder : /var/folders/3c/807k30_50mv_53hr_lqb6q0c0000gn/T//Rtmp1DrbUl/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 lib has been download and/or deziped in this folder : /var/folders/3c/807k30_50mv_53hr_lqb6q0c0000gn/T//Rtmp1DrbUl/lib
#> Your file osmose_3.3.3.jar has been download and/or deziped in this folder : /var/folders/3c/807k30_50mv_53hr_lqb6q0c0000gn/T//Rtmp1DrbUl/osmose_3.3.3.jar
#> Running: 'java' -jar '/var/folders/3c/807k30_50mv_53hr_lqb6q0c0000gn/T//Rtmp1DrbUl/osmose_3.3.3.jar' /var/folders/3c/807k30_50mv_53hr_lqb6q0c0000gn/T//Rtmp1DrbUl/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 53543.0 46142014 1051.6 622388.4
#> MelicertusKerathurus 174742.4 718621752647 4125.5 4171091910.1
#> MetapenaeusMonoceros 92013.5 126678098495 3064.3 215483027.8
#> TrachurusTrachurus 1725.0 25995919175 12.8 364684.7
#> SardinaPilchardus 5906.8 34589776659 71.4 4457450.6
#> SardinellaAurita 10616.9 15878016178 98.8 6380940.3
#> EngraulisEncrasicolus 1553.2 3637585590 0.4 32938.0
#> DiplodusAnnularis 104332.1 85678428382 3092.5 69149534.6
#> MustelusMustelus 25679.2 42470771 73.1 79294.6
#> MerlucciusMerluccius 42814.2 3684630223 351.3 12607854.3
#> PagellusErythrinus 57614.4 6921371795 1434.3 19176688.8