5.4. Reading outputs

The reading of outputs is achieved by using the read_osmose function:

library("osmose")

data = read_osmose(path='output') 

The content of the data object can be obtained as follows:

names(data)
 [1] "model"                  "species"                "biomass"               
 [4] "abundance"              "yield"                  "yieldN"                
 [7] "mortality"              "meanTL"                 "meanTLCatch"           
[10] "biomassByTL"            "predatorPressure"       "predPreyIni"           
[13] "dietMatrix"             "meanSize"               "meanSizeCatch"         
[16] "SizeSpectrum"           "abundanceBySize"        "biomassBySize"         
[19] "yieldBySize"            "yieldNBySize"           "meanTLBySize"          
[22] "mortalityBySize"        "dietMatrixBySize"       "predatorPressureBySize"
[25] "abundanceByAge"         "biomassByAge"           "yieldByAge"            
[28] "yieldNByAge"            "meanSizeByAge"          "meanTLByAge"           
[31] "mortalityByAge"         "dietMatrixByAge"        "predatorPressureByAge" 
[34] "ageMature"              "growthPotential"        "ingestion"             
[37] "maintenance"            "sizeInf"                "sizeMature"            
[40] "config"

Variables are accessed by using the getVar function, which allows to apply some operations prior to extraction (average over the replicates, conversion into a list or a matrix):

library("osmose")

getwd()
input.dir = file.path("astart", "_static", "gog_v4", "output")
data = read_osmose(input.dir)

biom = getVar(data, "biomass")
class(biom)
dim(biom)
cat("\n")

# expected = TRUE if mean over replicate should be returned
# only works for data that inherits from array
biom = getVar(data, "biomass", expected=TRUE)
class(biom)
dim(biom)
cat("\n")

biom = getVar(data, "biomass", how="list")
class(biom)
names(biom)
cat(biom$OctopusVulgaris)
cat("\n")

biom = getVar(data, "dietMatrix")
class(biom)
cat("\n")

biom = getVar(data, "dietMatrix", how="list")
class(biom)
[1] "/home/nbarrier/Modeles/osmose/git-applis/doc_user"
[1] "osmose.biomass" "array"         
[1] 120  11   2

[1] "matrix"
[1] 120  11

[1] "list"
 [1] "OctopusVulgaris"       "MelicertusKerathurus"  "MetapenaeusMonoceros" 
 [4] "TrachurusTrachurus"    "SardinaPilchardus"     "SardinellaAurita"     
 [7] "EngraulisEncrasicolus" "DiplodusAnnularis"     "MustelusMustelus"     
[10] "MerlucciusMerluccius"  "PagellusErythrinus"   
0 0 0 0 0 0 0 0 14386.51 43315.71 35539.02 28363.93 22637.96 18067.92 41282.78 92084.95 73693.77 61029.7 51977.71 43741.75 65111.6 130050.1 100651.2 85092.71 73154.94 62328.77 83936.29 156084.7 114240.1 98319.93 85579.12 73979.26 94736.14 173949.7 125799.2 108761 95454.9 83762.1 94197.08 138372.1 88096.95 75595.6 64903.14 56311.74 71715.08 120845.3 84065.01 72349.79 63866.85 54886.52 71462.87 111481.9 73878.26 64240.93 55970.21 48103.6 62405.15 96815.27 67079.83 56577.08 48822.86 42800.57 51902.8 76190.45 50853.12 42585.32 36853.65 31724.18 36969.58 65891.22 45468.18 38460.33 33103.86 28559.6 39050.31 68326.31 46401.84 38488.21 33236.5 27779.68 41134.45 72172.89 56107.11 48150.55 41327.03 35013.2 41924.5 57314.2 37091.85 31326.97 27233.98 23411.89 33727.21 58880.7 42367.27 36816.35 31207.18 26412.61 41050.22 62680.56 44973.88 37821.97 32354 27176.07 37992.57 60882.13 44898.03 39230.59 34082.85 28713.01 39204.65 71725.29 52164.04 44640.27 38818.71 33157.51 44016.89 67492.54 47389.32 40579.41
[1] "osmose.dietMatrix" "list"             

[1] "list"

The first argument is the data object obtained by using the read_osmose function, while the second argument is the name of the variable to extract.