diff --git a/.Rbuildignore b/.Rbuildignore index 0d4a580c..d416705d 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,7 +1,8 @@ - -^.*\.Rproj$ -^\.Rproj\.user$ -^\.github$ -^_pkgdown\.yml$ -^docs$ -^pkgdown$ + +^.*\.Rproj$ +^\.Rproj\.user$ +^\.github$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ +^data-raw$ diff --git a/.gitignore b/.gitignore index 156c6bee..5cd53704 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ *.png *.jpg *.tif -data outputs code *.xlsx diff --git a/DESCRIPTION b/DESCRIPTION index 49a8fa62..5f26165c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,3 +30,5 @@ VignetteBuilder: knitr RoxygenNote: 7.1.1 URL: https://github.com/NOAA-EDAB/Rpath BugReports: https://github.com/NOAA-EDAB/Rpath/issues +Depends: + R (>= 2.10) diff --git a/R/data.R b/R/data.R new file mode 100644 index 00000000..59ccb377 --- /dev/null +++ b/R/data.R @@ -0,0 +1,44 @@ +#' Eastern Bering Sea 1990s Ecopath model (53 biological groups and 1 fleet). +#' +#' Rpath inputs (unbalanaced model). +#' +#' @format An Rpath unbalanced model object that contains: +#' \describe{ +#' \item{model}{A data.table containing Ecopath unbalanced ecosystem parameters (base parameters and fisheries).} +#' \item{diet}{A data.table containing the Ecopath model's diet matrix.} +#' \item{stanzas}{Parameters for multistanza groups.} +#' \item{pedigree}{A data.table containing the data quality (pedigree) for the Ecopath model.} +#' ... +#' } +#' @source Whitehouse and Aydin 2020. Assessing the sensitivity of three Alaska marine food webs to perturbations: an example of Ecosim simulations using Rpath. https://doi.org/10.1016/j.ecolmodel.2020.109074 +"Ecosense.EBS" + +#' Gulf of Alaska (west/central) 1990s Ecopath model (49 biological groups and 1 fleet). +#' +#' Rpath inputs (unbalanaced model). +#' +#' @format An Rpath unbalanced model object that contains: +#' \describe{ +#' \item{model}{A data.table containing Ecopath unbalanced ecosystem parameters (base parameters and fisheries).} +#' \item{diet}{A data.table containing the Ecopath model's diet matrix.} +#' \item{stanzas}{Parameters for multistanza groups.} +#' \item{pedigree}{A data.table containing the data quality (pedigree) for the Ecopath model.} +#' ... +#' } +#' @source Whitehouse and Aydin 2020. Assessing the sensitivity of three Alaska marine food webs to perturbations: an example of Ecosim simulations using Rpath. https://doi.org/10.1016/j.ecolmodel.2020.109074 +"Ecosense.GOA" + +#' Eastern Chukchi Sea Ecopath model (52 biological groups and 1 fleet). +#' +#' Rpath inputs (unbalanaced model). +#' +#' @format An Rpath unbalanced model object that contains: +#' \describe{ +#' \item{model}{A data.table containing Ecopath unbalanced ecosystem parameters (base parameters and fisheries).} +#' \item{diet}{A data.table containing the Ecopath model's diet matrix.} +#' \item{stanzas}{Parameters for multistanza groups.} +#' \item{pedigree}{A data.table containing the data quality (pedigree) for the Ecopath model.} +#' ... +#' } +#' @source Whitehouse and Aydin 2020. Assessing the sensitivity of three Alaska marine food webs to perturbations: an example of Ecosim simulations using Rpath. https://doi.org/10.1016/j.ecolmodel.2020.109074 +"Ecosense.ECS" \ No newline at end of file diff --git a/R/param.R b/R/param.R index 571ede27..f746e54c 100644 --- a/R/param.R +++ b/R/param.R @@ -376,9 +376,9 @@ check.rpath.params <- function(Rpath.params){ } if(w == 0){ - cat('Rpath parameter file is functional.\n') + cat('Rpath parameter file is functional. \n') } else { - cat('Rpath parameter file needs attention!\n') + cat('Rpath parameter file needs attention! \n') } } diff --git a/data-raw/Ecosense_EBS_base.csv b/data-raw/Ecosense_EBS_base.csv new file mode 100644 index 00000000..f0d21e03 --- /dev/null +++ b/data-raw/Ecosense_EBS_base.csv @@ -0,0 +1,55 @@ +Group,Type,Biomass,PB,QB,EE,ProdCons,BioAcc,Unassim,DetInput,PelDetFate,BenthDetFate,F_Fishery,D_Fishery +Toothed whales,0,0.03503154,0.06911141,17.39968,,,0,0.2,,0.4,0.6,2.52E-05,0.000006747 +Gray whales,0,0.0326672,0.063365,8.87285,,,0,0.2,,0.4,0.6,0,0 +Other baleen,0,0.5007642,0.02832879,6.642456,,,0,0.2,,0.4,0.6,0.000000183,1.91E-05 +Bowhead whales,0,0.007173534,0.01005034,8.679965,,,0,0.2,,0.4,0.6,0,0 +Other pinnipeds,0,0.04919672,0.09292668,33.97923,,,0,0.2,,0.4,0.6,0.000100598,5.62E-06 +Walrus/bearded seal,0,0.1142484,0.051293,15.37061,,,0,0.2,,0.4,0.6,3.09E-05,5.96E-06 +Wintering seals,0,0.03029022,0.068998,19.19651,,,0,0.2,,0.4,0.6,0.000031609,3.15E-07 +Procellarids,0,0.000920162,0.07456178,73,,,0,0.2,,0.4,0.6,2.20E-09,0.000003567 +Alcids piscivorous,0,0.008617982,0.1623509,72.05511,,,0,0.2,,0.4,0.6,2.08E-08,3.34E-05 +Larids,0,0.000767614,0.08903116,104.9432,,,0,0.2,,0.4,0.6,1.90E-09,2.98E-06 +Alcids planktivorous,0,0.001754495,0.1694877,110,,,0,0.2,,0.4,0.6,4.20E-09,6.80E-06 +Other seabirds,0,0.000101753,0.06846981,76.18891,,,0,0.2,,0.4,0.6,2.00E-10,3.94E-07 +Cormorants,0,0.000149799,0.1587271,73,,,0,0.2,,0.4,0.6,4.00E-10,5.81E-07 +Sharks,0,0.0532473,0.1,3,,,0,0.2,,0.4,0.6,1.55E-05,0.000695172 +Walleye pollock,0,22.97889,0.8208976,4.193416,,,0,0.2,,0.392,0.608,0.4041824,2.104923 +Pacific cod,0,2.650923,0.5080103,2.739351,,,0,0.2,,0.392,0.608,0.2240711,0.1983278 +Pelagic forage fish,0,7.644652,0.7672387,3.732284,,,0,0.2,,0.392,0.608,0.02158515,0.007684128 +Lg.-mouth flatfish,0,1.58756,0.1937844,1.213555,,,0,0.2,,0.392,0.608,0.01807182,0.04641179 +Sm.-mouth flatfish,0,11.31311,0.2096047,1.325415,,,0,0.2,,0.392,0.608,0.1925451,0.2227745 +Skates,0,0.7733867,0.2,2,,,0,0.2,,0.392,0.608,0.004292543,0.02400982 +Other demersals,0,1.382284,0.2117719,2.526838,,,0,0.2,,0.392,0.608,0.01536881,0.01027679 +Eelpouts,0,2.371533,0.4,2,,,0,0.2,,0.392,0.608,0,0 +Lg.-mouth sculpins,0,0.5403231,0.4,2,,,0,0.2,,0.392,0.608,0.000573506,0.009394558 +Other sculpins,0,1.136692,0.4,2,,,0,0.2,,0.392,0.608,0,0 +Misc. shallow fish,0,1.167694,0.4,2,,,0,0.2,,0.392,0.608,1.13E-05,3.58E-05 +Octopods,0,0.192476,0.8,3.65,,,0,0.2,,0.392,0.608,7.99E-05,0.000228618 +Squids,0,0.9269976,3.2,10.67,,,0,0.2,,0.392,0.608,0.000454888,0.000875192 +Salmon returning,0,0.1637697,1.65,11.6,,,0,0.2,,0.392,0.608,0.1691487,0.00067146 +Salmon outgoing,0,0.0141972,1.28,13.56,,,0,0.2,,0.392,0.608,0,0 +Other crabs,0,3.244238,0.9338375,3.872315,,,0,0.2,,0.1,0.9,0.06657811,0.003027228 +Snow crab,0,2.178832,1.295101,3.117084,,,0,0.2,,0.1,0.9,0.3006897,0.006839902 +Shrimps,0,19.44489,0.5756463,2.40941,,,0,0.2,,0.1,0.9,2.25E-07,0.000001989 +Sea stars,0,2.471359,1.21,6.05,,,0,0.2,,0.1,0.9,3.87E-05,0.006488753 +Brittle stars,0,2.950093,1.21,6.05,,,0,0.2,,0.1,0.9,0,0 +Urchins dollars cucumbers,0,1.167418,0.61,3.05,,,0,0.2,,0.1,0.9,3.48E-07,6.56E-05 +Snails,0,0.8071689,1.81,9.049999,,,0,0.2,,0.1,0.9,1.88E-07,1.80E-05 +Misc. crustacean,0,8.88581,7.4,37,,,0,0.2,,0.1,0.9,0,0 +Benthic amphipods,0,12.79612,7.4,37,,,0,0.2,,0.1,0.9,0,0 +Anemones,0,0.1095207,1,5,,,0,0.4,,0.1,0.9,4.31E-07,0.000384743 +Corals and sea pens,0,0.02658792,0.06929576,0.3464788,,,0,0.4,,0.1,0.9,3.25E-07,0.000025347 +Worms etc.,0,3.905683,2.155615,10.77807,,,0,0.4,,0.1,0.9,0,0 +Benthic urochordate,0,0.3544967,3.58,17.9,,,0,0.4,,0.1,0.9,6.09E-06,0.001505825 +Sponge,0,0.05448509,1,5,,,0,0.4,,0.1,0.9,1.91E-06,0.00064731 +Bivalves,0,61.87307,1.3,6.5,,,0,0.4,,0.1,0.9,2.33E-08,1.11E-07 +Polychaetes,0,21.68738,2.97,14.85,,,0,0.4,,0.1,0.9,0,0 +Scyphozoid Jellies,0,0.3379304,0.88,3,,,0,0.2,,0.4,0.6,0.003364776,0.01527125 +Other zooplankton,0,22.7485,5.253331,15.00952,,,0,0.2,,0.4,0.6,0,0 +Copepods,0,26.85738,6,27.74,,,0,0.2,,0.4,0.6,0,0 +Pelagic microbes,0,45,36.5,104.2857,,,0,0.25,,0.4,0.6,0,0 +Benthic microbes,0,22.06101,36.5,104.2857,,,0,0.25,,0.1,0.9,0,0 +Primary production,1,48.60443,99.40636,,,,0,0,,0.4004332,0.5995669,0,0 +Pelagic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Benthic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Fishery/Subsistence,3,,,,,,,,,0.2278577,0.7721423,, diff --git a/data-raw/Ecosense_EBS_diet.csv b/data-raw/Ecosense_EBS_diet.csv new file mode 100644 index 00000000..ab7e75b0 --- /dev/null +++ b/data-raw/Ecosense_EBS_diet.csv @@ -0,0 +1,55 @@ +DIETS,Toothed whales,Gray whales,Other baleen,Bowhead whales,Other pinnipeds,Walrus/bearded seal,Wintering seals,Procellarids,Alcids piscivorous,Larids,Alcids planktivorous,Other seabirds,Cormorants,Sharks,Walleye pollock,Pacific cod,Pelagic forage fish,Lg.-mouth flatfish,Sm.-mouth flatfish,Skates,Other demersals,Eelpouts,Lg.-mouth sculpins,Other sculpins,Misc. shallow fish,Octopods,Squids,Salmon returning,Salmon outgoing,Other crabs,Snow crab,Shrimps,Sea stars,Brittle stars,Urchins dollars cucumbers,Snails,Misc. crustacean,Benthic amphipods,Anemones,Corals and sea pens,Worms etc.,Benthic urochordate,Sponge,Bivalves,Polychaetes,Scyphozoid Jellies,Other zooplankton,Copepods,Pelagic microbes,Benthic microbes,Primary production +Toothed whales,6.47E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Gray whales,0.000133081,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other baleen,0.002040034,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Bowhead whales,2.92E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other pinnipeds,0.000205117,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walrus/bearded seal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Wintering seals,,,,,,0.001017812,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Procellarids,,,,,,,,6.33E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids piscivorous,,,,,,,,0.00059265,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Larids,,,,,,,,5.28E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids planktivorous,,,,,,,,0.000120655,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other seabirds,,,,,,,,7.00E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Cormorants,,,,,,,,1.03E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Sharks,0.000239291,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walleye pollock,0.1698044,,0.08070278,,0.2811362,,0.4888999,0.1655044,0.2614391,0.2021952,0.002550183,0.1678919,0.02434087,0.2,0.08240532,0.2243627,,0.5571692,0.03047612,0.4114217,0.004290166,0.00395613,0.1298186,,,,,,,,,,,,,,,,,,,,,,,0.001,,,,, +Pacific cod,0.01947363,,,,0.01366742,,0.0049334,0.007216445,0.1888303,0.008816263,0.000111195,0.007320547,0.001061329,,0.000594541,0.00446721,,0.006268422,3.22E-05,0.006085007,,,0.000913099,0.04028247,,,,,,,,,,,,,,,,,,,,,,,,,,, +Pelagic forage fish,0.2487804,,0.1201802,,0.2320068,,0.1287617,0.3508018,0.3939846,0.6618846,0.05411142,0.3104237,0.931414,,0.005597626,0.03139776,,0.0777799,0.04213176,0.0297038,0.004689368,0.01307451,0.08628711,,,,0.15,,,,,,,,,,,,,,,,,,,0.008,,,,, +Lg.-mouth flatfish,0.001034033,,,,5.86E-06,,,,,,,,,0.2,0.000824726,0.001458564,,0.002081271,6.93E-05,0.02431003,1.60E-06,,0.000360408,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Sm.-mouth flatfish,0.006842509,,,,0.08088505,,0.0394672,,,,,,,,0.000164344,0.02012908,,0.02068678,0.000488947,0.09006111,0.000020214,7.38E-06,0.03985396,0.009723351,0.007394266,,,,,,,,,,,,,,,,,,,,,,,,,, +Skates,0.003475559,,,,,,,,,,,,,,,5.18E-07,,1.45E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other demersals,0.005536608,,,,0.01134714,,,0.000564447,0.000998577,0.000999001,0.001003092,0.000032534,0.00084674,0.2,4.84E-07,0.001655552,,0.001043523,,,0.000351201,,5.16E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Eelpouts,0.141124,,,,0.008174762,,0.05969413,,,,,,,,0.000426192,0.03098069,,0.04269749,0.001878417,0.08047485,3.13E-06,0.01845699,0.03330814,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Lg.-mouth sculpins,,,,,,,,,,,,,,,7.54E-06,0.001176434,,0.0002093,1.93E-05,0.000021452,0.000121231,,0.001836508,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other sculpins,0.05504273,,,,0.01009857,,0.07893439,,,,,,,,0.000323667,0.01049386,,0.01287026,0.001030404,0.02096508,0.000147024,0.01351007,0.02105363,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Misc. shallow fish,0.03660734,,0.01555704,,0.02213815,,0.09866799,,,,,,,0.02,8.52E-05,0.003238108,,0.004294502,0.000809832,0.007287188,5.99E-06,0.000986537,0.01898878,0.04985736,,,,,,,,,,,,,,,,,,,,,,,,,,, +Octopods,0.005624069,,,,0.02070426,0.01017812,0.009866798,,,,,,,0.02,2.62E-05,0.005013016,,0.000651224,7.19E-05,,0.000360057,,0.01435832,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Squids,0.2922446,,0.002097894,,0.2519298,,0.00049334,0.4435776,0.03470331,0.006531665,0.00074037,0.503465,,0.2,0.001616147,0.00071992,,0.07333685,0.00012839,2.53E-05,0.2840489,,6.85E-05,,,,,0.2,,,,,,,,,,,,,,,,,,0.001,,,,, +Salmon returning,0.01169868,,0.005824628,,0.008696572,,,,,,,,,0.05,,0.001279095,,,,0.02247792,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Salmon outgoing,7.14E-08,,3.56E-08,,0.008696572,,,,,,,7.53E-08,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other crabs,,0.002564021,,0.001170194,0.01055097,0.006252694,0.009866799,,,,,,0.000783198,0.0025,0.001008549,0.1117827,,0.01110253,0.01499601,0.05703641,0.001302062,0.008096965,0.06165776,0.05453778,0.000531343,0.15,,,,0.005500491,0.06013035,,0.01,,,,,,,,,,,,,,,,,, +Snow crab,,0.001909877,,0.000871649,0.000698742,0.003925424,,,,,,,0.00121494,,1.81E-05,0.05749471,,0.004300768,0.004455289,0.0300742,,0.09333689,0.03866288,,,0.05,,,,,,,0.005,,,,,,,,,,,,,,,,,, +Shrimps,,0.01358641,,0.006200707,0.02408229,0.02035623,0.0542674,,,,,,0.0086428,0.005,0.03297897,0.1420867,0,0.05616299,0.08154,0.07128841,0.2867417,0.01367033,0.1972778,0.5433436,0.225388,,,,,,,,0.01,,,,,,,,,,,,,,,,,, +Sea stars,,0.001959092,,0.000894111,,,,,,,,,,,2.83E-05,0.00012312,,1.04E-08,3.16E-06,0.00055577,4.92E-06,,5.38E-05,,,,,,,0.000382242,0.000603733,,,,,,,,,,,,,,,,,,,, +Brittle stars,,0.002253839,,0.00102863,,,,,,,,,,,3.63E-05,0.000185201,,6.63E-05,0.05973076,5.11E-05,2.43E-06,0.1822525,0.000102108,0.000181826,,,,,,0.01228855,0.07161608,,0.03,,,,,,,,,,,,,,,,,, +Urchins dollars cucumbers,,0.000840129,,0.000383427,0.01513655,,,,,,,,,,1.25E-07,0.000107477,,5.44E-06,0.02279872,8.06E-08,,,2.12E-05,,,,,,,0.01201729,0.007422531,,,,,,,,,,,,,,,,,,,, +Snails,,0.000502282,,0.000229237,2.21E-05,0.0610687,,,,,,,,0.0025,0.000179459,0.004685467,,0.000333693,0.007431038,0.000301499,0.000000029,,0.001372771,,,0.4,,,,0.01685826,0.04829947,,0.005,,,,,,,,,,,,,,,,,, +Misc. crustacean,,0.006993907,,0.003191952,,,,0.004287296,0.009203487,0.003571809,0.00072099,3.73E-05,0.004449074,,0.007055759,0.002030444,,2.65E-05,0.02593507,0.000023285,4.31E-07,0.005357117,0.000792121,0.01442491,4.38E-05,,,,,0.001538223,0.01720634,,,,,,,,0.125,0.125,0.003506872,0.125,0.125,0.125,,,,,,, +Benthic amphipods,,0.9,,0.004360963,,,,6.32E-05,,0.004879939,0.000985044,5.10E-05,0.006078489,,0.03478977,0.1104455,2.96E-06,0.001273519,0.09940312,0.008388263,0.001051775,0.3280452,0.05959997,0.1947338,0.09178961,,,,,0.005461351,0.04782058,0.3,,0.1,,,,,0.125,0.125,0.003506872,0.125,0.125,0.125,,,,,,, +Anemones,,8.68E-05,,3.96E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,0.001850753,,,,,,,,,,,,,,,,,,,, +Corals and sea pens,,2.11E-05,,9.62E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Worms etc.,,0.002718438,,0.001240668,,0.1832061,0.02614701,1.69E-05,,0.001301065,0.000262628,1.36E-05,,,0.001353052,0.02704704,,0.000266081,0.09399602,5.84E-05,7.86E-07,0.02537635,0.01925321,0.03702217,,,,,,0.2085163,0.03021216,,0.01,,,0.2,,,,,,,,,,,,,,, +Benthic urochordate,,0.000281016,,0.000128253,,,,,,,,,,,1.68E-05,0.000549436,,3.16E-06,0.002288761,1.66E-06,0.000489444,,,,,,,,,0.000570783,,,,,,,,,,,,,,,,,,,,, +Sponge,,4.32E-05,,1.97E-05,,,,,,,,,,,5.47E-05,4.36E-05,,9.00E-10,9.09E-05,7.98E-06,,,,,,,,,,0.00023874,0.002601985,,,,,,,,,,,,,,,,,,,, +Bivalves,,0.04904792,,0.022385,2.21E-05,0.7139949,,0.00032442,,0.02504892,0.005056271,0.000261789,,,0.000490379,0.00165732,,0.000577568,0.08503099,2.78E-05,8.08E-06,0.05257819,0.000393605,,,0.4,,,,0.2533802,0.2524816,0.1,0.91,,,0.2,,,,,,,,,,,,,,, +Polychaetes,,0.01719198,,0.007846256,,,,0.000113714,,0.008779998,0.001772293,9.18E-05,,,0.00366851,0.03710564,3.12E-05,0.000641417,0.3154908,0.002781462,0.000225772,0.2386699,0.10978,0.02550208,1.19E-05,,,,,0.263431,0.2847306,,0.02,,,0.2,,,,,,,,,,,,,,, +Scyphozoid Jellies,,,,,,,,,,,,,,,2.91E-05,3.76E-06,,1.33E-06,0.001530271,1.47E-05,0.0001446,,7.51E-06,,0.06429844,,,,,,,,,,,,,,,,,,,,,,,,,, +Other zooplankton,,,0.5746825,0.55,,,,0.01148704,0.04877095,0.03297732,0.4103911,0.004580894,0.008569111,,0.4335781,0.1106963,0.9033016,0.09674293,0.09784253,0.000493316,0.3819539,0.001346271,0.1561293,0.01137116,0.6102213,,0.65,0.6,0.5,,0.004736442,0.2,,,,,,,,,,,,,,0.74,0.008073313,,,, +Copepods,,,0.200955,0.4,,,,0.01519615,0.06206967,0.04196949,0.5222954,0.00583,0.01259939,,0.3857745,0.001424687,0.09666412,0.000011405,0.00054752,,0.03367182,,2.77E-05,0.01865575,0.000321321,,0.2,0.2,0.5,,,,,,,,,,,,,,,,,0.15,0.25,,,, +Pelagic microbes,,,,,,,,,,,,,,,1.93E-06,8.57E-06,,,0.000224104,,,0.00065419,,0.000363653,,,,,,,,,,,,,,,,,,,,,,0.05,0.15,0.5,,, +Benthic microbes,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.5,0.5,0.15,0.15,0.4901808,0.15,0.15,0.15,0.5,,,,,, +Primary production,,,,,,,,,,,,,,,,1.85E-05,,1.76E-07,5.60E-09,,,,,,,,,,,0.001516897,0.004452738,,,,0.25,0.2,,,,,,,,,,0.05,0.5919268,0.5,0.7,, +Pelagic detritus,,,,,,,,,,0.00104472,,,,,,,,,,,,,,,,,,,,0.000994342,0.005903513,,,,,,,,,,,,,,,,,,0.3,, +Benthic detritus,,,,,,,,,,,,,,0.1,0.006865464,0.0561312,,0.02938087,0.009528337,0.1360623,0.000363454,0.00062444,0.008015924,,,,,,,0.2173052,0.1599311,0.4,,0.9,0.75,0.2,0.5,0.5,0.6,0.6,0.5028055,0.6,0.6,0.6,0.5,,,,,1, +Import,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/data-raw/Ecosense_EBS_pedigree.csv b/data-raw/Ecosense_EBS_pedigree.csv new file mode 100644 index 00000000..8f783a1e --- /dev/null +++ b/data-raw/Ecosense_EBS_pedigree.csv @@ -0,0 +1,54 @@ +Group,B,PB,QB,Diet,F_Fishery/Subsistence +Toothed whales,0.8,0.6,0.6,0.8,0.3 +Gray whales,0.5,0.6,0.6,0.8,0 +Other baleen,0.8,0.6,0.6,0.8,0.3 +Bowhead whales,0.5,0.1,0.6,0.8,0 +Other pinnipeds,0.5,0.6,0.8,0.8,0.3 +Walrus/bearded seal,0.5,0.6,0.6,0.7,0.3 +Wintering seals,0.5,0.6,0.6,0.7,0.3 +Procellarids,0.8,0.6,0.6,0.8,0.5 +Alcids piscivorous,0.5,0.6,0.6,0.8,0.5 +Larids,0.5,0.6,0.6,0.8,0.5 +Alcids planktivorous,0.5,0.6,0.6,0.8,0.5 +Other seabirds,0.8,0.6,0.6,0.8,0.5 +Cormorants,0.5,0.6,0.6,0.8,0.5 +Sharks,0.5,0.7,0.7,0.8,0.7 +Walleye pollock,0.5,0.4,0.4,0.1,0.1 +Pacific cod,0.8,0.4,0.4,0.1,0.7 +Pelagic forage fish,0.8,0.7,0.7,0.8,0.5 +Lg.-mouth flatfish,0.8,0.6,0.8,0.3,0.7 +Sm.-mouth flatfish,0.8,0.6,0.8,0.7,0.3 +Skates,0.5,0.7,0.7,0.7,0.7 +Other demersals,0.8,0.7,0.8,0.8,0.8 +Eelpouts,0.8,0.7,0.7,0.8,0.7 +Lg.-mouth sculpins,0.1,0.7,0.7,0.3,0.8 +Other sculpins,0.8,0.7,0.7,0.3,0 +Misc. shallow fish,0.8,0.7,0.7,0.7,0.7 +Octopods,0.8,0.7,0.7,0.8,0.4 +Squids,0.8,0.7,0.7,0.8,0.4 +Salmon returning,0.8,0.5,0.8,0.7,0.3 +Salmon outgoing,0.8,0.6,0.6,0.8,0 +Other crabs,0.8,0.6,0.8,0.8,0.8 +Snow crab,0.1,0.6,0.8,0.7,0.3 +Shrimps,0.8,0.6,0.8,0.8,0.5 +Sea stars,0.5,0.6,0.7,0.8,0.8 +Brittle stars,0.8,0.6,0.7,0.8,0 +Urchins dollars cucumbers,0.8,0.6,0.7,0.8,0.5 +Snails,0.8,0.6,0.7,0.8,0.5 +Misc. crustacean,0.8,0.6,0.7,0.8,0 +Benthic amphipods,0.8,0.6,0.7,0.8,0 +Anemones,0.5,0.6,0.7,0.8,0.5 +Corals and sea pens,0.5,0.6,0.7,0.8,0.5 +Worms etc.,0.8,0.6,0.7,0.8,0 +Benthic urochordate,0.5,0.6,0.7,0.8,0.5 +Sponge,0.5,0.6,0.7,0.8,0.5 +Bivalves,0.8,0.6,0.7,0.8,0.5 +Polychaetes,0.8,0.6,0.7,0.8,0 +Scyphozoid Jellies,0.5,0.6,0.6,0.8,0.5 +Other zooplankton,0.8,0.7,0.8,0.8,0 +Copepods,0.8,0.7,0.8,0.8,0 +Pelagic microbes,0.8,0.7,0.7,0.8,0 +Benthic microbes,0.8,0.7,0.7,0.1,0 +Primary production,0.8,0.7,0,0.01,0 +Pelagic detritus,0.8,0,0,0,0 +Benthic detritus,0.8,0,0,0,0 diff --git a/data-raw/Ecosense_ECS_base.csv b/data-raw/Ecosense_ECS_base.csv new file mode 100644 index 00000000..bc8fdad4 --- /dev/null +++ b/data-raw/Ecosense_ECS_base.csv @@ -0,0 +1,54 @@ +Group,Type,Biomass,PB,QB,EE,ProdCons,BioAcc,Unassim,DetInput,PelDetFate,BenthDetFate,F_Fishery,D_Fishery +Polar bears,0,0.00052669,0.0603,4.001384,,,0,0.2,,0.3,0.7,1.84E-05,3.00E-10 +Toothed whales,0,0.01158743,0.112092,14.50402,,,0,0.2,,0.3,0.7,6.34E-05,1.00E-10 +Gray whale,0,0.1879512,0.063365,8.87285,,,0,0.2,,0.3,0.7,0,0 +Bowhead whale,0,0.3984775,0.01005,5.260121,,,0,0.2,,0.3,0.7,0.001198808,1.00E-10 +Walrus/bearded seal,0,0.09814298,0.07127273,18.19188,,,0,0.2,,0.3,0.7,0.004842258,2.00E-10 +Wintering seals,0,0.06165962,0.08586258,19.17929,,,0,0.2,,0.3,0.7,0.002269417,2.00E-10 +Procellarids,0,0.001927375,0.06674218,187.9285,,,0,0.2,,0.3,0.7,0,0 +Cormorants,0,1.47E-06,0.1625189,142.6185,,,0,0.2,,0.3,0.7,0,0 +Other seabirds,0,7.77E-05,0.1625189,374.3133,,,0,0.2,,0.3,0.7,0,0 +Larids,0,9.31E-05,0.1057225,205.6736,,,0,0.2,,0.3,0.7,0,0 +Alcids piscivorous,0,0.001155027,0.104122,178.3831,,,0,0.2,,0.3,0.7,0,0 +Alcids planktivorous,0,0.000139496,0.1404024,247.5067,,,0,0.2,,0.3,0.7,0,0 +Lg.-mouth flatfish,0,0.1114285,0.4006235,1.780206,,,0,0.2,,0.3,0.7,0,0 +Sm.-mouth flatfish,0,0.09015632,0.3078811,1.535264,,,0,0.2,,0.3,0.7,0,0 +Lg.-mouth sculpins,0,0.599852,0.4,2,,,0,0.2,,0.3,0.7,0,0 +Other sculpins,0,0.8552857,0.4592638,2.415146,,,0,0.2,,0.3,0.7,0,0 +Eelpouts,0,0.3821929,0.4,2,,,0,0.2,,0.3,0.7,0,0 +Pelagic forage fish,0,1.190608,0.5432349,2.919605,,,0,0.2,,0.3,0.7,0,0 +Misc. shallow fish,0,7.477481,0.41934,2.105119,,,0,0.2,,0.3,0.7,0,0 +Other demersals,0,0.2338559,0.4,2,,,0,0.2,,0.3,0.7,0,0 +Skates,0,0.005364676,0.21,2.1,,,0,0.2,,0.3,0.7,0,0 +Walleye pollock,0,0.0005417,0.8689514,3.008252,,,0,0.2,,0.3,0.7,0,0 +Pacific cod,0,0.000037935,0.5477087,2.802848,,,0,0.2,,0.3,0.7,0,0 +Arctic cod,0,1.044914,0.8689514,3.008252,,,0,0.2,,0.3,0.7,0.000000001,1.00E-10 +Snow crab,0,3.169973,1,2.75,,,0,0.2,,0.1,0.9,0,0 +Bivalves,0,90.28777,0.755625,3.778125,,,0,0.4,,0.1,0.9,0,0 +Snails,0,1.384463,1.77,8.849999,,,0,0.2,,0.1,0.9,0,0 +Other crabs,0,3.067152,0.82,4.1,,,0,0.2,,0.1,0.9,0,0 +Shrimps,0,7.492234,0.576,2.409,,,0,0.2,,0.1,0.9,0,0 +Sea stars,0,2.180155,0.34,1.7,,,0,0.2,,0.1,0.9,0,0 +Brittle stars,0,5.644247,0.485,2.425,,,0,0.4,,0.1,0.9,0,0 +Basket stars,0,0.5098612,0.34,1.7,,,0,0.2,,0.1,0.9,0,0 +"Urchins, dollars, cucumbers",0,36.28965,0.695,3.475,,,0,0.4,,0.1,0.9,0,0 +Sponge,0,0.5271555,1,5,,,0,0.4,,0.1,0.9,0,0 +Anemones,0,0.3841269,1,5,,,0,0.2,,0.1,0.9,0,0 +Benthic urochordate,0,1.160084,3.58,17.9,,,0,0.4,,0.1,0.9,0,0 +Corals and sea pens,0,0.02567942,0.046,0.23,,,0,0.4,,0.1,0.9,0,0 +Scyphozoid jellies,0,0.3719727,0.88,3,,,0,0.2,,0.3,0.7,0,0 +Octopods,0,0.01057694,1.77,8.849999,,,0,0.2,,0.1,0.9,0,0 +Salmon outgoing,0,0.000520686,1.28,13.56,,,0,0.2,,0.3,0.7,0,0 +Salmon returning,0,0.005206862,1.65,11.6,,,0,0.2,,0.3,0.7,0,0 +Benthic amphipods,0,20.52637,1,5,,,0,0.4,,0.1,0.9,0,0 +Polychaetes,0,27.80796,2.915733,14.57867,,,0,0.4,,0.1,0.9,0,0 +Worms etc.,0,17.03959,2.23,11.15,,,0,0.4,,0.1,0.9,0,0 +Misc. crustaceans,0,5.580986,2.008,10.04,,,0,0.4,,0.1,0.9,0,0 +Copepods,0,2.042696,6,27.74,,,0,0.2,,0.3,0.7,0,0 +Other zooplankton,0,1.225213,5.475,15.64286,,,0,0.2,,0.3,0.7,0,0 +Pelagic microbes,0,1.488708,26.25,75,,,0,0.2,,0.3,0.7,0,0 +Benthic microbes,0,22.31168,26.25,75,,,0,0.2,,0.1,0.9,0,0 +Primary production,1,27.8,75,,,,0,0,,0.3,0.7,0,0 +Pelagic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Benthic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Fishery/Subsistence,3,,,,,,,,,0.3,0.7,, diff --git a/data-raw/Ecosense_ECS_diet.csv b/data-raw/Ecosense_ECS_diet.csv new file mode 100644 index 00000000..85514f75 --- /dev/null +++ b/data-raw/Ecosense_ECS_diet.csv @@ -0,0 +1,54 @@ +DIETS,Polar bears,Toothed whales,Gray whale,Bowhead whale,Walrus/bearded seal,Wintering seals,Procellarids,Cormorants,Other seabirds,Larids,Alcids piscivorous,Alcids planktivorous,Lg.-mouth flatfish,Sm.-mouth flatfish,Lg.-mouth sculpins,Other sculpins,Eelpouts,Pelagic forage fish,Misc. shallow fish,Other demersals,Skates,Walleye pollock,Pacific cod,Arctic cod,Snow crab,Bivalves,Snails,Other crabs,Shrimps,Sea stars,Brittle stars,Basket stars,"Urchins, dollars, cucumbers",Sponge,Anemones,Benthic urochordate,Corals and sea pens,Scyphozoid jellies,Octopods,Salmon outgoing,Salmon returning,Benthic amphipods,Polychaetes,Worms etc.,Misc. crustaceans,Copepods,Other zooplankton,Pelagic microbes,Benthic microbes,Primary production +Polar bears,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Toothed whales,0.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Gray whale,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Bowhead whale,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walrus/bearded seal,0.25,,,,0.000212616,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Wintering seals,0.65,,,,0.000504327,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Procellarids,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Cormorants,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other seabirds,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Larids,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids piscivorous,,,,,,,,,,0.004651598,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids planktivorous,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Lg.-mouth flatfish,,,,,0.006081153,0.000781252,,,,,0.009612602,,,,,,,,,0.005322316,0.02487342,,0.001472492,0.006102135,,,,,,,,,,,,,,,,,,,,,,,,,, +Sm.-mouth flatfish,,,,,0.006081153,0.000781252,,,,,0.009612602,,,,,,,,,0.01650201,0.06433967,,0.01072673,,,,,,,,,,,,,,,,,,,,,,,,,,, +Lg.-mouth sculpins,,0.009999999,,,0.01659991,0.0410623,,,,0.001718235,0.07135769,,,,,,0.04798269,0.005778736,,0.04407414,0.02363462,,0.006649494,0.006265168,,,,,,,,,,,,,,,,,,,,,,,,,, +Other sculpins,,0.009999999,,,,0.008492618,,,,0.001718235,0.07133969,,,,0.206761,,0.000789418,0.004220617,,0.05228622,0.000336991,,0.004856593,,,,,,,,,,,,,,,,,,,,,,,,,,, +Eelpouts,,0.009999999,,,,,,,,,,,,,0.08932029,,,,,0.003859158,0.04130904,,0.004297453,0.003560629,,,,,,,,,,,,,,,,,,,,,,,,,, +Pelagic forage fish,,0.5544065,,,0.000657422,0.06911467,0.05867733,0.25,,0.3324589,0.2731979,,,,,0.03727878,,,,0.05182033,0.05281629,,,0.04948226,,,,,,,,,,,,,,,,,,,,,,,,,, +Misc. shallow fish,,0.03590742,,,0.00509502,0.3092427,,0.25,,0.0267805,0.2405652,,0.3332412,,0.2435342,,0.07879899,0.1874234,0.06125135,0.07786866,0.01548537,,0.06349141,0.002147306,,,,,,,,,,,,,,,,,,,,,,,,,, +Other demersals,,,,,,0.001981432,,,,0.007045029,0.006587705,,,,0.01485121,,0.000345366,,,0.09428567,0.005443891,,0.00277255,0.002785945,,,,,,,,,,,,,,,,,,,,,,,,,, +Skates,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walleye pollock,,,,,,,,,,,,,,,,,,,,,,,0.000578866,,,,,,,,,,,,,,,,,,,,,,,,,,, +Pacific cod,,,,,,,,,,,,,,,,,,,,,0.001371445,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Arctic cod,,0.2796861,,,0.002410548,0.4286107,0.06969959,0.25,,0.5012766,0.2594775,,0.2409175,,,,,,,0.005050726,0.2729864,0.5366726,0.1560087,0.008183806,,,,,,,,,,,,,,,,,,,,,,,,,, +Snow crab,,,0.000256674,0.000113781,0.07158563,,,,,,,,,0.0265204,0.07528889,0.00226101,,,,0.01153278,0.2568457,,0.1453266,,,,,,,,,,,,,,,,0.25,,,,,,,,,,, +Bivalves,,,0.0433623,0.01922197,0.5941439,,,,,1.53E-06,2.65E-06,,0.00729814,0.3710207,,0.001438914,0.000389389,,0.04453,0.001736895,1.76E-05,,0.001407035,4.30E-05,0.2075,,0.5,0.25,0.15,0.5154778,0.125,,,,0.2,,,,0.25,,,,,,,,,,, +Snails,,,0.004340004,0.00192387,0.04782695,,,,,0.005283926,0.003017653,,,0.000498679,,0.006792177,,,0.000733818,,5.89E-05,,0.001507538,,0.0326,,,,,0.05159265,,,,,,,,,0.25,,,,,,,,,,, +Other crabs,,,7.88E-05,3.49E-05,0.02207871,,,,,0.005283772,0.003044799,,,0.000157228,0.1497352,0.05728141,0.002116573,0.000288189,0.005869959,0.02178959,0.06081963,,0.0525628,0.001098868,0.0411,,,,,,,,,,,,,,0.25,,,,,,,,,,, +Shrimps,,0.09993257,1.25E-05,5.55E-06,0.08408973,0.09176343,,0.25,,0.01060208,0.009951027,,0.1977302,,0.1319228,0.01229081,0.01550181,0.009836816,0.1471351,0.181513,0.1139477,0.1423735,0.2859297,0.1600893,,,,,,,,,,,,,,,,,,,,,,,,,, +Sea stars,,,0.004000351,0.001773306,,,,,,,,,,,,,,,,,,,,,0.0015,,,,,,,,,,,,,,,,,,,,,,,,, +Brittle stars,,,0.003698438,0.001639472,,,,,,,,,,0.03040408,1.92E-05,0.005426886,,,,,6.06E-06,,,,0.05895,,,,,,,,,,,,,,,,,,,,,,,,, +Basket stars,,,0.00014616,6.48E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"Urchins, dollars, cucumbers",,,0.02290767,0.01015469,0.05747112,,,,,,,,,0.05108213,,,,,,,0.000107293,,,,0.0081,,,,,0.2723194,,,,,,,,,,,,,,,,,,,, +Sponge,,,0.000249278,0.000110502,,,,,,,,,,,,,,,,,,,,,0.00275,,,,,,,,,,,,,,,,,,,,,,,,, +Anemones,,,0.002641741,0.001171051,,,,,,,,,,,,0.06376915,,,,,1.18E-05,,,,0.00115,,,,,,,,,,,,,,,,,,,,,,,,, +Benthic urochordate,,,0.002641741,0.001171051,0.006627641,,,,,,,,,,,,,,,,0.00021469,,,,,,,,,0.03140422,,,,,,,,,,,,,,,,,,,, +Corals and sea pens,,,2.54E-06,1.13E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Scyphozoid jellies,,,,,,,,,,,,0.0192604,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Octopods,,0.000067419,,,0.007169423,0.001830349,,,,,,,,,,,,,,,6.64E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Salmon outgoing,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Salmon returning,,,,,,,,,,,,,,,,,,,,,0.02096798,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Benthic amphipods,,,0.9,0.005671234,0.03530366,0.03725448,0.002204452,,0.1,0.03446057,0.02325702,,0.0252337,0.1203165,0.0703186,0.4825385,0.2814546,0.01338544,0.4361333,0.3160916,0.03019983,0.0429575,0.137789,0.09571919,0.05525,,0.05,,0.15,,0.125,0.25,,,0.2,,,,,,,,,,,,,,, +Polychaetes,,,0.01086888,0.00481804,0.03047494,,,,,0.02371788,0.008201232,,0.04969615,0.3519998,0.01052774,0.2352545,0.5376897,0.004593154,0.1107291,0.1004426,0.007359331,,0.06924623,0.004512317,0.27195,,0.3,0.25,0.15,0.1292059,0.125,,,,,,,,,,,,,,,,,,, +Worms etc.,,,0.002226611,0.000987029,0.005586154,,,,,,,,,0.008323649,,0.06003539,,,0.02272738,0.000147471,,,,,0.03125,,0.05,0.25,,,,,,,,,,,,,,,,,,,,,, +Misc. crustaceans,,,0.002566263,0.001137593,,,,,,0.00012475,,,,0.03681871,0.006913655,0.007458307,0.00088703,0.000632304,0.06850621,0.003324673,0.000133681,0.03436605,0.001507538,0.01197542,0.01425,,0.05,,0.15,,0.125,0.25,,,0.2,,,,,,,,,,,,,,, +Copepods,,,,0.7125,,,0.004408904,,0.45,,,0.3485923,9.47E-06,9.85E-05,,,5.11E-07,0.3125479,0.01474068,0.000178091,0.000000209,0.1472829,,0.3724843,,,,,,,,0.25,,,,,,0.675,,0.5,0.5,,,,,,0.25,,, +Other zooplankton,,,,0.2375,,0.009084825,0.8650097,,0.45,0.02627006,0.01077462,0.6321473,0.1458736,0.002759635,0.000807251,0.02817404,0.03404389,0.4612935,0.08764321,0.01217405,0.006646099,0.0963475,0.05386934,0.2755505,0.0041,,,,,,,0.25,,,,,,0.225,,0.5,0.5,,,,,,,,, +Pelagic microbes,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.05,,,,,,,,0.5,0.15,,, +Benthic microbes,,,,,,,,,,,,,,,,,,,,,,,,,,0.25,,,,,,,,0.25,0.2,0.25,0.25,,,,,0.5,0.5,0.5,0.5,,,,, +Primary production,,,,,,,,,,,,,,,,,,,,,,,,,0.0039,,,,,,,,0.25,,,,,0.05,,,,,,,,0.5,0.6,0.7,, +Pelagic detritus,,,,,,,,,,0.005581916,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.3,, +Benthic detritus,,,,,,,,,,0.01302447,,,,,,,,,,,,,,,0.26565,0.75,0.05,0.25,0.4,,0.5,,0.75,0.75,0.2,0.75,0.75,,,,,0.5,0.5,0.5,0.5,,,,1, +Import,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/data-raw/Ecosense_ECS_pedigree.csv b/data-raw/Ecosense_ECS_pedigree.csv new file mode 100644 index 00000000..2d1148c5 --- /dev/null +++ b/data-raw/Ecosense_ECS_pedigree.csv @@ -0,0 +1,53 @@ +Group,B,PB,QB,Diet,F_Fishery/Subsistence +Polar bears,0.8,0.5,0.6,0.8,0.8 +Toothed whales,0.5,0.6,0.6,0.7,0.5 +Gray whale,0.5,0.6,0.6,0.7,0 +Bowhead whale,0.5,0.6,0.6,0.7,0.1 +Walrus/bearded seal,0.8,0.6,0.6,0.7,0.5 +Wintering seals,0.8,0.6,0.6,0.6,0.5 +Procellarids,0.5,0.6,0.6,0.8,0 +Cormorants,0.5,0.6,0.6,0.8,0 +Other seabirds,0.5,0.6,0.6,0.8,0 +Larids,0.5,0.6,0.6,0.8,0 +Alcids piscivorous,0.5,0.6,0.6,0.8,0 +Alcids planktivorous,0.5,0.6,0.6,0.8,0 +Lg.-mouth flatfish,0.8,0.5,0.5,0.3,0 +Sm.-mouth flatfish,0.8,0.6,0.6,0.3,0 +Lg.-mouth sculpins,0.8,0.6,0.6,0.3,0 +Other sculpins,0.8,0.6,0.6,0.3,0 +Eelpouts,0.8,0.6,0.6,0.3,0 +Pelagic forage fish,0.8,0.6,0.6,0.3,0 +Misc. shallow fish,0.8,0.6,0.6,0.3,0 +Other demersals,0.8,0.6,0.6,0.3,0 +Skates,0.1,0.6,0.7,0.8,0 +Walleye pollock,0.1,0.6,0.6,0.3,0 +Pacific cod,0.1,0.6,0.6,0.8,0 +Arctic cod,0.8,0.2,0.2,0.3,0 +Snow crab,0.1,0.6,0.6,0.8,0 +Bivalves,0.1,0.5,0.7,0.8,0 +Snails,0.1,0.6,0.7,0.8,0 +Other crabs,0.1,0.6,0.7,0.8,0 +Shrimps,0.8,0.6,0.7,0.8,0 +Sea stars,0.1,0.6,0.7,0.8,0 +Brittle stars,0.1,0.6,0.7,0.8,0 +Basket stars,0.1,0.6,0.7,0.8,0 +"Urchins, dollars, cucumbers",0.1,0.5,0.7,0.8,0 +Sponge,0.1,0.6,0.7,0.8,0 +Anemones,0.1,0.6,0.7,0.8,0 +Benthic urochordate,0.1,0.6,0.7,0.8,0 +Corals and sea pens,0.1,0.6,0.7,0.8,0 +Scyphozoid jellies,0.1,0.6,0.6,0.8,0 +Octopods,0.8,0.6,0.7,0.8,0 +Salmon outgoing,0.8,0.6,0.6,0.8,0 +Salmon returning,0.8,0.6,0.6,0.8,0 +Benthic amphipods,0.8,0.6,0.7,0.8,0 +Polychaetes,0.1,0.5,0.7,0.8,0 +Worms etc.,0.1,0.6,0.7,0.8,0 +Misc. crustaceans,0.1,0.6,0.7,0.8,0 +Copepods,0.8,0.6,0.6,0.8,0 +Other zooplankton,0.8,0.6,0.7,0.8,0 +Pelagic microbes,0.8,0.7,0.7,0.8,0 +Benthic microbes,0.8,0.7,0.7,0.8,0 +Primary production,0.8,0.7,0,0.01,0 +Pelagic detritus,0,0,0,0,0 +Benthic detritus,0,0,0,0,0 diff --git a/data-raw/Ecosense_GOA_base.csv b/data-raw/Ecosense_GOA_base.csv new file mode 100644 index 00000000..4a340d95 --- /dev/null +++ b/data-raw/Ecosense_GOA_base.csv @@ -0,0 +1,51 @@ +Group,Type,Biomass,PB,QB,EE,ProdCons,BioAcc,Unassim,DetInput,PelDetFate,BenthDetFate,F_Fishery,D_Fishery +Toothed whales,0,0.06165833,0.04713691,12.43829,,,0,0.2,,0.5,0.5,1.29E-07,8.45E-07 +Gray whale,0,0.05543134,0.063365,8.87285,,,0,0.2,,0.5,0.5,8.57E-08,0 +Other baleen,0,0.4567338,0.03134125,6.980565,,,0,0.2,,0.5,0.5,0,5.19E-05 +Other pinnipeds,0,0.03346486,0.1222834,36.81018,,,0,0.2,,0.5,0.5,0.000090749,4.04E-06 +Procellarids,0,0.001051795,0.06487884,73,,,0,0.2,,0.5,0.5,0,1.43E-06 +Alcids piscivorous,0,0.01131623,0.09528826,72.57302,,,0,0.2,,0.5,0.5,0,1.54E-05 +Larids,0,0.001458566,0.1115763,95.5601,,,0,0.2,,0.5,0.5,0,1.98E-06 +Alcids planktivorous,0,0.000299744,0.1694877,110,,,0,0.2,,0.5,0.5,0,4.07E-07 +Other seabirds,0,0.000461801,0.09378317,109.5,,,0,0.2,,0.5,0.5,0,6.27E-07 +Cormorants,0,0.000348881,0.1587271,73,,,0,0.2,,0.5,0.5,0,4.74E-07 +Sharks,0,0.142353,0.1,3.729058,,,0,0.2,,0.5,0.5,0.000176845,0.00594262 +Walleye pollock,0,6.224493,0.6538435,4.109179,,,-1.35,0.2,,0.5,0.5,0.0618452,0.281034 +Pacific cod,0,1.520393,0.5576789,2.39571,,,0,0.2,,0.5,0.5,0.1218526,0.1289747 +Pelagic forage fish,0,14.26999,0.8180392,3.676071,,,-0.11,0.2,,0.5,0.5,0.05087369,0.005135313 +Lg.-mouth flatfish,0,8.015218,0.2929934,1.443946,,,0,0.2,,0.5,0.5,0.08691967,0.07947716 +Sm.-mouth flatfish,0,2.44411,0.2152337,1.93294,,,0,0.2,,0.5,0.5,0.04497369,0.02795422 +Skates,0,0.191803,0.2,2,,,0,0.2,,0.5,0.5,0.003005425,0.01178723 +Other demersals,0,4.505964,0.1830862,2.246801,,,-0.002,0.2,,0.5,0.5,0.09719946,0.09624746 +Eelpouts,0,1.069425,0.4,2,,,0,0.2,,0.5,0.5,7.66E-06,1.66E-05 +Lg.-mouth sculpins,0,0.08888517,0.4,2,,,0,0.2,,0.5,0.5,0.000193433,0.004255149 +Other sculpins,0,0.8168654,0.4,2,,,0,0.2,,0.5,0.5,0,0 +Misc. shallow fish,0,0.8389893,0.4,2,,,0,0.2,,0.5,0.5,0.000319678,0.000919832 +Octopods,0,0.7834731,0.8,3.65,,,0,0.2,,0.5,0.5,0.000165189,0.000167874 +Squid,0,1.265454,3.2,10.67,,,0,0.2,,0.5,0.5,0.000119335,0.000225772 +Salmon returning,0,0.8566338,1.815861,11.8269,,,0,0.2,,0.5,0.5,0.29042,0.02977088 +Salmon outgoing,0,0.01713268,1.641523,14.38647,,,0,0.2,,0.5,0.5,0,0 +Other crabs,0,5.218338,0.8414152,3.966247,,,0,0.2,,0.1,0.9,0.003609303,0.000240075 +Shrimps,0,22.22855,0.576,2.41,,,0,0.2,,0.1,0.9,0.00019897,4.79E-06 +Sea stars,0,0.09551849,1.21,6.05,,,0,0.2,,0.1,0.9,0.000009245,0.003106511 +Brittle stars,0,4.544021,1.21,6.05,,,0,0.2,,0.1,0.9,0,0 +"Urchins, dollars, cucumbers",0,1.630926,0.61,3.05,,,0,0.2,,0.1,0.9,3.51E-06,7.42E-05 +Snails,0,0.8638767,1.81,9.049999,,,0,0.2,,0.1,0.9,3.27E-07,0 +Misc. crustaceans,0,2.120289,7.4,37,,,0,0.2,,0.1,0.9,0,0 +Benthic amphipods,0,5.868869,7.4,37,,,0,0.2,,0.1,0.9,0,0 +Anemones,0,0.08886787,1,5,,,0,0.4,,0.1,0.9,4.09E-07,7.39E-05 +Corals and sea pens,0,0.005739689,0.05045965,0.2522982,,,0,0.4,,0.1,0.9,2.98E-06,2.43E-05 +Worms etc.,0,3.772863,2.195745,10.97872,,,0,0.4,,0.1,0.9,0,0 +Benthic urochordate,0,0.2448,3.58,17.9,,,0,0.4,,0.1,0.9,0,0.000006744 +Sponge,0,0.1075014,1,5,,,0,0.4,,0.1,0.9,2.65E-07,0.000020834 +Bivalves,0,13.85198,1.3,6.5,,,0,0.4,,0.1,0.9,0.000280681,0 +Polychaetes,0,3.923291,2.97,14.85,,,0,0.4,,0.1,0.9,0,0 +Scyphozoid jellies,0,0.11,0.88,3,,,0,0.2,,0.7,0.3,0.000141226,0.000195899 +Other zooplankton,0,23.99852,5.30758,15.16452,,,0,0.2,,0.7,0.3,0,0 +Copepods,0,21.8635,6,27.74,,,0,0.2,,0.7,0.3,0,0 +Pelagic microbes,0,12.25505,36.5,104.2857,,,0,0.2,,0.7,0.3,0,0 +Benthic microbes,0,7.252296,36.5,104.2857,,,0,0.2,,0.1,0.9,0,0 +Primary production,1,40.39581,110.2083,,,,0,0,,0.5001647,0.4998353,0,0 +Pelagic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Benthic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Fishery/Subsistence,3,,,,,,,,,0.3908825,0.6091174,, diff --git a/data-raw/Ecosense_GOA_diet.csv b/data-raw/Ecosense_GOA_diet.csv new file mode 100644 index 00000000..90f58390 --- /dev/null +++ b/data-raw/Ecosense_GOA_diet.csv @@ -0,0 +1,51 @@ +DIETS,Toothed whales,Gray whale,Other baleen,Other pinnipeds,Procellarids,Alcids piscivorous,Larids,Alcids planktivorous,Other seabirds,Cormorants,Sharks,Walleye pollock,Pacific cod,Pelagic forage fish,Lg.-mouth flatfish,Sm.-mouth flatfish,Skates,Other demersals,Eelpouts,Lg.-mouth sculpins,Other sculpins,Misc. shallow fish,Octopods,Squid,Salmon returning,Salmon outgoing,Other crabs,Shrimps,Sea stars,Brittle stars,"Urchins, dollars, cucumbers",Snails,Misc. crustaceans,Benthic amphipods,Anemones,Corals and sea pens,Worms etc.,Benthic urochordate,Sponge,Bivalves,Polychaetes,Scyphozoid jellies,Other zooplankton,Copepods,Pelagic microbes,Benthic microbes,Primary production +Toothed whales,0.000053212,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Gray whale,0.000195671,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other baleen,0.00161226,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other pinnipeds,0.00011813,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Procellarids,,,,0.00001722,8.24E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids piscivorous,,,,0.000185269,0.000886036,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Larids,,,,2.39E-05,0.000114203,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids planktivorous,,,,4.91E-06,2.35E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other seabirds,,,,7.56E-06,0.000036158,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Cormorants,,,,5.71E-06,2.73E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Sharks,0.000161708,,,,,,,,,,0.007149246,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walleye pollock,0.003959108,,0.01536035,0.2443831,0.1994964,0.1707221,0.1374473,0.002219961,0.019285,0.000520214,0.0642318,0.01730322,0.165236,,0.2428017,0.001732163,0.05733645,0.02243403,0.003956129,0.1298187,,,,,,,,,,,,,,,,,,,,,,0.001,,,,, +Pacific cod,0.01370258,,,0.01315614,0.03869898,0.0953234,0.02666247,0.000430635,0.003740967,0.000100913,0.01441741,4.16E-05,4.53E-05,,0.00643942,0.000612311,0.01391214,0.000445677,,0.000913099,0.04028247,,,,,,,,,,,,,,,,,,,,,,,,,, +Pelagic forage fish,0.1161123,,0.2332085,0.3194725,0.2109555,0.5695944,0.7290136,0.0579436,0.1867094,0.9490509,0.09923565,0.05399713,0.05462447,,0.3145934,0.002486164,0.1599201,0.01277022,0.01307451,0.08628713,,,,0.15,,,,,,,,,,,,,,,,,,0.008000001,,,,, +Lg.-mouth flatfish,0.005098103,,,0.06527214,,,,,,,0.1543446,0.000791903,0.01130468,,0.01020996,1.63E-05,0.1309565,0.000628949,,0.000360408,,,,,,,,,,,,,,,,,,,,,,,,,,, +Sm.-mouth flatfish,0.001552685,,,0.01064673,,,,,,,0.01475467,0.001102062,0.006265766,,0.003265063,,0.09747098,6.51E-05,7.38E-06,0.03985396,0.009723351,0.000782896,,,,,,,,,,,,,,,,,,,,,,,,, +Skates,0.001757251,,,0.002557138,,,,,,,0.006894708,,,,,,8.46E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other demersals,0.0355815,,0.000854911,0.0275689,0.000779691,0.000999022,0.000999001,0.000999028,0.000656877,0.000999001,0.1612058,4.97E-06,0.000487305,,0.01635126,,0.007544784,0.00062241,,5.16E-06,,,,,,,,,,,,,,,,,,,,,,,,,,, +Eelpouts,0.03762805,,,0.001576726,,,,,,,,0.000384112,0.00827353,,0.01708649,0.001052443,0.06045089,1.19E-05,0.01845699,0.03330814,,,,,,,,,,,,,,,,,,,,,,,,,,, +Lg.-mouth sculpins,,,,0.004269105,,,,,,,0.001023347,,,,0.0004592,,0.001537074,0.00074721,,0.001836508,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other sculpins,0.0239836,,,0.001656653,,,,,,,0.008203304,0.000368221,0.03324791,,0.003973727,0.002730238,0.008991601,0.001097425,0.01351007,0.02105363,,,,,,,,,,,,,,,,,,,,,,,,,,, +Misc. shallow fish,0.0183782,,0.01225261,0.01958377,,,,,,,0.01196223,0.000873976,0.00369463,,0.004439839,0.00072485,0.009763914,0.000227009,0.000986536,0.01898878,0.04985735,,,,,,,,,,,,,,,,,,,,,,,,,, +Octopods,,,,0.003456976,,,,,,,0.01923347,0.000801896,0.01928917,,0.004122138,5.58E-05,0.005395931,0.03390534,,0.01435831,,,,,,,,,,,,,,,,,,,,,,,,,,, +Squid,0.7395499,,0.003086945,0.0333473,0.5152936,0.03660618,0.005065987,0.000737371,0.5699574,,0.03743711,0.005250731,0.004351677,,0.002514759,,0.007717871,0.02896504,,6.85E-05,,,,,0.2,,,,,,,,,,,,,,,,,0.001,,,,, +Salmon returning,0.000544865,,0.01958669,0.09488117,,,,,,,0.1593205,,,,0.01610603,,0.007721416,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Salmon outgoing,1.09E-05,,0.000391734,0.001760886,,,,,0.000253304,,,,,,,,0.000154428,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other crabs,,0.00868696,,0.07330567,,,,,,0.001637441,0.03539184,0.02547316,0.2096924,,0.05080061,0.05152845,0.004317433,0.02019694,0.1014338,0.1003206,0.05453777,,0.2,,,,0.001857261,,0.015,,,,,,,,,,,,,,,,,, +Shrimps,,0.03814375,,7.59E-05,,,,,,0.01679093,0.04296356,0.1641614,0.1930464,,0.1034172,0.1775361,0.2619857,0.2075776,0.01367033,0.1972779,0.5433435,0.06150237,,,,,,,0.01,,,,,,,,,,,,,,,,,, +Sea stars,,0.000168028,,,,,,,,,3.78E-05,0.001743829,0.001815502,,5.86E-07,0.000471179,,2.18E-06,,5.38E-05,,,,,,,0.000007134,,,,,,,,,,,,,,,,,,,, +Brittle stars,,0.007993475,,,,,,,,,0.001799504,,0.000263089,,2.68E-05,0.1307027,0.000445373,1.20E-07,0.1822525,0.000102108,0.000181826,,,,,,0.003674393,,0.03,,,,,,,,,,,,,,,,,, +"Urchins, dollars, cucumbers",,0.002868994,,0.08012424,,,,,,,0.00152771,3.39E-05,1.33E-05,,0.000167073,0.04294402,,2.75E-06,,2.12E-05,,,,,,,0.002019559,,,,,,,,,,,,,,,,,,,, +Snails,,0.001471001,,,,,,,,,0.001029396,4.63E-05,0.003873213,,0.00034488,0.002924132,,0.00091642,,0.001372771,,,0.4,,,,0.002910736,,0.005,,,,,,,,,,,,,,,,,, +Misc. crustaceans,,0.00358871,,,0.002251724,0.03868497,0.002705831,0.000634075,0.000665534,0.001579755,0.000458313,0.000930434,0.003999098,,0.000181152,0.08995359,0.002523744,0.001508952,0.005357116,0.000792121,0.01442491,,,,,,0.000473233,,,,,,,,0.125,0.125,0.001585444,0.125,0.125,0.125,,,,,,, +Benthic amphipods,,0.9,,,0.000155224,,0.00744352,0.001744287,0.001830829,0.004345777,0.002902649,0.05938753,0.09548885,0.00000074,0.004069764,0.03767442,0.1267503,0.02685756,0.3280453,0.05959999,0.1947338,0.00359031,,,,,0.001832292,0.3,,0.1,,,,,0.125,0.125,0.001585444,0.125,0.125,0.125,,,,,,, +Anemones,,0.000156329,,,,,,,,,3.52E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Corals and sea pens,,1.01E-05,,,,,,,,,,,,,,,,2.65E-07,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Worms etc.,,0.006274812,,,9.61E-05,,0.004606393,0.001079445,0.001133001,,0.006249924,6.17E-05,0.003281819,,0.000493864,0.03986195,0.0164955,0.000021125,0.02537635,0.01925321,0.03702217,,,,,,0.2279804,,0.01,,,0.2,,,,,,,,,,,,,,, +Benthic urochordate,,0.000430632,,,,,,,,,,,0.000000921,,1.83E-07,0.000503441,,0.000544108,,,,,,,,,4.46E-06,,,,,,,,,,,,,,,,,,,, +Sponge,,0.000189108,,,,,,,,,,,2.79E-05,,8.28E-07,1.27E-07,,6.28E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Bivalves,,0.02344889,,,0.000368692,,0.01768009,0.00414309,0.004348645,,0.005278854,0.000192252,0.002028014,,0.000433315,0.08457874,0.002404211,5.30E-05,0.05257818,0.000393605,,,0.4,,,,0.2544916,0.1,0.91,,,0.2,,,,,,,,,,,,,,, +Polychaetes,,0.006569219,,0.002660374,0.000103289,,0.004953088,0.001160688,0.001218275,,0.001478873,0.004868158,0.05555004,7.80E-06,0.001962562,0.2496711,0.001560155,0.001169203,0.2386699,0.10978,0.02550207,,,,,,0.2717699,,0.02,,,0.2,,,,,,,,,,,,,,, +Scyphozoid jellies,,,,,,,,,,,0.005856221,1.72E-06,,,,3.28E-08,,0.004273257,,7.51E-06,,0.000036637,,,,,,,,,,,,,,,,,,,,,,,,, +Other zooplankton,,,0.5818204,,0.01520136,0.04391786,0.02999332,0.4632186,0.1048208,0.01196193,0.08262146,0.5702611,0.07453965,0.9000154,0.1908987,0.07980518,0.005273665,0.5375271,0.001346272,0.1561293,0.01137116,0.9312431,,0.65,0.6,0.5,,0.2,,,,,,,,,,,,,,0.7400001,0.006289897,,,, +Copepods,,,0.1334379,,0.01542998,0.04415208,0.03015328,0.4656892,0.1053799,0.0130131,0.04071566,0.09128769,0.000105551,0.09997606,5.90E-05,0.002411173,,0.0915686,,2.77E-05,0.01865575,0.002844756,,0.2,0.2,0.5,,,,,,,,,,,,,,,,0.15,0.25,,,, +Pelagic microbes,,,,,,,,,,,,,,,,8.87E-07,,,0.00065419,,0.000363653,,,,,,,,,,,,,,,,,,,,,0.03,0.15,0.5,,, +Benthic microbes,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.5,0.5,0.15,0.15,0.4955608,0.15,0.15,0.15,0.5,,,,,, +Primary production,,,,,,,,,,,,,1.78E-07,,5.42E-07,,,4.38E-07,,,,,,,,,,,,,0.25,0.2,,,,,,,,,,0.07000001,0.5937101,0.5,0.7,, +Pelagic detritus,,,,,,,0.003276177,,,,,,,,,,,,,,,,,,,,0.000732203,,,,,,,,,,,,,,,,,,0.3,, +Benthic detritus,,,,,,,,,,,0.01223919,0.000631227,0.04945371,,0.00477988,2.26E-05,0.009285232,0.00585382,0.00062444,0.008015925,,,,,,,0.2322469,0.4,,0.9,0.75,0.2,0.5,0.5,0.6,0.6,0.5012683,0.6,0.6,0.6,0.5,,,,,1, +Import,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/data-raw/Ecosense_GOA_pedigree.csv b/data-raw/Ecosense_GOA_pedigree.csv new file mode 100644 index 00000000..8d072f57 --- /dev/null +++ b/data-raw/Ecosense_GOA_pedigree.csv @@ -0,0 +1,50 @@ +Group,B,PB,QB,Diet,F_Fishery/Subsistence +Toothed whales,0.8,0.6,0.6,0.8,0.3 +Gray whale,0.5,0.6,0.6,0.8,0.3 +Other baleen,0.8,0.6,0.6,0.8,0.1 +Other pinnipeds,0.5,0.6,0.8,0.8,0.3 +Procellarids,0.8,0.6,0.6,0.8,0.5 +Alcids piscivorous,0.5,0.6,0.6,0.8,0.5 +Larids,0.5,0.6,0.6,0.8,0.5 +Alcids planktivorous,0.5,0.6,0.6,0.8,0.5 +Other seabirds,0.8,0.6,0.6,0.8,0.5 +Cormorants,0.5,0.6,0.6,0.8,0.5 +Sharks,0.8,0.7,0.7,0.8,0.7 +Walleye pollock,0.8,0.4,0.4,0.1,0.3 +Pacific cod,0.8,0.4,0.4,0.1,0.7 +Pelagic forage fish,0.8,0.7,0.7,0.8,0.5 +Lg.-mouth flatfish,0.5,0.4,0.4,0.1,0.7 +Sm.-mouth flatfish,0.8,0.6,0.6,0.7,0.3 +Skates,0.5,0.7,0.7,0.8,0.7 +Other demersals,0.8,0.7,0.8,0.8,0.8 +Eelpouts,0.8,0.7,0.7,0.8,0.7 +Lg.-mouth sculpins,0.1,0.7,0.7,0.8,0.8 +Other sculpins,0.8,0.7,0.7,0.8,0 +Misc. shallow fish,0.8,0.7,0.7,0.7,0.7 +Octopods,0.8,0.7,0.7,0.8,0.4 +Squid,0.8,0.7,0.7,0.8,0.4 +Salmon returning,0.8,0.5,0.8,0.7,0.3 +Salmon outgoing,0.8,0.6,0.6,0.8,0 +Other crabs,0.8,0.6,0.8,0.8,0.5 +Shrimps,0.8,0.6,0.8,0.8,0.5 +Sea stars,0.5,0.6,0.7,0.8,0.8 +Brittle stars,0.5,0.6,0.7,0.8,0 +"Urchins, dollars, cucumbers",0.5,0.6,0.7,0.8,0.5 +Snails,0.8,0.6,0.7,0.8,0.3 +Misc. crustaceans,0.8,0.6,0.7,0.8,0 +Benthic amphipods,0.8,0.6,0.7,0.8,0 +Anemones,0.5,0.6,0.7,0.8,0.5 +Corals and sea pens,0.1,0.6,0.7,0.8,0.5 +Worms etc.,0.8,0.6,0.7,0.8,0 +Benthic urochordate,0.8,0.6,0.7,0.8,0.5 +Sponge,0.5,0.6,0.7,0.8,0.5 +Bivalves,0.8,0.6,0.7,0.8,0.3 +Polychaetes,0.8,0.6,0.7,0.8,0 +Scyphozoid jellies,0.5,0.6,0.6,0.8,0.5 +Other zooplankton,0.8,0.7,0.7,0.8,0 +Copepods,0.8,0.7,0.6,0.8,0 +Pelagic microbes,0.8,0.7,0.7,0.8,0 +Benthic microbes,0.8,0.7,0.7,0.1,0 +Primary production,0.8,0.7,0,0.01,0 +Pelagic detritus,0.8,0,0,0,0 +Benthic detritus,0.8,0,0,0,0 diff --git a/data-raw/Rpath_unbalanced_data.R b/data-raw/Rpath_unbalanced_data.R new file mode 100644 index 00000000..e0973e81 --- /dev/null +++ b/data-raw/Rpath_unbalanced_data.R @@ -0,0 +1,45 @@ +## Code to create unbalanced ecopath objects for Rpath examples +## Doesn't run on package install, needs to be run in repo and then Rdata +## files created in data and inst/extdata need to be pushed/committed. +## +## Only re-run if changing input data changes, or if structure of unbalanced +## ecosystem object changes. +## +## Also CREATE ENTRY in R/data.R file for each ecosystem. + +## This MUST BE RUN from the Rpath package's root directory (the +## directory with the /data, /R, /data-raw and /inst folders). + +library(usethis) +library(Rpath) + +Ecosense.EBS <- read.rpath.params("data-raw/Ecosense_EBS_base.csv", + "data-raw/Ecosense_EBS_diet.csv", + "data-raw/Ecosense_EBS_pedigree.csv" +) +Ecosense.GOA <- read.rpath.params("data-raw/Ecosense_GOA_base.csv", + "data-raw/Ecosense_GOA_diet.csv", + "data-raw/Ecosense_GOA_pedigree.csv" +) +Ecosense.ECS <- read.rpath.params("data-raw/Ecosense_ECS_base.csv", + "data-raw/Ecosense_ECS_diet.csv", + "data-raw/Ecosense_ECS_pedigree.csv" +) +usethis::use_data(Ecosense.EBS, overwrite = TRUE) +usethis::use_data(Ecosense.GOA, overwrite = TRUE) +usethis::use_data(Ecosense.ECS, overwrite = TRUE) + +#files you want available to the user to inspect +extfiles <- c("data-raw/Ecosense_EBS_base.csv", + "data-raw/Ecosense_EBS_diet.csv", + "data-raw/Ecosense_EBS_pedigree.csv", + "data-raw/Ecosense_GOA_base.csv", + "data-raw/Ecosense_GOA_diet.csv", + "data-raw/Ecosense_GOA_pedigree.csv", + "data-raw/Ecosense_ECS_base.csv", + "data-raw/Ecosense_ECS_diet.csv", + "data-raw/Ecosense_ECS_pedigree.csv") + +file.copy(extfiles,"inst/extdata", overwrite=TRUE) + + diff --git a/data/Ecosense.EBS.rda b/data/Ecosense.EBS.rda new file mode 100644 index 00000000..71d29f42 Binary files /dev/null and b/data/Ecosense.EBS.rda differ diff --git a/data/Ecosense.ECS.rda b/data/Ecosense.ECS.rda new file mode 100644 index 00000000..885dda6b Binary files /dev/null and b/data/Ecosense.ECS.rda differ diff --git a/data/Ecosense.GOA.rda b/data/Ecosense.GOA.rda new file mode 100644 index 00000000..39c485f2 Binary files /dev/null and b/data/Ecosense.GOA.rda differ diff --git a/inst/extdata/Ecosense_EBS_base.csv b/inst/extdata/Ecosense_EBS_base.csv new file mode 100644 index 00000000..f0d21e03 --- /dev/null +++ b/inst/extdata/Ecosense_EBS_base.csv @@ -0,0 +1,55 @@ +Group,Type,Biomass,PB,QB,EE,ProdCons,BioAcc,Unassim,DetInput,PelDetFate,BenthDetFate,F_Fishery,D_Fishery +Toothed whales,0,0.03503154,0.06911141,17.39968,,,0,0.2,,0.4,0.6,2.52E-05,0.000006747 +Gray whales,0,0.0326672,0.063365,8.87285,,,0,0.2,,0.4,0.6,0,0 +Other baleen,0,0.5007642,0.02832879,6.642456,,,0,0.2,,0.4,0.6,0.000000183,1.91E-05 +Bowhead whales,0,0.007173534,0.01005034,8.679965,,,0,0.2,,0.4,0.6,0,0 +Other pinnipeds,0,0.04919672,0.09292668,33.97923,,,0,0.2,,0.4,0.6,0.000100598,5.62E-06 +Walrus/bearded seal,0,0.1142484,0.051293,15.37061,,,0,0.2,,0.4,0.6,3.09E-05,5.96E-06 +Wintering seals,0,0.03029022,0.068998,19.19651,,,0,0.2,,0.4,0.6,0.000031609,3.15E-07 +Procellarids,0,0.000920162,0.07456178,73,,,0,0.2,,0.4,0.6,2.20E-09,0.000003567 +Alcids piscivorous,0,0.008617982,0.1623509,72.05511,,,0,0.2,,0.4,0.6,2.08E-08,3.34E-05 +Larids,0,0.000767614,0.08903116,104.9432,,,0,0.2,,0.4,0.6,1.90E-09,2.98E-06 +Alcids planktivorous,0,0.001754495,0.1694877,110,,,0,0.2,,0.4,0.6,4.20E-09,6.80E-06 +Other seabirds,0,0.000101753,0.06846981,76.18891,,,0,0.2,,0.4,0.6,2.00E-10,3.94E-07 +Cormorants,0,0.000149799,0.1587271,73,,,0,0.2,,0.4,0.6,4.00E-10,5.81E-07 +Sharks,0,0.0532473,0.1,3,,,0,0.2,,0.4,0.6,1.55E-05,0.000695172 +Walleye pollock,0,22.97889,0.8208976,4.193416,,,0,0.2,,0.392,0.608,0.4041824,2.104923 +Pacific cod,0,2.650923,0.5080103,2.739351,,,0,0.2,,0.392,0.608,0.2240711,0.1983278 +Pelagic forage fish,0,7.644652,0.7672387,3.732284,,,0,0.2,,0.392,0.608,0.02158515,0.007684128 +Lg.-mouth flatfish,0,1.58756,0.1937844,1.213555,,,0,0.2,,0.392,0.608,0.01807182,0.04641179 +Sm.-mouth flatfish,0,11.31311,0.2096047,1.325415,,,0,0.2,,0.392,0.608,0.1925451,0.2227745 +Skates,0,0.7733867,0.2,2,,,0,0.2,,0.392,0.608,0.004292543,0.02400982 +Other demersals,0,1.382284,0.2117719,2.526838,,,0,0.2,,0.392,0.608,0.01536881,0.01027679 +Eelpouts,0,2.371533,0.4,2,,,0,0.2,,0.392,0.608,0,0 +Lg.-mouth sculpins,0,0.5403231,0.4,2,,,0,0.2,,0.392,0.608,0.000573506,0.009394558 +Other sculpins,0,1.136692,0.4,2,,,0,0.2,,0.392,0.608,0,0 +Misc. shallow fish,0,1.167694,0.4,2,,,0,0.2,,0.392,0.608,1.13E-05,3.58E-05 +Octopods,0,0.192476,0.8,3.65,,,0,0.2,,0.392,0.608,7.99E-05,0.000228618 +Squids,0,0.9269976,3.2,10.67,,,0,0.2,,0.392,0.608,0.000454888,0.000875192 +Salmon returning,0,0.1637697,1.65,11.6,,,0,0.2,,0.392,0.608,0.1691487,0.00067146 +Salmon outgoing,0,0.0141972,1.28,13.56,,,0,0.2,,0.392,0.608,0,0 +Other crabs,0,3.244238,0.9338375,3.872315,,,0,0.2,,0.1,0.9,0.06657811,0.003027228 +Snow crab,0,2.178832,1.295101,3.117084,,,0,0.2,,0.1,0.9,0.3006897,0.006839902 +Shrimps,0,19.44489,0.5756463,2.40941,,,0,0.2,,0.1,0.9,2.25E-07,0.000001989 +Sea stars,0,2.471359,1.21,6.05,,,0,0.2,,0.1,0.9,3.87E-05,0.006488753 +Brittle stars,0,2.950093,1.21,6.05,,,0,0.2,,0.1,0.9,0,0 +Urchins dollars cucumbers,0,1.167418,0.61,3.05,,,0,0.2,,0.1,0.9,3.48E-07,6.56E-05 +Snails,0,0.8071689,1.81,9.049999,,,0,0.2,,0.1,0.9,1.88E-07,1.80E-05 +Misc. crustacean,0,8.88581,7.4,37,,,0,0.2,,0.1,0.9,0,0 +Benthic amphipods,0,12.79612,7.4,37,,,0,0.2,,0.1,0.9,0,0 +Anemones,0,0.1095207,1,5,,,0,0.4,,0.1,0.9,4.31E-07,0.000384743 +Corals and sea pens,0,0.02658792,0.06929576,0.3464788,,,0,0.4,,0.1,0.9,3.25E-07,0.000025347 +Worms etc.,0,3.905683,2.155615,10.77807,,,0,0.4,,0.1,0.9,0,0 +Benthic urochordate,0,0.3544967,3.58,17.9,,,0,0.4,,0.1,0.9,6.09E-06,0.001505825 +Sponge,0,0.05448509,1,5,,,0,0.4,,0.1,0.9,1.91E-06,0.00064731 +Bivalves,0,61.87307,1.3,6.5,,,0,0.4,,0.1,0.9,2.33E-08,1.11E-07 +Polychaetes,0,21.68738,2.97,14.85,,,0,0.4,,0.1,0.9,0,0 +Scyphozoid Jellies,0,0.3379304,0.88,3,,,0,0.2,,0.4,0.6,0.003364776,0.01527125 +Other zooplankton,0,22.7485,5.253331,15.00952,,,0,0.2,,0.4,0.6,0,0 +Copepods,0,26.85738,6,27.74,,,0,0.2,,0.4,0.6,0,0 +Pelagic microbes,0,45,36.5,104.2857,,,0,0.25,,0.4,0.6,0,0 +Benthic microbes,0,22.06101,36.5,104.2857,,,0,0.25,,0.1,0.9,0,0 +Primary production,1,48.60443,99.40636,,,,0,0,,0.4004332,0.5995669,0,0 +Pelagic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Benthic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Fishery/Subsistence,3,,,,,,,,,0.2278577,0.7721423,, diff --git a/inst/extdata/Ecosense_EBS_diet.csv b/inst/extdata/Ecosense_EBS_diet.csv new file mode 100644 index 00000000..ab7e75b0 --- /dev/null +++ b/inst/extdata/Ecosense_EBS_diet.csv @@ -0,0 +1,55 @@ +DIETS,Toothed whales,Gray whales,Other baleen,Bowhead whales,Other pinnipeds,Walrus/bearded seal,Wintering seals,Procellarids,Alcids piscivorous,Larids,Alcids planktivorous,Other seabirds,Cormorants,Sharks,Walleye pollock,Pacific cod,Pelagic forage fish,Lg.-mouth flatfish,Sm.-mouth flatfish,Skates,Other demersals,Eelpouts,Lg.-mouth sculpins,Other sculpins,Misc. shallow fish,Octopods,Squids,Salmon returning,Salmon outgoing,Other crabs,Snow crab,Shrimps,Sea stars,Brittle stars,Urchins dollars cucumbers,Snails,Misc. crustacean,Benthic amphipods,Anemones,Corals and sea pens,Worms etc.,Benthic urochordate,Sponge,Bivalves,Polychaetes,Scyphozoid Jellies,Other zooplankton,Copepods,Pelagic microbes,Benthic microbes,Primary production +Toothed whales,6.47E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Gray whales,0.000133081,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other baleen,0.002040034,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Bowhead whales,2.92E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other pinnipeds,0.000205117,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walrus/bearded seal,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Wintering seals,,,,,,0.001017812,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Procellarids,,,,,,,,6.33E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids piscivorous,,,,,,,,0.00059265,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Larids,,,,,,,,5.28E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids planktivorous,,,,,,,,0.000120655,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other seabirds,,,,,,,,7.00E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Cormorants,,,,,,,,1.03E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Sharks,0.000239291,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walleye pollock,0.1698044,,0.08070278,,0.2811362,,0.4888999,0.1655044,0.2614391,0.2021952,0.002550183,0.1678919,0.02434087,0.2,0.08240532,0.2243627,,0.5571692,0.03047612,0.4114217,0.004290166,0.00395613,0.1298186,,,,,,,,,,,,,,,,,,,,,,,0.001,,,,, +Pacific cod,0.01947363,,,,0.01366742,,0.0049334,0.007216445,0.1888303,0.008816263,0.000111195,0.007320547,0.001061329,,0.000594541,0.00446721,,0.006268422,3.22E-05,0.006085007,,,0.000913099,0.04028247,,,,,,,,,,,,,,,,,,,,,,,,,,, +Pelagic forage fish,0.2487804,,0.1201802,,0.2320068,,0.1287617,0.3508018,0.3939846,0.6618846,0.05411142,0.3104237,0.931414,,0.005597626,0.03139776,,0.0777799,0.04213176,0.0297038,0.004689368,0.01307451,0.08628711,,,,0.15,,,,,,,,,,,,,,,,,,,0.008,,,,, +Lg.-mouth flatfish,0.001034033,,,,5.86E-06,,,,,,,,,0.2,0.000824726,0.001458564,,0.002081271,6.93E-05,0.02431003,1.60E-06,,0.000360408,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Sm.-mouth flatfish,0.006842509,,,,0.08088505,,0.0394672,,,,,,,,0.000164344,0.02012908,,0.02068678,0.000488947,0.09006111,0.000020214,7.38E-06,0.03985396,0.009723351,0.007394266,,,,,,,,,,,,,,,,,,,,,,,,,, +Skates,0.003475559,,,,,,,,,,,,,,,5.18E-07,,1.45E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other demersals,0.005536608,,,,0.01134714,,,0.000564447,0.000998577,0.000999001,0.001003092,0.000032534,0.00084674,0.2,4.84E-07,0.001655552,,0.001043523,,,0.000351201,,5.16E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Eelpouts,0.141124,,,,0.008174762,,0.05969413,,,,,,,,0.000426192,0.03098069,,0.04269749,0.001878417,0.08047485,3.13E-06,0.01845699,0.03330814,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Lg.-mouth sculpins,,,,,,,,,,,,,,,7.54E-06,0.001176434,,0.0002093,1.93E-05,0.000021452,0.000121231,,0.001836508,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other sculpins,0.05504273,,,,0.01009857,,0.07893439,,,,,,,,0.000323667,0.01049386,,0.01287026,0.001030404,0.02096508,0.000147024,0.01351007,0.02105363,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Misc. shallow fish,0.03660734,,0.01555704,,0.02213815,,0.09866799,,,,,,,0.02,8.52E-05,0.003238108,,0.004294502,0.000809832,0.007287188,5.99E-06,0.000986537,0.01898878,0.04985736,,,,,,,,,,,,,,,,,,,,,,,,,,, +Octopods,0.005624069,,,,0.02070426,0.01017812,0.009866798,,,,,,,0.02,2.62E-05,0.005013016,,0.000651224,7.19E-05,,0.000360057,,0.01435832,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Squids,0.2922446,,0.002097894,,0.2519298,,0.00049334,0.4435776,0.03470331,0.006531665,0.00074037,0.503465,,0.2,0.001616147,0.00071992,,0.07333685,0.00012839,2.53E-05,0.2840489,,6.85E-05,,,,,0.2,,,,,,,,,,,,,,,,,,0.001,,,,, +Salmon returning,0.01169868,,0.005824628,,0.008696572,,,,,,,,,0.05,,0.001279095,,,,0.02247792,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Salmon outgoing,7.14E-08,,3.56E-08,,0.008696572,,,,,,,7.53E-08,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other crabs,,0.002564021,,0.001170194,0.01055097,0.006252694,0.009866799,,,,,,0.000783198,0.0025,0.001008549,0.1117827,,0.01110253,0.01499601,0.05703641,0.001302062,0.008096965,0.06165776,0.05453778,0.000531343,0.15,,,,0.005500491,0.06013035,,0.01,,,,,,,,,,,,,,,,,, +Snow crab,,0.001909877,,0.000871649,0.000698742,0.003925424,,,,,,,0.00121494,,1.81E-05,0.05749471,,0.004300768,0.004455289,0.0300742,,0.09333689,0.03866288,,,0.05,,,,,,,0.005,,,,,,,,,,,,,,,,,, +Shrimps,,0.01358641,,0.006200707,0.02408229,0.02035623,0.0542674,,,,,,0.0086428,0.005,0.03297897,0.1420867,0,0.05616299,0.08154,0.07128841,0.2867417,0.01367033,0.1972778,0.5433436,0.225388,,,,,,,,0.01,,,,,,,,,,,,,,,,,, +Sea stars,,0.001959092,,0.000894111,,,,,,,,,,,2.83E-05,0.00012312,,1.04E-08,3.16E-06,0.00055577,4.92E-06,,5.38E-05,,,,,,,0.000382242,0.000603733,,,,,,,,,,,,,,,,,,,, +Brittle stars,,0.002253839,,0.00102863,,,,,,,,,,,3.63E-05,0.000185201,,6.63E-05,0.05973076,5.11E-05,2.43E-06,0.1822525,0.000102108,0.000181826,,,,,,0.01228855,0.07161608,,0.03,,,,,,,,,,,,,,,,,, +Urchins dollars cucumbers,,0.000840129,,0.000383427,0.01513655,,,,,,,,,,1.25E-07,0.000107477,,5.44E-06,0.02279872,8.06E-08,,,2.12E-05,,,,,,,0.01201729,0.007422531,,,,,,,,,,,,,,,,,,,, +Snails,,0.000502282,,0.000229237,2.21E-05,0.0610687,,,,,,,,0.0025,0.000179459,0.004685467,,0.000333693,0.007431038,0.000301499,0.000000029,,0.001372771,,,0.4,,,,0.01685826,0.04829947,,0.005,,,,,,,,,,,,,,,,,, +Misc. crustacean,,0.006993907,,0.003191952,,,,0.004287296,0.009203487,0.003571809,0.00072099,3.73E-05,0.004449074,,0.007055759,0.002030444,,2.65E-05,0.02593507,0.000023285,4.31E-07,0.005357117,0.000792121,0.01442491,4.38E-05,,,,,0.001538223,0.01720634,,,,,,,,0.125,0.125,0.003506872,0.125,0.125,0.125,,,,,,, +Benthic amphipods,,0.9,,0.004360963,,,,6.32E-05,,0.004879939,0.000985044,5.10E-05,0.006078489,,0.03478977,0.1104455,2.96E-06,0.001273519,0.09940312,0.008388263,0.001051775,0.3280452,0.05959997,0.1947338,0.09178961,,,,,0.005461351,0.04782058,0.3,,0.1,,,,,0.125,0.125,0.003506872,0.125,0.125,0.125,,,,,,, +Anemones,,8.68E-05,,3.96E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,0.001850753,,,,,,,,,,,,,,,,,,,, +Corals and sea pens,,2.11E-05,,9.62E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Worms etc.,,0.002718438,,0.001240668,,0.1832061,0.02614701,1.69E-05,,0.001301065,0.000262628,1.36E-05,,,0.001353052,0.02704704,,0.000266081,0.09399602,5.84E-05,7.86E-07,0.02537635,0.01925321,0.03702217,,,,,,0.2085163,0.03021216,,0.01,,,0.2,,,,,,,,,,,,,,, +Benthic urochordate,,0.000281016,,0.000128253,,,,,,,,,,,1.68E-05,0.000549436,,3.16E-06,0.002288761,1.66E-06,0.000489444,,,,,,,,,0.000570783,,,,,,,,,,,,,,,,,,,,, +Sponge,,4.32E-05,,1.97E-05,,,,,,,,,,,5.47E-05,4.36E-05,,9.00E-10,9.09E-05,7.98E-06,,,,,,,,,,0.00023874,0.002601985,,,,,,,,,,,,,,,,,,,, +Bivalves,,0.04904792,,0.022385,2.21E-05,0.7139949,,0.00032442,,0.02504892,0.005056271,0.000261789,,,0.000490379,0.00165732,,0.000577568,0.08503099,2.78E-05,8.08E-06,0.05257819,0.000393605,,,0.4,,,,0.2533802,0.2524816,0.1,0.91,,,0.2,,,,,,,,,,,,,,, +Polychaetes,,0.01719198,,0.007846256,,,,0.000113714,,0.008779998,0.001772293,9.18E-05,,,0.00366851,0.03710564,3.12E-05,0.000641417,0.3154908,0.002781462,0.000225772,0.2386699,0.10978,0.02550208,1.19E-05,,,,,0.263431,0.2847306,,0.02,,,0.2,,,,,,,,,,,,,,, +Scyphozoid Jellies,,,,,,,,,,,,,,,2.91E-05,3.76E-06,,1.33E-06,0.001530271,1.47E-05,0.0001446,,7.51E-06,,0.06429844,,,,,,,,,,,,,,,,,,,,,,,,,, +Other zooplankton,,,0.5746825,0.55,,,,0.01148704,0.04877095,0.03297732,0.4103911,0.004580894,0.008569111,,0.4335781,0.1106963,0.9033016,0.09674293,0.09784253,0.000493316,0.3819539,0.001346271,0.1561293,0.01137116,0.6102213,,0.65,0.6,0.5,,0.004736442,0.2,,,,,,,,,,,,,,0.74,0.008073313,,,, +Copepods,,,0.200955,0.4,,,,0.01519615,0.06206967,0.04196949,0.5222954,0.00583,0.01259939,,0.3857745,0.001424687,0.09666412,0.000011405,0.00054752,,0.03367182,,2.77E-05,0.01865575,0.000321321,,0.2,0.2,0.5,,,,,,,,,,,,,,,,,0.15,0.25,,,, +Pelagic microbes,,,,,,,,,,,,,,,1.93E-06,8.57E-06,,,0.000224104,,,0.00065419,,0.000363653,,,,,,,,,,,,,,,,,,,,,,0.05,0.15,0.5,,, +Benthic microbes,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.5,0.5,0.15,0.15,0.4901808,0.15,0.15,0.15,0.5,,,,,, +Primary production,,,,,,,,,,,,,,,,1.85E-05,,1.76E-07,5.60E-09,,,,,,,,,,,0.001516897,0.004452738,,,,0.25,0.2,,,,,,,,,,0.05,0.5919268,0.5,0.7,, +Pelagic detritus,,,,,,,,,,0.00104472,,,,,,,,,,,,,,,,,,,,0.000994342,0.005903513,,,,,,,,,,,,,,,,,,0.3,, +Benthic detritus,,,,,,,,,,,,,,0.1,0.006865464,0.0561312,,0.02938087,0.009528337,0.1360623,0.000363454,0.00062444,0.008015924,,,,,,,0.2173052,0.1599311,0.4,,0.9,0.75,0.2,0.5,0.5,0.6,0.6,0.5028055,0.6,0.6,0.6,0.5,,,,,1, +Import,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/inst/extdata/Ecosense_EBS_pedigree.csv b/inst/extdata/Ecosense_EBS_pedigree.csv new file mode 100644 index 00000000..8f783a1e --- /dev/null +++ b/inst/extdata/Ecosense_EBS_pedigree.csv @@ -0,0 +1,54 @@ +Group,B,PB,QB,Diet,F_Fishery/Subsistence +Toothed whales,0.8,0.6,0.6,0.8,0.3 +Gray whales,0.5,0.6,0.6,0.8,0 +Other baleen,0.8,0.6,0.6,0.8,0.3 +Bowhead whales,0.5,0.1,0.6,0.8,0 +Other pinnipeds,0.5,0.6,0.8,0.8,0.3 +Walrus/bearded seal,0.5,0.6,0.6,0.7,0.3 +Wintering seals,0.5,0.6,0.6,0.7,0.3 +Procellarids,0.8,0.6,0.6,0.8,0.5 +Alcids piscivorous,0.5,0.6,0.6,0.8,0.5 +Larids,0.5,0.6,0.6,0.8,0.5 +Alcids planktivorous,0.5,0.6,0.6,0.8,0.5 +Other seabirds,0.8,0.6,0.6,0.8,0.5 +Cormorants,0.5,0.6,0.6,0.8,0.5 +Sharks,0.5,0.7,0.7,0.8,0.7 +Walleye pollock,0.5,0.4,0.4,0.1,0.1 +Pacific cod,0.8,0.4,0.4,0.1,0.7 +Pelagic forage fish,0.8,0.7,0.7,0.8,0.5 +Lg.-mouth flatfish,0.8,0.6,0.8,0.3,0.7 +Sm.-mouth flatfish,0.8,0.6,0.8,0.7,0.3 +Skates,0.5,0.7,0.7,0.7,0.7 +Other demersals,0.8,0.7,0.8,0.8,0.8 +Eelpouts,0.8,0.7,0.7,0.8,0.7 +Lg.-mouth sculpins,0.1,0.7,0.7,0.3,0.8 +Other sculpins,0.8,0.7,0.7,0.3,0 +Misc. shallow fish,0.8,0.7,0.7,0.7,0.7 +Octopods,0.8,0.7,0.7,0.8,0.4 +Squids,0.8,0.7,0.7,0.8,0.4 +Salmon returning,0.8,0.5,0.8,0.7,0.3 +Salmon outgoing,0.8,0.6,0.6,0.8,0 +Other crabs,0.8,0.6,0.8,0.8,0.8 +Snow crab,0.1,0.6,0.8,0.7,0.3 +Shrimps,0.8,0.6,0.8,0.8,0.5 +Sea stars,0.5,0.6,0.7,0.8,0.8 +Brittle stars,0.8,0.6,0.7,0.8,0 +Urchins dollars cucumbers,0.8,0.6,0.7,0.8,0.5 +Snails,0.8,0.6,0.7,0.8,0.5 +Misc. crustacean,0.8,0.6,0.7,0.8,0 +Benthic amphipods,0.8,0.6,0.7,0.8,0 +Anemones,0.5,0.6,0.7,0.8,0.5 +Corals and sea pens,0.5,0.6,0.7,0.8,0.5 +Worms etc.,0.8,0.6,0.7,0.8,0 +Benthic urochordate,0.5,0.6,0.7,0.8,0.5 +Sponge,0.5,0.6,0.7,0.8,0.5 +Bivalves,0.8,0.6,0.7,0.8,0.5 +Polychaetes,0.8,0.6,0.7,0.8,0 +Scyphozoid Jellies,0.5,0.6,0.6,0.8,0.5 +Other zooplankton,0.8,0.7,0.8,0.8,0 +Copepods,0.8,0.7,0.8,0.8,0 +Pelagic microbes,0.8,0.7,0.7,0.8,0 +Benthic microbes,0.8,0.7,0.7,0.1,0 +Primary production,0.8,0.7,0,0.01,0 +Pelagic detritus,0.8,0,0,0,0 +Benthic detritus,0.8,0,0,0,0 diff --git a/inst/extdata/Ecosense_ECS_base.csv b/inst/extdata/Ecosense_ECS_base.csv new file mode 100644 index 00000000..bc8fdad4 --- /dev/null +++ b/inst/extdata/Ecosense_ECS_base.csv @@ -0,0 +1,54 @@ +Group,Type,Biomass,PB,QB,EE,ProdCons,BioAcc,Unassim,DetInput,PelDetFate,BenthDetFate,F_Fishery,D_Fishery +Polar bears,0,0.00052669,0.0603,4.001384,,,0,0.2,,0.3,0.7,1.84E-05,3.00E-10 +Toothed whales,0,0.01158743,0.112092,14.50402,,,0,0.2,,0.3,0.7,6.34E-05,1.00E-10 +Gray whale,0,0.1879512,0.063365,8.87285,,,0,0.2,,0.3,0.7,0,0 +Bowhead whale,0,0.3984775,0.01005,5.260121,,,0,0.2,,0.3,0.7,0.001198808,1.00E-10 +Walrus/bearded seal,0,0.09814298,0.07127273,18.19188,,,0,0.2,,0.3,0.7,0.004842258,2.00E-10 +Wintering seals,0,0.06165962,0.08586258,19.17929,,,0,0.2,,0.3,0.7,0.002269417,2.00E-10 +Procellarids,0,0.001927375,0.06674218,187.9285,,,0,0.2,,0.3,0.7,0,0 +Cormorants,0,1.47E-06,0.1625189,142.6185,,,0,0.2,,0.3,0.7,0,0 +Other seabirds,0,7.77E-05,0.1625189,374.3133,,,0,0.2,,0.3,0.7,0,0 +Larids,0,9.31E-05,0.1057225,205.6736,,,0,0.2,,0.3,0.7,0,0 +Alcids piscivorous,0,0.001155027,0.104122,178.3831,,,0,0.2,,0.3,0.7,0,0 +Alcids planktivorous,0,0.000139496,0.1404024,247.5067,,,0,0.2,,0.3,0.7,0,0 +Lg.-mouth flatfish,0,0.1114285,0.4006235,1.780206,,,0,0.2,,0.3,0.7,0,0 +Sm.-mouth flatfish,0,0.09015632,0.3078811,1.535264,,,0,0.2,,0.3,0.7,0,0 +Lg.-mouth sculpins,0,0.599852,0.4,2,,,0,0.2,,0.3,0.7,0,0 +Other sculpins,0,0.8552857,0.4592638,2.415146,,,0,0.2,,0.3,0.7,0,0 +Eelpouts,0,0.3821929,0.4,2,,,0,0.2,,0.3,0.7,0,0 +Pelagic forage fish,0,1.190608,0.5432349,2.919605,,,0,0.2,,0.3,0.7,0,0 +Misc. shallow fish,0,7.477481,0.41934,2.105119,,,0,0.2,,0.3,0.7,0,0 +Other demersals,0,0.2338559,0.4,2,,,0,0.2,,0.3,0.7,0,0 +Skates,0,0.005364676,0.21,2.1,,,0,0.2,,0.3,0.7,0,0 +Walleye pollock,0,0.0005417,0.8689514,3.008252,,,0,0.2,,0.3,0.7,0,0 +Pacific cod,0,0.000037935,0.5477087,2.802848,,,0,0.2,,0.3,0.7,0,0 +Arctic cod,0,1.044914,0.8689514,3.008252,,,0,0.2,,0.3,0.7,0.000000001,1.00E-10 +Snow crab,0,3.169973,1,2.75,,,0,0.2,,0.1,0.9,0,0 +Bivalves,0,90.28777,0.755625,3.778125,,,0,0.4,,0.1,0.9,0,0 +Snails,0,1.384463,1.77,8.849999,,,0,0.2,,0.1,0.9,0,0 +Other crabs,0,3.067152,0.82,4.1,,,0,0.2,,0.1,0.9,0,0 +Shrimps,0,7.492234,0.576,2.409,,,0,0.2,,0.1,0.9,0,0 +Sea stars,0,2.180155,0.34,1.7,,,0,0.2,,0.1,0.9,0,0 +Brittle stars,0,5.644247,0.485,2.425,,,0,0.4,,0.1,0.9,0,0 +Basket stars,0,0.5098612,0.34,1.7,,,0,0.2,,0.1,0.9,0,0 +"Urchins, dollars, cucumbers",0,36.28965,0.695,3.475,,,0,0.4,,0.1,0.9,0,0 +Sponge,0,0.5271555,1,5,,,0,0.4,,0.1,0.9,0,0 +Anemones,0,0.3841269,1,5,,,0,0.2,,0.1,0.9,0,0 +Benthic urochordate,0,1.160084,3.58,17.9,,,0,0.4,,0.1,0.9,0,0 +Corals and sea pens,0,0.02567942,0.046,0.23,,,0,0.4,,0.1,0.9,0,0 +Scyphozoid jellies,0,0.3719727,0.88,3,,,0,0.2,,0.3,0.7,0,0 +Octopods,0,0.01057694,1.77,8.849999,,,0,0.2,,0.1,0.9,0,0 +Salmon outgoing,0,0.000520686,1.28,13.56,,,0,0.2,,0.3,0.7,0,0 +Salmon returning,0,0.005206862,1.65,11.6,,,0,0.2,,0.3,0.7,0,0 +Benthic amphipods,0,20.52637,1,5,,,0,0.4,,0.1,0.9,0,0 +Polychaetes,0,27.80796,2.915733,14.57867,,,0,0.4,,0.1,0.9,0,0 +Worms etc.,0,17.03959,2.23,11.15,,,0,0.4,,0.1,0.9,0,0 +Misc. crustaceans,0,5.580986,2.008,10.04,,,0,0.4,,0.1,0.9,0,0 +Copepods,0,2.042696,6,27.74,,,0,0.2,,0.3,0.7,0,0 +Other zooplankton,0,1.225213,5.475,15.64286,,,0,0.2,,0.3,0.7,0,0 +Pelagic microbes,0,1.488708,26.25,75,,,0,0.2,,0.3,0.7,0,0 +Benthic microbes,0,22.31168,26.25,75,,,0,0.2,,0.1,0.9,0,0 +Primary production,1,27.8,75,,,,0,0,,0.3,0.7,0,0 +Pelagic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Benthic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Fishery/Subsistence,3,,,,,,,,,0.3,0.7,, diff --git a/inst/extdata/Ecosense_ECS_diet.csv b/inst/extdata/Ecosense_ECS_diet.csv new file mode 100644 index 00000000..85514f75 --- /dev/null +++ b/inst/extdata/Ecosense_ECS_diet.csv @@ -0,0 +1,54 @@ +DIETS,Polar bears,Toothed whales,Gray whale,Bowhead whale,Walrus/bearded seal,Wintering seals,Procellarids,Cormorants,Other seabirds,Larids,Alcids piscivorous,Alcids planktivorous,Lg.-mouth flatfish,Sm.-mouth flatfish,Lg.-mouth sculpins,Other sculpins,Eelpouts,Pelagic forage fish,Misc. shallow fish,Other demersals,Skates,Walleye pollock,Pacific cod,Arctic cod,Snow crab,Bivalves,Snails,Other crabs,Shrimps,Sea stars,Brittle stars,Basket stars,"Urchins, dollars, cucumbers",Sponge,Anemones,Benthic urochordate,Corals and sea pens,Scyphozoid jellies,Octopods,Salmon outgoing,Salmon returning,Benthic amphipods,Polychaetes,Worms etc.,Misc. crustaceans,Copepods,Other zooplankton,Pelagic microbes,Benthic microbes,Primary production +Polar bears,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Toothed whales,0.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Gray whale,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Bowhead whale,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walrus/bearded seal,0.25,,,,0.000212616,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Wintering seals,0.65,,,,0.000504327,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Procellarids,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Cormorants,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other seabirds,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Larids,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids piscivorous,,,,,,,,,,0.004651598,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids planktivorous,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Lg.-mouth flatfish,,,,,0.006081153,0.000781252,,,,,0.009612602,,,,,,,,,0.005322316,0.02487342,,0.001472492,0.006102135,,,,,,,,,,,,,,,,,,,,,,,,,, +Sm.-mouth flatfish,,,,,0.006081153,0.000781252,,,,,0.009612602,,,,,,,,,0.01650201,0.06433967,,0.01072673,,,,,,,,,,,,,,,,,,,,,,,,,,, +Lg.-mouth sculpins,,0.009999999,,,0.01659991,0.0410623,,,,0.001718235,0.07135769,,,,,,0.04798269,0.005778736,,0.04407414,0.02363462,,0.006649494,0.006265168,,,,,,,,,,,,,,,,,,,,,,,,,, +Other sculpins,,0.009999999,,,,0.008492618,,,,0.001718235,0.07133969,,,,0.206761,,0.000789418,0.004220617,,0.05228622,0.000336991,,0.004856593,,,,,,,,,,,,,,,,,,,,,,,,,,, +Eelpouts,,0.009999999,,,,,,,,,,,,,0.08932029,,,,,0.003859158,0.04130904,,0.004297453,0.003560629,,,,,,,,,,,,,,,,,,,,,,,,,, +Pelagic forage fish,,0.5544065,,,0.000657422,0.06911467,0.05867733,0.25,,0.3324589,0.2731979,,,,,0.03727878,,,,0.05182033,0.05281629,,,0.04948226,,,,,,,,,,,,,,,,,,,,,,,,,, +Misc. shallow fish,,0.03590742,,,0.00509502,0.3092427,,0.25,,0.0267805,0.2405652,,0.3332412,,0.2435342,,0.07879899,0.1874234,0.06125135,0.07786866,0.01548537,,0.06349141,0.002147306,,,,,,,,,,,,,,,,,,,,,,,,,, +Other demersals,,,,,,0.001981432,,,,0.007045029,0.006587705,,,,0.01485121,,0.000345366,,,0.09428567,0.005443891,,0.00277255,0.002785945,,,,,,,,,,,,,,,,,,,,,,,,,, +Skates,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walleye pollock,,,,,,,,,,,,,,,,,,,,,,,0.000578866,,,,,,,,,,,,,,,,,,,,,,,,,,, +Pacific cod,,,,,,,,,,,,,,,,,,,,,0.001371445,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Arctic cod,,0.2796861,,,0.002410548,0.4286107,0.06969959,0.25,,0.5012766,0.2594775,,0.2409175,,,,,,,0.005050726,0.2729864,0.5366726,0.1560087,0.008183806,,,,,,,,,,,,,,,,,,,,,,,,,, +Snow crab,,,0.000256674,0.000113781,0.07158563,,,,,,,,,0.0265204,0.07528889,0.00226101,,,,0.01153278,0.2568457,,0.1453266,,,,,,,,,,,,,,,,0.25,,,,,,,,,,, +Bivalves,,,0.0433623,0.01922197,0.5941439,,,,,1.53E-06,2.65E-06,,0.00729814,0.3710207,,0.001438914,0.000389389,,0.04453,0.001736895,1.76E-05,,0.001407035,4.30E-05,0.2075,,0.5,0.25,0.15,0.5154778,0.125,,,,0.2,,,,0.25,,,,,,,,,,, +Snails,,,0.004340004,0.00192387,0.04782695,,,,,0.005283926,0.003017653,,,0.000498679,,0.006792177,,,0.000733818,,5.89E-05,,0.001507538,,0.0326,,,,,0.05159265,,,,,,,,,0.25,,,,,,,,,,, +Other crabs,,,7.88E-05,3.49E-05,0.02207871,,,,,0.005283772,0.003044799,,,0.000157228,0.1497352,0.05728141,0.002116573,0.000288189,0.005869959,0.02178959,0.06081963,,0.0525628,0.001098868,0.0411,,,,,,,,,,,,,,0.25,,,,,,,,,,, +Shrimps,,0.09993257,1.25E-05,5.55E-06,0.08408973,0.09176343,,0.25,,0.01060208,0.009951027,,0.1977302,,0.1319228,0.01229081,0.01550181,0.009836816,0.1471351,0.181513,0.1139477,0.1423735,0.2859297,0.1600893,,,,,,,,,,,,,,,,,,,,,,,,,, +Sea stars,,,0.004000351,0.001773306,,,,,,,,,,,,,,,,,,,,,0.0015,,,,,,,,,,,,,,,,,,,,,,,,, +Brittle stars,,,0.003698438,0.001639472,,,,,,,,,,0.03040408,1.92E-05,0.005426886,,,,,6.06E-06,,,,0.05895,,,,,,,,,,,,,,,,,,,,,,,,, +Basket stars,,,0.00014616,6.48E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"Urchins, dollars, cucumbers",,,0.02290767,0.01015469,0.05747112,,,,,,,,,0.05108213,,,,,,,0.000107293,,,,0.0081,,,,,0.2723194,,,,,,,,,,,,,,,,,,,, +Sponge,,,0.000249278,0.000110502,,,,,,,,,,,,,,,,,,,,,0.00275,,,,,,,,,,,,,,,,,,,,,,,,, +Anemones,,,0.002641741,0.001171051,,,,,,,,,,,,0.06376915,,,,,1.18E-05,,,,0.00115,,,,,,,,,,,,,,,,,,,,,,,,, +Benthic urochordate,,,0.002641741,0.001171051,0.006627641,,,,,,,,,,,,,,,,0.00021469,,,,,,,,,0.03140422,,,,,,,,,,,,,,,,,,,, +Corals and sea pens,,,2.54E-06,1.13E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Scyphozoid jellies,,,,,,,,,,,,0.0192604,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Octopods,,0.000067419,,,0.007169423,0.001830349,,,,,,,,,,,,,,,6.64E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Salmon outgoing,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Salmon returning,,,,,,,,,,,,,,,,,,,,,0.02096798,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Benthic amphipods,,,0.9,0.005671234,0.03530366,0.03725448,0.002204452,,0.1,0.03446057,0.02325702,,0.0252337,0.1203165,0.0703186,0.4825385,0.2814546,0.01338544,0.4361333,0.3160916,0.03019983,0.0429575,0.137789,0.09571919,0.05525,,0.05,,0.15,,0.125,0.25,,,0.2,,,,,,,,,,,,,,, +Polychaetes,,,0.01086888,0.00481804,0.03047494,,,,,0.02371788,0.008201232,,0.04969615,0.3519998,0.01052774,0.2352545,0.5376897,0.004593154,0.1107291,0.1004426,0.007359331,,0.06924623,0.004512317,0.27195,,0.3,0.25,0.15,0.1292059,0.125,,,,,,,,,,,,,,,,,,, +Worms etc.,,,0.002226611,0.000987029,0.005586154,,,,,,,,,0.008323649,,0.06003539,,,0.02272738,0.000147471,,,,,0.03125,,0.05,0.25,,,,,,,,,,,,,,,,,,,,,, +Misc. crustaceans,,,0.002566263,0.001137593,,,,,,0.00012475,,,,0.03681871,0.006913655,0.007458307,0.00088703,0.000632304,0.06850621,0.003324673,0.000133681,0.03436605,0.001507538,0.01197542,0.01425,,0.05,,0.15,,0.125,0.25,,,0.2,,,,,,,,,,,,,,, +Copepods,,,,0.7125,,,0.004408904,,0.45,,,0.3485923,9.47E-06,9.85E-05,,,5.11E-07,0.3125479,0.01474068,0.000178091,0.000000209,0.1472829,,0.3724843,,,,,,,,0.25,,,,,,0.675,,0.5,0.5,,,,,,0.25,,, +Other zooplankton,,,,0.2375,,0.009084825,0.8650097,,0.45,0.02627006,0.01077462,0.6321473,0.1458736,0.002759635,0.000807251,0.02817404,0.03404389,0.4612935,0.08764321,0.01217405,0.006646099,0.0963475,0.05386934,0.2755505,0.0041,,,,,,,0.25,,,,,,0.225,,0.5,0.5,,,,,,,,, +Pelagic microbes,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.05,,,,,,,,0.5,0.15,,, +Benthic microbes,,,,,,,,,,,,,,,,,,,,,,,,,,0.25,,,,,,,,0.25,0.2,0.25,0.25,,,,,0.5,0.5,0.5,0.5,,,,, +Primary production,,,,,,,,,,,,,,,,,,,,,,,,,0.0039,,,,,,,,0.25,,,,,0.05,,,,,,,,0.5,0.6,0.7,, +Pelagic detritus,,,,,,,,,,0.005581916,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.3,, +Benthic detritus,,,,,,,,,,0.01302447,,,,,,,,,,,,,,,0.26565,0.75,0.05,0.25,0.4,,0.5,,0.75,0.75,0.2,0.75,0.75,,,,,0.5,0.5,0.5,0.5,,,,1, +Import,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/inst/extdata/Ecosense_ECS_pedigree.csv b/inst/extdata/Ecosense_ECS_pedigree.csv new file mode 100644 index 00000000..2d1148c5 --- /dev/null +++ b/inst/extdata/Ecosense_ECS_pedigree.csv @@ -0,0 +1,53 @@ +Group,B,PB,QB,Diet,F_Fishery/Subsistence +Polar bears,0.8,0.5,0.6,0.8,0.8 +Toothed whales,0.5,0.6,0.6,0.7,0.5 +Gray whale,0.5,0.6,0.6,0.7,0 +Bowhead whale,0.5,0.6,0.6,0.7,0.1 +Walrus/bearded seal,0.8,0.6,0.6,0.7,0.5 +Wintering seals,0.8,0.6,0.6,0.6,0.5 +Procellarids,0.5,0.6,0.6,0.8,0 +Cormorants,0.5,0.6,0.6,0.8,0 +Other seabirds,0.5,0.6,0.6,0.8,0 +Larids,0.5,0.6,0.6,0.8,0 +Alcids piscivorous,0.5,0.6,0.6,0.8,0 +Alcids planktivorous,0.5,0.6,0.6,0.8,0 +Lg.-mouth flatfish,0.8,0.5,0.5,0.3,0 +Sm.-mouth flatfish,0.8,0.6,0.6,0.3,0 +Lg.-mouth sculpins,0.8,0.6,0.6,0.3,0 +Other sculpins,0.8,0.6,0.6,0.3,0 +Eelpouts,0.8,0.6,0.6,0.3,0 +Pelagic forage fish,0.8,0.6,0.6,0.3,0 +Misc. shallow fish,0.8,0.6,0.6,0.3,0 +Other demersals,0.8,0.6,0.6,0.3,0 +Skates,0.1,0.6,0.7,0.8,0 +Walleye pollock,0.1,0.6,0.6,0.3,0 +Pacific cod,0.1,0.6,0.6,0.8,0 +Arctic cod,0.8,0.2,0.2,0.3,0 +Snow crab,0.1,0.6,0.6,0.8,0 +Bivalves,0.1,0.5,0.7,0.8,0 +Snails,0.1,0.6,0.7,0.8,0 +Other crabs,0.1,0.6,0.7,0.8,0 +Shrimps,0.8,0.6,0.7,0.8,0 +Sea stars,0.1,0.6,0.7,0.8,0 +Brittle stars,0.1,0.6,0.7,0.8,0 +Basket stars,0.1,0.6,0.7,0.8,0 +"Urchins, dollars, cucumbers",0.1,0.5,0.7,0.8,0 +Sponge,0.1,0.6,0.7,0.8,0 +Anemones,0.1,0.6,0.7,0.8,0 +Benthic urochordate,0.1,0.6,0.7,0.8,0 +Corals and sea pens,0.1,0.6,0.7,0.8,0 +Scyphozoid jellies,0.1,0.6,0.6,0.8,0 +Octopods,0.8,0.6,0.7,0.8,0 +Salmon outgoing,0.8,0.6,0.6,0.8,0 +Salmon returning,0.8,0.6,0.6,0.8,0 +Benthic amphipods,0.8,0.6,0.7,0.8,0 +Polychaetes,0.1,0.5,0.7,0.8,0 +Worms etc.,0.1,0.6,0.7,0.8,0 +Misc. crustaceans,0.1,0.6,0.7,0.8,0 +Copepods,0.8,0.6,0.6,0.8,0 +Other zooplankton,0.8,0.6,0.7,0.8,0 +Pelagic microbes,0.8,0.7,0.7,0.8,0 +Benthic microbes,0.8,0.7,0.7,0.8,0 +Primary production,0.8,0.7,0,0.01,0 +Pelagic detritus,0,0,0,0,0 +Benthic detritus,0,0,0,0,0 diff --git a/inst/extdata/Ecosense_GOA_base.csv b/inst/extdata/Ecosense_GOA_base.csv new file mode 100644 index 00000000..4a340d95 --- /dev/null +++ b/inst/extdata/Ecosense_GOA_base.csv @@ -0,0 +1,51 @@ +Group,Type,Biomass,PB,QB,EE,ProdCons,BioAcc,Unassim,DetInput,PelDetFate,BenthDetFate,F_Fishery,D_Fishery +Toothed whales,0,0.06165833,0.04713691,12.43829,,,0,0.2,,0.5,0.5,1.29E-07,8.45E-07 +Gray whale,0,0.05543134,0.063365,8.87285,,,0,0.2,,0.5,0.5,8.57E-08,0 +Other baleen,0,0.4567338,0.03134125,6.980565,,,0,0.2,,0.5,0.5,0,5.19E-05 +Other pinnipeds,0,0.03346486,0.1222834,36.81018,,,0,0.2,,0.5,0.5,0.000090749,4.04E-06 +Procellarids,0,0.001051795,0.06487884,73,,,0,0.2,,0.5,0.5,0,1.43E-06 +Alcids piscivorous,0,0.01131623,0.09528826,72.57302,,,0,0.2,,0.5,0.5,0,1.54E-05 +Larids,0,0.001458566,0.1115763,95.5601,,,0,0.2,,0.5,0.5,0,1.98E-06 +Alcids planktivorous,0,0.000299744,0.1694877,110,,,0,0.2,,0.5,0.5,0,4.07E-07 +Other seabirds,0,0.000461801,0.09378317,109.5,,,0,0.2,,0.5,0.5,0,6.27E-07 +Cormorants,0,0.000348881,0.1587271,73,,,0,0.2,,0.5,0.5,0,4.74E-07 +Sharks,0,0.142353,0.1,3.729058,,,0,0.2,,0.5,0.5,0.000176845,0.00594262 +Walleye pollock,0,6.224493,0.6538435,4.109179,,,-1.35,0.2,,0.5,0.5,0.0618452,0.281034 +Pacific cod,0,1.520393,0.5576789,2.39571,,,0,0.2,,0.5,0.5,0.1218526,0.1289747 +Pelagic forage fish,0,14.26999,0.8180392,3.676071,,,-0.11,0.2,,0.5,0.5,0.05087369,0.005135313 +Lg.-mouth flatfish,0,8.015218,0.2929934,1.443946,,,0,0.2,,0.5,0.5,0.08691967,0.07947716 +Sm.-mouth flatfish,0,2.44411,0.2152337,1.93294,,,0,0.2,,0.5,0.5,0.04497369,0.02795422 +Skates,0,0.191803,0.2,2,,,0,0.2,,0.5,0.5,0.003005425,0.01178723 +Other demersals,0,4.505964,0.1830862,2.246801,,,-0.002,0.2,,0.5,0.5,0.09719946,0.09624746 +Eelpouts,0,1.069425,0.4,2,,,0,0.2,,0.5,0.5,7.66E-06,1.66E-05 +Lg.-mouth sculpins,0,0.08888517,0.4,2,,,0,0.2,,0.5,0.5,0.000193433,0.004255149 +Other sculpins,0,0.8168654,0.4,2,,,0,0.2,,0.5,0.5,0,0 +Misc. shallow fish,0,0.8389893,0.4,2,,,0,0.2,,0.5,0.5,0.000319678,0.000919832 +Octopods,0,0.7834731,0.8,3.65,,,0,0.2,,0.5,0.5,0.000165189,0.000167874 +Squid,0,1.265454,3.2,10.67,,,0,0.2,,0.5,0.5,0.000119335,0.000225772 +Salmon returning,0,0.8566338,1.815861,11.8269,,,0,0.2,,0.5,0.5,0.29042,0.02977088 +Salmon outgoing,0,0.01713268,1.641523,14.38647,,,0,0.2,,0.5,0.5,0,0 +Other crabs,0,5.218338,0.8414152,3.966247,,,0,0.2,,0.1,0.9,0.003609303,0.000240075 +Shrimps,0,22.22855,0.576,2.41,,,0,0.2,,0.1,0.9,0.00019897,4.79E-06 +Sea stars,0,0.09551849,1.21,6.05,,,0,0.2,,0.1,0.9,0.000009245,0.003106511 +Brittle stars,0,4.544021,1.21,6.05,,,0,0.2,,0.1,0.9,0,0 +"Urchins, dollars, cucumbers",0,1.630926,0.61,3.05,,,0,0.2,,0.1,0.9,3.51E-06,7.42E-05 +Snails,0,0.8638767,1.81,9.049999,,,0,0.2,,0.1,0.9,3.27E-07,0 +Misc. crustaceans,0,2.120289,7.4,37,,,0,0.2,,0.1,0.9,0,0 +Benthic amphipods,0,5.868869,7.4,37,,,0,0.2,,0.1,0.9,0,0 +Anemones,0,0.08886787,1,5,,,0,0.4,,0.1,0.9,4.09E-07,7.39E-05 +Corals and sea pens,0,0.005739689,0.05045965,0.2522982,,,0,0.4,,0.1,0.9,2.98E-06,2.43E-05 +Worms etc.,0,3.772863,2.195745,10.97872,,,0,0.4,,0.1,0.9,0,0 +Benthic urochordate,0,0.2448,3.58,17.9,,,0,0.4,,0.1,0.9,0,0.000006744 +Sponge,0,0.1075014,1,5,,,0,0.4,,0.1,0.9,2.65E-07,0.000020834 +Bivalves,0,13.85198,1.3,6.5,,,0,0.4,,0.1,0.9,0.000280681,0 +Polychaetes,0,3.923291,2.97,14.85,,,0,0.4,,0.1,0.9,0,0 +Scyphozoid jellies,0,0.11,0.88,3,,,0,0.2,,0.7,0.3,0.000141226,0.000195899 +Other zooplankton,0,23.99852,5.30758,15.16452,,,0,0.2,,0.7,0.3,0,0 +Copepods,0,21.8635,6,27.74,,,0,0.2,,0.7,0.3,0,0 +Pelagic microbes,0,12.25505,36.5,104.2857,,,0,0.2,,0.7,0.3,0,0 +Benthic microbes,0,7.252296,36.5,104.2857,,,0,0.2,,0.1,0.9,0,0 +Primary production,1,40.39581,110.2083,,,,0,0,,0.5001647,0.4998353,0,0 +Pelagic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Benthic detritus,2,,0.5,,,,0,0,0,0,0,0,0 +Fishery/Subsistence,3,,,,,,,,,0.3908825,0.6091174,, diff --git a/inst/extdata/Ecosense_GOA_diet.csv b/inst/extdata/Ecosense_GOA_diet.csv new file mode 100644 index 00000000..90f58390 --- /dev/null +++ b/inst/extdata/Ecosense_GOA_diet.csv @@ -0,0 +1,51 @@ +DIETS,Toothed whales,Gray whale,Other baleen,Other pinnipeds,Procellarids,Alcids piscivorous,Larids,Alcids planktivorous,Other seabirds,Cormorants,Sharks,Walleye pollock,Pacific cod,Pelagic forage fish,Lg.-mouth flatfish,Sm.-mouth flatfish,Skates,Other demersals,Eelpouts,Lg.-mouth sculpins,Other sculpins,Misc. shallow fish,Octopods,Squid,Salmon returning,Salmon outgoing,Other crabs,Shrimps,Sea stars,Brittle stars,"Urchins, dollars, cucumbers",Snails,Misc. crustaceans,Benthic amphipods,Anemones,Corals and sea pens,Worms etc.,Benthic urochordate,Sponge,Bivalves,Polychaetes,Scyphozoid jellies,Other zooplankton,Copepods,Pelagic microbes,Benthic microbes,Primary production +Toothed whales,0.000053212,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Gray whale,0.000195671,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other baleen,0.00161226,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other pinnipeds,0.00011813,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Procellarids,,,,0.00001722,8.24E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids piscivorous,,,,0.000185269,0.000886036,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Larids,,,,2.39E-05,0.000114203,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Alcids planktivorous,,,,4.91E-06,2.35E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other seabirds,,,,7.56E-06,0.000036158,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Cormorants,,,,5.71E-06,2.73E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Sharks,0.000161708,,,,,,,,,,0.007149246,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Walleye pollock,0.003959108,,0.01536035,0.2443831,0.1994964,0.1707221,0.1374473,0.002219961,0.019285,0.000520214,0.0642318,0.01730322,0.165236,,0.2428017,0.001732163,0.05733645,0.02243403,0.003956129,0.1298187,,,,,,,,,,,,,,,,,,,,,,0.001,,,,, +Pacific cod,0.01370258,,,0.01315614,0.03869898,0.0953234,0.02666247,0.000430635,0.003740967,0.000100913,0.01441741,4.16E-05,4.53E-05,,0.00643942,0.000612311,0.01391214,0.000445677,,0.000913099,0.04028247,,,,,,,,,,,,,,,,,,,,,,,,,, +Pelagic forage fish,0.1161123,,0.2332085,0.3194725,0.2109555,0.5695944,0.7290136,0.0579436,0.1867094,0.9490509,0.09923565,0.05399713,0.05462447,,0.3145934,0.002486164,0.1599201,0.01277022,0.01307451,0.08628713,,,,0.15,,,,,,,,,,,,,,,,,,0.008000001,,,,, +Lg.-mouth flatfish,0.005098103,,,0.06527214,,,,,,,0.1543446,0.000791903,0.01130468,,0.01020996,1.63E-05,0.1309565,0.000628949,,0.000360408,,,,,,,,,,,,,,,,,,,,,,,,,,, +Sm.-mouth flatfish,0.001552685,,,0.01064673,,,,,,,0.01475467,0.001102062,0.006265766,,0.003265063,,0.09747098,6.51E-05,7.38E-06,0.03985396,0.009723351,0.000782896,,,,,,,,,,,,,,,,,,,,,,,,, +Skates,0.001757251,,,0.002557138,,,,,,,0.006894708,,,,,,8.46E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other demersals,0.0355815,,0.000854911,0.0275689,0.000779691,0.000999022,0.000999001,0.000999028,0.000656877,0.000999001,0.1612058,4.97E-06,0.000487305,,0.01635126,,0.007544784,0.00062241,,5.16E-06,,,,,,,,,,,,,,,,,,,,,,,,,,, +Eelpouts,0.03762805,,,0.001576726,,,,,,,,0.000384112,0.00827353,,0.01708649,0.001052443,0.06045089,1.19E-05,0.01845699,0.03330814,,,,,,,,,,,,,,,,,,,,,,,,,,, +Lg.-mouth sculpins,,,,0.004269105,,,,,,,0.001023347,,,,0.0004592,,0.001537074,0.00074721,,0.001836508,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other sculpins,0.0239836,,,0.001656653,,,,,,,0.008203304,0.000368221,0.03324791,,0.003973727,0.002730238,0.008991601,0.001097425,0.01351007,0.02105363,,,,,,,,,,,,,,,,,,,,,,,,,,, +Misc. shallow fish,0.0183782,,0.01225261,0.01958377,,,,,,,0.01196223,0.000873976,0.00369463,,0.004439839,0.00072485,0.009763914,0.000227009,0.000986536,0.01898878,0.04985735,,,,,,,,,,,,,,,,,,,,,,,,,, +Octopods,,,,0.003456976,,,,,,,0.01923347,0.000801896,0.01928917,,0.004122138,5.58E-05,0.005395931,0.03390534,,0.01435831,,,,,,,,,,,,,,,,,,,,,,,,,,, +Squid,0.7395499,,0.003086945,0.0333473,0.5152936,0.03660618,0.005065987,0.000737371,0.5699574,,0.03743711,0.005250731,0.004351677,,0.002514759,,0.007717871,0.02896504,,6.85E-05,,,,,0.2,,,,,,,,,,,,,,,,,0.001,,,,, +Salmon returning,0.000544865,,0.01958669,0.09488117,,,,,,,0.1593205,,,,0.01610603,,0.007721416,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Salmon outgoing,1.09E-05,,0.000391734,0.001760886,,,,,0.000253304,,,,,,,,0.000154428,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Other crabs,,0.00868696,,0.07330567,,,,,,0.001637441,0.03539184,0.02547316,0.2096924,,0.05080061,0.05152845,0.004317433,0.02019694,0.1014338,0.1003206,0.05453777,,0.2,,,,0.001857261,,0.015,,,,,,,,,,,,,,,,,, +Shrimps,,0.03814375,,7.59E-05,,,,,,0.01679093,0.04296356,0.1641614,0.1930464,,0.1034172,0.1775361,0.2619857,0.2075776,0.01367033,0.1972779,0.5433435,0.06150237,,,,,,,0.01,,,,,,,,,,,,,,,,,, +Sea stars,,0.000168028,,,,,,,,,3.78E-05,0.001743829,0.001815502,,5.86E-07,0.000471179,,2.18E-06,,5.38E-05,,,,,,,0.000007134,,,,,,,,,,,,,,,,,,,, +Brittle stars,,0.007993475,,,,,,,,,0.001799504,,0.000263089,,2.68E-05,0.1307027,0.000445373,1.20E-07,0.1822525,0.000102108,0.000181826,,,,,,0.003674393,,0.03,,,,,,,,,,,,,,,,,, +"Urchins, dollars, cucumbers",,0.002868994,,0.08012424,,,,,,,0.00152771,3.39E-05,1.33E-05,,0.000167073,0.04294402,,2.75E-06,,2.12E-05,,,,,,,0.002019559,,,,,,,,,,,,,,,,,,,, +Snails,,0.001471001,,,,,,,,,0.001029396,4.63E-05,0.003873213,,0.00034488,0.002924132,,0.00091642,,0.001372771,,,0.4,,,,0.002910736,,0.005,,,,,,,,,,,,,,,,,, +Misc. crustaceans,,0.00358871,,,0.002251724,0.03868497,0.002705831,0.000634075,0.000665534,0.001579755,0.000458313,0.000930434,0.003999098,,0.000181152,0.08995359,0.002523744,0.001508952,0.005357116,0.000792121,0.01442491,,,,,,0.000473233,,,,,,,,0.125,0.125,0.001585444,0.125,0.125,0.125,,,,,,, +Benthic amphipods,,0.9,,,0.000155224,,0.00744352,0.001744287,0.001830829,0.004345777,0.002902649,0.05938753,0.09548885,0.00000074,0.004069764,0.03767442,0.1267503,0.02685756,0.3280453,0.05959999,0.1947338,0.00359031,,,,,0.001832292,0.3,,0.1,,,,,0.125,0.125,0.001585444,0.125,0.125,0.125,,,,,,, +Anemones,,0.000156329,,,,,,,,,3.52E-05,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Corals and sea pens,,1.01E-05,,,,,,,,,,,,,,,,2.65E-07,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Worms etc.,,0.006274812,,,9.61E-05,,0.004606393,0.001079445,0.001133001,,0.006249924,6.17E-05,0.003281819,,0.000493864,0.03986195,0.0164955,0.000021125,0.02537635,0.01925321,0.03702217,,,,,,0.2279804,,0.01,,,0.2,,,,,,,,,,,,,,, +Benthic urochordate,,0.000430632,,,,,,,,,,,0.000000921,,1.83E-07,0.000503441,,0.000544108,,,,,,,,,4.46E-06,,,,,,,,,,,,,,,,,,,, +Sponge,,0.000189108,,,,,,,,,,,2.79E-05,,8.28E-07,1.27E-07,,6.28E-06,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +Bivalves,,0.02344889,,,0.000368692,,0.01768009,0.00414309,0.004348645,,0.005278854,0.000192252,0.002028014,,0.000433315,0.08457874,0.002404211,5.30E-05,0.05257818,0.000393605,,,0.4,,,,0.2544916,0.1,0.91,,,0.2,,,,,,,,,,,,,,, +Polychaetes,,0.006569219,,0.002660374,0.000103289,,0.004953088,0.001160688,0.001218275,,0.001478873,0.004868158,0.05555004,7.80E-06,0.001962562,0.2496711,0.001560155,0.001169203,0.2386699,0.10978,0.02550207,,,,,,0.2717699,,0.02,,,0.2,,,,,,,,,,,,,,, +Scyphozoid jellies,,,,,,,,,,,0.005856221,1.72E-06,,,,3.28E-08,,0.004273257,,7.51E-06,,0.000036637,,,,,,,,,,,,,,,,,,,,,,,,, +Other zooplankton,,,0.5818204,,0.01520136,0.04391786,0.02999332,0.4632186,0.1048208,0.01196193,0.08262146,0.5702611,0.07453965,0.9000154,0.1908987,0.07980518,0.005273665,0.5375271,0.001346272,0.1561293,0.01137116,0.9312431,,0.65,0.6,0.5,,0.2,,,,,,,,,,,,,,0.7400001,0.006289897,,,, +Copepods,,,0.1334379,,0.01542998,0.04415208,0.03015328,0.4656892,0.1053799,0.0130131,0.04071566,0.09128769,0.000105551,0.09997606,5.90E-05,0.002411173,,0.0915686,,2.77E-05,0.01865575,0.002844756,,0.2,0.2,0.5,,,,,,,,,,,,,,,,0.15,0.25,,,, +Pelagic microbes,,,,,,,,,,,,,,,,8.87E-07,,,0.00065419,,0.000363653,,,,,,,,,,,,,,,,,,,,,0.03,0.15,0.5,,, +Benthic microbes,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.5,0.5,0.15,0.15,0.4955608,0.15,0.15,0.15,0.5,,,,,, +Primary production,,,,,,,,,,,,,1.78E-07,,5.42E-07,,,4.38E-07,,,,,,,,,,,,,0.25,0.2,,,,,,,,,,0.07000001,0.5937101,0.5,0.7,, +Pelagic detritus,,,,,,,0.003276177,,,,,,,,,,,,,,,,,,,,0.000732203,,,,,,,,,,,,,,,,,,0.3,, +Benthic detritus,,,,,,,,,,,0.01223919,0.000631227,0.04945371,,0.00477988,2.26E-05,0.009285232,0.00585382,0.00062444,0.008015925,,,,,,,0.2322469,0.4,,0.9,0.75,0.2,0.5,0.5,0.6,0.6,0.5012683,0.6,0.6,0.6,0.5,,,,,1, +Import,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 diff --git a/inst/extdata/Ecosense_GOA_pedigree.csv b/inst/extdata/Ecosense_GOA_pedigree.csv new file mode 100644 index 00000000..8d072f57 --- /dev/null +++ b/inst/extdata/Ecosense_GOA_pedigree.csv @@ -0,0 +1,50 @@ +Group,B,PB,QB,Diet,F_Fishery/Subsistence +Toothed whales,0.8,0.6,0.6,0.8,0.3 +Gray whale,0.5,0.6,0.6,0.8,0.3 +Other baleen,0.8,0.6,0.6,0.8,0.1 +Other pinnipeds,0.5,0.6,0.8,0.8,0.3 +Procellarids,0.8,0.6,0.6,0.8,0.5 +Alcids piscivorous,0.5,0.6,0.6,0.8,0.5 +Larids,0.5,0.6,0.6,0.8,0.5 +Alcids planktivorous,0.5,0.6,0.6,0.8,0.5 +Other seabirds,0.8,0.6,0.6,0.8,0.5 +Cormorants,0.5,0.6,0.6,0.8,0.5 +Sharks,0.8,0.7,0.7,0.8,0.7 +Walleye pollock,0.8,0.4,0.4,0.1,0.3 +Pacific cod,0.8,0.4,0.4,0.1,0.7 +Pelagic forage fish,0.8,0.7,0.7,0.8,0.5 +Lg.-mouth flatfish,0.5,0.4,0.4,0.1,0.7 +Sm.-mouth flatfish,0.8,0.6,0.6,0.7,0.3 +Skates,0.5,0.7,0.7,0.8,0.7 +Other demersals,0.8,0.7,0.8,0.8,0.8 +Eelpouts,0.8,0.7,0.7,0.8,0.7 +Lg.-mouth sculpins,0.1,0.7,0.7,0.8,0.8 +Other sculpins,0.8,0.7,0.7,0.8,0 +Misc. shallow fish,0.8,0.7,0.7,0.7,0.7 +Octopods,0.8,0.7,0.7,0.8,0.4 +Squid,0.8,0.7,0.7,0.8,0.4 +Salmon returning,0.8,0.5,0.8,0.7,0.3 +Salmon outgoing,0.8,0.6,0.6,0.8,0 +Other crabs,0.8,0.6,0.8,0.8,0.5 +Shrimps,0.8,0.6,0.8,0.8,0.5 +Sea stars,0.5,0.6,0.7,0.8,0.8 +Brittle stars,0.5,0.6,0.7,0.8,0 +"Urchins, dollars, cucumbers",0.5,0.6,0.7,0.8,0.5 +Snails,0.8,0.6,0.7,0.8,0.3 +Misc. crustaceans,0.8,0.6,0.7,0.8,0 +Benthic amphipods,0.8,0.6,0.7,0.8,0 +Anemones,0.5,0.6,0.7,0.8,0.5 +Corals and sea pens,0.1,0.6,0.7,0.8,0.5 +Worms etc.,0.8,0.6,0.7,0.8,0 +Benthic urochordate,0.8,0.6,0.7,0.8,0.5 +Sponge,0.5,0.6,0.7,0.8,0.5 +Bivalves,0.8,0.6,0.7,0.8,0.3 +Polychaetes,0.8,0.6,0.7,0.8,0 +Scyphozoid jellies,0.5,0.6,0.6,0.8,0.5 +Other zooplankton,0.8,0.7,0.7,0.8,0 +Copepods,0.8,0.7,0.6,0.8,0 +Pelagic microbes,0.8,0.7,0.7,0.8,0 +Benthic microbes,0.8,0.7,0.7,0.1,0 +Primary production,0.8,0.7,0,0.01,0 +Pelagic detritus,0.8,0,0,0,0 +Benthic detritus,0.8,0,0,0,0 diff --git a/man/Ecosense.EBS.Rd b/man/Ecosense.EBS.Rd new file mode 100644 index 00000000..fd30653c --- /dev/null +++ b/man/Ecosense.EBS.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{Ecosense.EBS} +\alias{Ecosense.EBS} +\title{Eastern Bering Sea 1990s Ecopath model (53 biological groups and 1 fleet).} +\format{ +An Rpath unbalanced model object that contains: +\describe{ + \item{model}{A data.table containing Ecopath unbalanced ecosystem parameters (base parameters and fisheries).} + \item{diet}{A data.table containing the Ecopath model's diet matrix.} + \item{stanzas}{Parameters for multistanza groups.} + \item{pedigree}{A data.table containing the data quality (pedigree) for the Ecopath model.} + ... +} +} +\source{ +Whitehouse and Aydin 2020. Assessing the sensitivity of three Alaska marine food webs to perturbations: an example of Ecosim simulations using Rpath. https://doi.org/10.1016/j.ecolmodel.2020.109074 +} +\usage{ +Ecosense.EBS +} +\description{ +Rpath inputs (unbalanaced model). +} +\keyword{datasets} diff --git a/man/Ecosense.ECS.Rd b/man/Ecosense.ECS.Rd new file mode 100644 index 00000000..eb027d64 --- /dev/null +++ b/man/Ecosense.ECS.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{Ecosense.ECS} +\alias{Ecosense.ECS} +\title{Eastern Chukchi Sea Ecopath model (52 biological groups and 1 fleet).} +\format{ +An Rpath unbalanced model object that contains: +\describe{ + \item{model}{A data.table containing Ecopath unbalanced ecosystem parameters (base parameters and fisheries).} + \item{diet}{A data.table containing the Ecopath model's diet matrix.} + \item{stanzas}{Parameters for multistanza groups.} + \item{pedigree}{A data.table containing the data quality (pedigree) for the Ecopath model.} + ... +} +} +\source{ +Whitehouse and Aydin 2020. Assessing the sensitivity of three Alaska marine food webs to perturbations: an example of Ecosim simulations using Rpath. https://doi.org/10.1016/j.ecolmodel.2020.109074 +} +\usage{ +Ecosense.ECS +} +\description{ +Rpath inputs (unbalanaced model). +} +\keyword{datasets} diff --git a/man/Ecosense.GOA.Rd b/man/Ecosense.GOA.Rd new file mode 100644 index 00000000..07b15ad4 --- /dev/null +++ b/man/Ecosense.GOA.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{Ecosense.GOA} +\alias{Ecosense.GOA} +\title{Gulf of Alaska (west/central) 1990s Ecopath model (49 biological groups and 1 fleet).} +\format{ +An Rpath unbalanced model object that contains: +\describe{ + \item{model}{A data.table containing Ecopath unbalanced ecosystem parameters (base parameters and fisheries).} + \item{diet}{A data.table containing the Ecopath model's diet matrix.} + \item{stanzas}{Parameters for multistanza groups.} + \item{pedigree}{A data.table containing the data quality (pedigree) for the Ecopath model.} + ... +} +} +\source{ +Whitehouse and Aydin 2020. Assessing the sensitivity of three Alaska marine food webs to perturbations: an example of Ecosim simulations using Rpath. https://doi.org/10.1016/j.ecolmodel.2020.109074 +} +\usage{ +Ecosense.GOA +} +\description{ +Rpath inputs (unbalanaced model). +} +\keyword{datasets} diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 7b0f1c36..c6f2024b 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -5,6 +5,11 @@ using namespace Rcpp; +#ifdef RCPP_USE_GLOBAL_ROSTREAM +Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); +Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); +#endif + // rk4_run List rk4_run(List params, List instate, List forcing, List fishing, List stanzas, int StartYear, int EndYear); RcppExport SEXP _Rpath_rk4_run(SEXP paramsSEXP, SEXP instateSEXP, SEXP forcingSEXP, SEXP fishingSEXP, SEXP stanzasSEXP, SEXP StartYearSEXP, SEXP EndYearSEXP) { diff --git a/src/ecosim.cpp b/src/ecosim.cpp index c1855f70..d4fc87c3 100644 --- a/src/ecosim.cpp +++ b/src/ecosim.cpp @@ -1,948 +1,950 @@ - -#include "ecosim.h" - -//################################################################---------- -// Runge-Kutta 4th order method for integrating Ecosim equations -// Currently does not contain aged-structured species. -// [[Rcpp::export]] -List rk4_run (List params, List instate, List forcing, List fishing, List stanzas, - int StartYear, int EndYear){ - - int y, m, dd, t; -// Input rates are in units of years or years^-1. Integration is wri tten so -// that integration timesteps always line up with months, for data reasons. -// STEPS_PER_YEAR should be 12 (for months), and STEPS_PER_MONTH sets the -// rk4 integration timestep. So effective integration timestep with respect -// to input rates (years) is 1/(12*STEPS_PER_MONTH). - const int STEPS_PER_MONTH = as(params["RK4_STEPS"]); - const double hh = DELTA_T/(double)STEPS_PER_MONTH; - -// Get some basic needed numbers from the params List - const int NUM_BIO = as(params["NUM_LIVING"]) + as(params["NUM_DEAD"]); - const int NumPredPreyLinks = as(params["NumPredPreyLinks"]); - const int NumFishingLinks = as(params["NumFishingLinks"]); - -// Switches for run modes - const int BURN_YEARS = as(params["BURN_YEARS"]); - const NumericVector SENSE_LIMIT = as(params["SENSE_LIMIT"]); - const double LO_DISCARD = (SENSE_LIMIT[0]); - const double HI_DISCARD = (SENSE_LIMIT[1]); - int CRASH_YEAR = -1; - int MEASURE_MONTH = 5; - -// Flag for group-sepcific Integration method (NoIntegrate=0 means Fast Eq) - const NumericVector NoIntegrate = as(params["NoIntegrate"]); - -// Parameters needed directly for foraging time adjustment - const NumericVector B_BaseRef = as(params["B_BaseRef"]); - const NumericVector FtimeAdj = as(params["FtimeAdj"]); - const NumericVector FtimeQBOpt = as(params["FtimeQBOpt"]); -// FtimeAdj is monthly unit so adjust for sub-monthly integration - const NumericVector FtimeStep = FtimeAdj/STEPS_PER_MONTH; - -// Number of split groups - const int Nsplit = as(stanzas["Nsplit"]); - -// Parameter need to track catch by Gear - const NumericVector FishFrom = as(params["FishFrom"]); - -// Monthly output matrices - NumericMatrix out_Biomass(EndYear*12, NUM_BIO+1); - NumericMatrix out_Catch(EndYear*12, NUM_BIO+1); - NumericMatrix out_SSB(EndYear*12, NUM_BIO+1); - NumericMatrix out_rec(EndYear*12, NUM_BIO+1); - NumericMatrix out_Gear_Catch(EndYear*12, NumFishingLinks+1); -// Annual output matrices - NumericMatrix annual_Catch(EndYear, NUM_BIO+1); - NumericMatrix annual_Biomass(EndYear, NUM_BIO+1); - NumericMatrix annual_QB(EndYear, NUM_BIO+1); - NumericMatrix annual_Qlink(EndYear, NumPredPreyLinks+1); -// Accumulator for monthly catch values - NumericVector cum_Catch(NUM_BIO+1); - NumericVector cum_Gear_Catch(NumFishingLinks +1); - -//SML -// Update sums of split groups to total biomass for derivative calcs - if(Nsplit > 0){ - SplitSetPred(stanzas, instate); - } -//SML - -// Load state, set some initial values. Make sure state is COPY, not pointer - List state = clone(instate); - dd = StartYear * STEPS_PER_YEAR; // dd is monthly index for data storage - -// KYA 6/12/17 an initial derivative call just to declare deriv in right scope - List dyt = deriv_vector(params,state,forcing,fishing,stanzas,1,0,0); - NumericVector FoodGain = as(dyt["FoodGain"]); - NumericVector Qlink = as(dyt["Qlink"]); - - // MAIN LOOP STARTS HERE with years loop - for (y = StartYear; y <= EndYear; y++){ - if (y<1){stop("RK Year can't be less than 1");} - // Monthly loop - for (m = 0; m < STEPS_PER_YEAR; m++){ - cum_Catch = NumericVector(NUM_BIO+1); // monthly catch to accumulate - cum_Gear_Catch = NumericVector(NumFishingLinks+1); - dd = (y-1) * STEPS_PER_YEAR + m; - // Sub-monthly integration loop - for (t=0; t< STEPS_PER_MONTH; t++){ - double tt = (double)t*hh; // sub monthly timestep in years - // Load state vars (note: this creates pointers, not new vals) - NumericVector old_Biomass = as(state["Biomass"]); - NumericVector old_Ftime = as(state["Ftime"]); - - // Calculate base derivative and RK-4 derivative steps (overwrites YY) - List YY = state; - List k1 = deriv_vector(params,YY,forcing,fishing,stanzas,y,m,tt); - NumericVector kk1 = as(k1["DerivT"]); - - YY["Biomass"] = old_Biomass + 0.5*kk1*hh; - List k2 = deriv_vector(params,YY,forcing,fishing,stanzas,y,m,tt + 0.5*hh); - NumericVector kk2 = as(k2["DerivT"]); - - YY["Biomass"] = old_Biomass + 0.5*kk2*hh; - List k3 = deriv_vector(params,YY,forcing,fishing,stanzas,y,m,tt + 0.5*hh); - NumericVector kk3 = as(k3["DerivT"]); - - YY["Biomass"] = old_Biomass + kk3*hh; - List k4 = deriv_vector(params,YY,forcing,fishing,stanzas,y,m,tt + hh); - NumericVector kk4 = as(k4["DerivT"]); - - // Take an rk4 step - NumericVector new_Biomass = old_Biomass + hh*(kk1 + 2*kk2 + 2*kk3 + kk4)/6.0; - - // Update Foraging time state variable - // pd term is used to indicate differrent values used for - // age-structured species, defaults to Biomass for non-aged structure - NumericVector pd = old_Biomass; - FoodGain = as(k1["FoodGain"]); - Qlink = as(k1["Qlink"]); - NumericVector new_Ftime = ifelse((FoodGain>0)&(pd>0), - 0.1 + 0.9*old_Ftime* - ((1.0-FtimeStep) + FtimeStep*FtimeQBOpt/(FoodGain/pd)), - old_Ftime); - - // Accumulate Catch (small timestep, so linear average) - NumericVector FishingLoss = as(k1["FishingLoss"]); - cum_Catch += (hh * FishingLoss/old_Biomass) * (new_Biomass+old_Biomass)/2.0; - - // Track catch by gear - NumericVector old_Biomass_flink = as(old_Biomass[FishFrom]); - NumericVector new_Biomass_flink = as(new_Biomass[FishFrom]); - NumericVector GearCatch = as(k1["GearCatch"]); - cum_Gear_Catch += (hh * GearCatch / old_Biomass_flink) * (new_Biomass_flink + old_Biomass_flink)/2.0; - - // Set state to new values, including min/max traps - state["Biomass"] = pmax(pmin(new_Biomass, B_BaseRef*BIGNUM), B_BaseRef*EPSILON); - state["Ftime"] = pmin(new_Ftime, 2.0); - }// end of sub-monthly (t-indexed) loop - - // Insert Monthly Stanza (split pool) update here - //SML - // Calculate new derivative - List dyt = deriv_vector(params, state, forcing, fishing, stanzas, y, m, 0); - if(Nsplit > 0){ - SplitUpdate(stanzas, state, forcing, dyt, y, m + 1); - SplitSetPred(stanzas, state); - } - - // Make a copy of the current state for bounds testing - NumericVector cur_Biomass = as(state["Biomass"]); - - // KYA 8/9/17 one of the NA or NaN flags is reading back as a negative integer (-2^32) - // Not sure why. This sets any negative biomass (assuming this means NaN) to NA_REAL - cur_Biomass = ifelse((cur_Biomass<0),NA_REAL,cur_Biomass); - - // If the run is during the "burn-in" years, and biomass goes - // into the discard range, set flag to exit the loop. Should set "bad" - // biomass values to NA - if (y < BURN_YEARS){ cur_Biomass = ifelse((cur_BiomassB_BaseRef*HI_DISCARD), - NA_REAL,cur_Biomass); - } - - // If biomass goes crazy or hits NA, exit loop with crash signal. Note it - // should still write the NA or INF values back to the output. - if ( any(is_na(cur_Biomass)) | any(is_infinite(cur_Biomass)) | any(is_nan(cur_Biomass)) ) { - CRASH_YEAR = y; y = EndYear; m = STEPS_PER_YEAR; - } - - - // Write to monthly output matricies (vector write) - out_Biomass( dd, _) = cur_Biomass; - out_SSB(dd, _) = cur_Biomass; - out_rec(dd, _) = cur_Biomass; - out_Catch( dd, _) = cum_Catch; - out_Gear_Catch(dd, _) = cum_Gear_Catch; - annual_Catch(y-1, _) = annual_Catch(y-1, _) + cum_Catch; - if (m==MEASURE_MONTH){ - annual_Biomass(y-1, _) = cur_Biomass; - annual_QB(y-1, _) = FoodGain/cur_Biomass; - annual_Qlink(y-1, _) = Qlink; - } - } // End of main months loop - - }// End of years loop - -// Write Last timestep (note: SSB and rec only used for age-structure species) - //out_Biomass( dd+1, _) = as(state["Biomass"]); - //out_SSB(dd+1, _) = as(state["Biomass"]); - //out_rec(dd+1, _) = as(state["Biomass"]); - //out_Catch( dd+1, _) = out_Catch( dd, _); - -// Create Rcpp list to output -List outdat = List::create( - _["out_Biomass"]=out_Biomass, - _["out_Catch"]=out_Catch, - _["out_Gear_Catch"]=out_Gear_Catch, - _["annual_Catch"]=annual_Catch, - _["annual_Biomass"]=annual_Biomass, - _["annual_QB"]=annual_QB, - _["annual_Qlink"]=annual_Qlink, - _["end_state"]=state, - _["crash_year"]=CRASH_YEAR); - -// Return is an Rcpp List - return(outdat); -} - -//-----#################################################################---- -// Adams_Basforth two-step method for integrating ecosim equations. -// Fixed monthly timestep with "fast integration" Walters et al. '97 method -// for faster-turnover species. -// Currently does not contain aged-structured species. -// [[Rcpp::export]] -List Adams_run (List params, List instate, List forcing, List fishing, List stanzas, - int StartYear, int EndYear, List InitDeriv){ - -int y, m, dd; - -// Get some basic needed numbers from the params List - const int NUM_BIO = as(params["NUM_LIVING"]) + as(params["NUM_DEAD"]); - const int NumPredPreyLinks = as(params["NumPredPreyLinks"]); - const int NumFishingLinks = as(params["NumFishingLinks"]); - -// Forcing Biomass - //const int NumForcedBio = as(fitting["NumForcedBio"]); - //const IntegerVector BforceNum = as(fitting["BforceNum"]); - // KYA TODO 11/1/2017 put force_bybio in RK! - NumericMatrix force_bybio = as(forcing["ForcedBio"]); - -// Switches for run modes - const int BURN_YEARS = as(params["BURN_YEARS"]); - const NumericVector SENSE_LIMIT = as(params["SENSE_LIMIT"]); - const double LO_DISCARD = (SENSE_LIMIT[0]); - const double HI_DISCARD = (SENSE_LIMIT[1]); - int CRASH_YEAR = -1; - int MEASURE_MONTH = 5; - -// Flag for group-sepcific Integration method (NoIntegrate=0 means Fast Eq) - const NumericVector NoIntegrate = as(params["NoIntegrate"]); - -// Parameters needed directly for foraging time adjustment - const NumericVector B_BaseRef = as(params["B_BaseRef"]); - const NumericVector FtimeAdj = as(params["FtimeAdj"]); - const NumericVector FtimeQBOpt = as(params["FtimeQBOpt"]); - -// Parameters from stanzas - const int Nsplit = as(stanzas["Nsplit"]); - -// Parameter need to track catch by Gear - const NumericVector FishFrom = as(params["FishFrom"]); - -// Monthly output matrices - NumericMatrix out_Biomass( EndYear * 12, NUM_BIO + 1); - NumericMatrix out_Catch( EndYear * 12, NUM_BIO + 1); - NumericMatrix out_SSB(EndYear * 12, NUM_BIO + 1); - NumericMatrix out_rec(EndYear * 12, NUM_BIO + 1); - NumericMatrix out_Gear_Catch(EndYear*12, NumFishingLinks+1); -// Annual output matrices - NumericMatrix annual_Catch(EndYear, NUM_BIO+1); - NumericMatrix annual_Biomass(EndYear, NUM_BIO+1); - NumericMatrix annual_QB(EndYear, NUM_BIO+1); - NumericMatrix annual_Qlink(EndYear, NumPredPreyLinks+1); - -// Load state and call initial derivative (todo: allow other start times) -// Use Clone to make sure state/stanzas are copies of instate/instanzas, not pointers - List state = clone(instate); - //List stanzas = clone(instanzas); - - // Update sums of split groups to total biomass for derivative calcs - if(Nsplit > 0){ - SplitSetPred(stanzas, state); - } - - // Use the initial derivative calculated outside of function - List dyt = InitDeriv; - - dd = StartYear * STEPS_PER_YEAR; - -// MAIN LOOP STARTS HERE -// ASSUMES STEPS_PER_MONTH will always be 1.0, took out divisions - for (y = StartYear; y <= EndYear; y++){ - if (y<1){stop("Adams Year can't be less than 1");} - // Monthly loop - for (m = 0; m < STEPS_PER_YEAR; m++){ - dd = (y-1) * STEPS_PER_YEAR + m; // dd is index for monthly output - // Load old state and old derivative - NumericVector old_Biomass = as(state["Biomass"]); - NumericVector old_Ftime = as(state["Ftime"]); - NumericVector dydt0 = as(dyt["DerivT"]); - NumericVector stanzaPred = as(state["StanzaPred"]); - - // Calculate new derivative - dyt = deriv_vector(params, state, forcing, fishing, stanzas, y, m, 0); - - // Extract needed parts of the derivative - NumericVector dydt1 = as(dyt["DerivT"]); - NumericVector FoodGain = as(dyt["FoodGain"]); - NumericVector biomeq = as(dyt["biomeq"]); - NumericVector FishingLoss = as(dyt["FishingLoss"]); - NumericVector Qlink = as(dyt["Qlink"]); - - // Now Update the new State Biomass using Adams-Basforth - NumericVector new_Biomass = - ifelse( NoIntegrate == 0, - (1.0 - SORWT) * biomeq + SORWT * old_Biomass, - ifelse( NoIntegrate > 0, - old_Biomass + (DELTA_T / 2.0) * (3.0 * dydt1 - dydt0), - old_Biomass)); - - // Then Update Foraging Time - NumericVector pd = ifelse(NoIntegrate < 0, stanzaPred, old_Biomass); - NumericVector new_Ftime = ifelse((FoodGain > 0) & (pd > 0), - 0.1 + 0.9 * old_Ftime * ((1.0 - FtimeAdj) + FtimeAdj * FtimeQBOpt / - (FoodGain / pd)), - old_Ftime); - - // Monthly Stanza (split pool) update - if(Nsplit > 0){ - SplitUpdate(stanzas, state, forcing, dyt, y, m + 1); - SplitSetPred(stanzas, state); - } - new_Biomass = ifelse(NoIntegrate < 0, as(state["Biomass"]), new_Biomass); - - // Calculate catch assuming fixed Frate and exponential biomass change. - // kya 9/10/15 - replaced with linear, diff on monthly scale is minor - NumericVector new_Catch = (DELTA_T * FishingLoss / old_Biomass) * - (new_Biomass + old_Biomass) / 2.0; - - // Track catch by gear - NumericVector old_Biomass_flink = as(old_Biomass[FishFrom]); - NumericVector new_Biomass_flink = as(new_Biomass[FishFrom]); - NumericVector GearCatch = as(dyt["GearCatch"]); - NumericVector new_Gear_Catch = (DELTA_T * GearCatch / old_Biomass_flink) * - (new_Biomass_flink + old_Biomass_flink)/2.0; - - // NumericVector new_Catch = - // ifelse( new_Biomass==old_Biomass, - // FishingLoss*DELTA_T, - // (FishingLoss*DELTA_T/old_Biomass) * - // (new_Biomass-old_Biomass)/log(new_Biomass/old_Biomass) - // ); - - // KYA 9/13/17 - noticed that cur_Biomass is never copied back into state["Biomass"] after - // bounds testing. Error? Moved state["Biomass"] setting, hopefully nothing breaks... - // Set state to new values, including min/max traps - //state["Biomass"] = pmax(pmin(new_Biomass, B_BaseRef * BIGNUM), B_BaseRef * EPSILON); - //state["Ftime"] = pmin(new_Ftime, 2.0); - - // Make a copy of the current state for bounds testing - NumericVector cur_Biomass = pmax(pmin(new_Biomass, B_BaseRef * BIGNUM), B_BaseRef * EPSILON); // as(state["Biomass"]); - - NumericVector bforce = force_bybio((y-1) * STEPS_PER_YEAR + m, _); - cur_Biomass = ifelse(bforce>B_BaseRef * EPSILON, bforce, cur_Biomass); - - // insert forced biomass levels - //for (i=0; i=0){cur_Biomass[sp]=BforceVal(sp,m);} */ - //} - - // KYA 8/9/17 one of the NA or NaN flags is reading back as a negative integer (-2^32) - // Not sure why. This sets any negative biomass (assuming this means NaN) to NA_REAL - cur_Biomass = ifelse((cur_Biomass<0),NA_REAL,cur_Biomass); - - // If the run is during the "burn-in" years, and biomass goes - // into the discard range, set flag to exit the loop. Should set "bad" - // biomass values to NA - if (y < BURN_YEARS){ cur_Biomass = ifelse((cur_BiomassB_BaseRef*HI_DISCARD), - NA_REAL,cur_Biomass); - } - - // If biomass goes crazy or hits NA, exit loop with crash signal. Note it - // should still write the NA or INF values back to the output. - //NOJUV make sure crash tests work for juveniles. - - if ( any(is_na(cur_Biomass)) | any(is_infinite(cur_Biomass)) | any(is_nan(cur_Biomass)) ) { - CRASH_YEAR = y; y = EndYear; m = STEPS_PER_YEAR; - } - - // KYA 9/13/17 - Now copy cur_Biomass into state - state["Biomass"] = cur_Biomass; - state["Ftime"] = pmin(new_Ftime, 2.0); - - // Write to output matricies - out_Biomass( dd, _) = old_Biomass; - out_SSB(dd, _) = old_Biomass; - out_rec(dd, _) = old_Biomass; - out_Catch( dd, _) = new_Catch; - out_Gear_Catch(dd, _) = new_Gear_Catch; - annual_Catch(y-1, _) = annual_Catch(y-1, _) + new_Catch; - if (m==MEASURE_MONTH){ - annual_Biomass(y-1, _) = old_Biomass; - annual_QB(y-1, _) = FoodGain/old_Biomass; - annual_Qlink(y-1, _) = Qlink; - } - - //NOJUV for (i = 1; i <= juv_N; i++){ - //NOJUV out_SSB(dd, JuvNum[i]) = 0.0; - //NOJUV out_SSB(dd, AduNum[i]) = SpawnBio[i]; - //NOJUV out_rec(dd, AduNum[i]) = NageS(firstMoAdu[i], i) * WageS(firstMoAdu[i], i); - - } // End of main months loop - - }// End of years loop - -// Write Last timestep - //out_Biomass( dd+1, _) = as(state["Biomass"]); - //out_SSB(dd+1, _) = as(state["Biomass"]); - //out_rec(dd+1, _) = as(state["Biomass"]); - //out_Catch( dd+1, _) = out_Catch( dd, _); // the "next" time interval - //out_Gear_Catch(dd+1, _) = out_Gear_Catch(dd, _); -//NOJUV for (i = 1; i <= juv_N; i++){ -//NOJUV out_SSB(dd, JuvNum[i]) = 0.0; -//NOJUV out_SSB(dd, AduNum[i]) = SpawnBio[i]; -//NOJUV out_rec(dd, AduNum[i]) = NageS(firstMoAdu[i], i) * WageS(firstMoAdu[i], i); -//NOJUV } - -// Create Rcpp list to output - List outdat = List::create( - _["out_Biomass"]=out_Biomass, - _["out_Catch"]=out_Catch, - _["out_Gear_Catch"]=out_Gear_Catch, - _["annual_Catch"]=annual_Catch, - _["annual_Biomass"]=annual_Biomass, - _["annual_QB"]=annual_QB, - _["annual_Qlink"]=annual_Qlink, - _["end_state"]=state, - _["crash_year"]=CRASH_YEAR, - _["dyt"]=dyt); - -// Return is an Rcpp List - return(outdat); - -} - -//################################################################---------- -// Main derivative (dB/dt) calculations for ecosim model, using Rcpp vector -// package. -// [[Rcpp::export]] -List deriv_vector(List params, List state, List forcing, List fishing, List stanzas, - int inyear, int m, double tt){ - -int sp, links, prey, pred, gr, egr, dest, isp, ist, ieco; - - //Rcout << inyear <<" "<< m << std::endl; - if (inyear<1){stop("Derivative Year can't be less than 1");} - -// forcing time index (in months) - // KYA 11/1/17 - added offset to deal with 0 vs 1 indexing in forcing files - // (matters when trying to line up with "acutal" years) - const int y = inyear - 1; - const int dd = y*STEPS_PER_YEAR+m; - -// Base model size - number of groups and number of links (flows) by type - const int NUM_GROUPS = as(params["NUM_GROUPS"]); - const int NUM_LIVING = as(params["NUM_LIVING"]); - const int NUM_DEAD = as(params["NUM_DEAD"]); - const int NumPredPreyLinks = as(params["NumPredPreyLinks"]); - const int NumFishingLinks = as(params["NumFishingLinks"]); - const int NumDetLinks = as(params["NumDetLinks"]); - const int COUPLED = as(params["COUPLED"]); - -// NUM_GROUPS length input vectors - const NumericVector B_BaseRef = as(params["B_BaseRef"]); - const NumericVector MzeroMort = as(params["MzeroMort"]); - const NumericVector UnassimRespFrac = as(params["UnassimRespFrac"]); - const NumericVector ActiveRespFrac = as(params["ActiveRespFrac"]); - const NumericVector HandleSelf = as(params["HandleSelf"]); - const NumericVector ScrambleSelf = as(params["ScrambleSelf"]); - //const NumericVector fish_Effort = as(params["fish_Effort"]); - -// NumPredPreyLinks Length vectors - const IntegerVector PreyFrom = as(params["PreyFrom"]); - const IntegerVector PreyTo = as(params["PreyTo"]); - const NumericVector QQ = as(params["QQ"]); - const NumericVector DD = as(params["DD"]); - const NumericVector VV = as(params["VV"]); - const NumericVector HandleSwitch = as(params["HandleSwitch"]); - const NumericVector PredPredWeight = as(params["PredPredWeight"]); - const NumericVector PreyPreyWeight = as(params["PreyPreyWeight"]); - -// NumFishingLinks lenghted vectors - const IntegerVector FishFrom = as(params["FishFrom"]); - const IntegerVector FishThrough = as(params["FishThrough"]); - const IntegerVector FishTo = as(params["FishTo"]); - const NumericVector FishQ = as(params["FishQ"]); - const IntegerVector DetFrom = as(params["DetFrom"]); - const IntegerVector DetTo = as(params["DetTo"]); - const NumericVector DetFrac = as(params["DetFrac"]); - -// Age-structured parameters - const int Nsplit = as(stanzas["Nsplit"]); - const NumericVector Nstanzas = as(stanzas["Nstanzas"]); - const NumericVector baseStanzaPred = as(stanzas["baseStanzaPred"]); - NumericMatrix EcopathCode = as(stanzas["EcopathCode"]); - -// State vectors - const NumericVector state_Biomass = as(state["Biomass"]); - const NumericVector state_Ftime = as(state["Ftime"]); - const NumericVector stanzaPred = as(state["StanzaPred"]); - -//FISHING NumericVector TerminalF = as(params["TerminalF"]); -//FISHING NumericVector TARGET_BIO = as(params["TARGET_BIO"]); -//FISHING NumericVector TARGET_F = as(params["TARGET_F"]); -//FISHING NumericVector ALPHA = as(params["ALPHA"]); - -// "Environmental" forcing matrices (dd-indexed month x species) -// SHOULD BE CONST, but no row extraction for CONST (per Rcpp issues wiki) - NumericMatrix force_byprey = as(forcing["ForcedPrey"]); - NumericMatrix force_bymort = as(forcing["ForcedMort"]); - NumericMatrix force_bysearch = as(forcing["ForcedSearch"]); - NumericMatrix force_bymigrate = as(forcing["ForcedMigrate"]); - NumericMatrix force_byactresp = as(forcing["ForcedActresp"]); - -// Fishing forcing matrices (indexed year x species) -// SHOULD BE CONST, but no row extraction for CONST (per Rcpp issues wiki) - NumericMatrix FORCED_FRATE = as(fishing["ForcedFRate"]); - NumericMatrix FORCED_CATCH = as(fishing["ForcedCatch"]); - NumericMatrix EffortMat = as(fishing["ForcedEffort"]); - -// Components of derivative calculated here - NumericVector TotGain(NUM_GROUPS+1); - NumericVector TotLoss(NUM_GROUPS+1); - NumericVector LossPropToB(NUM_GROUPS+1); - NumericVector LossPropToQ(NUM_GROUPS+1); - NumericVector DerivT(NUM_GROUPS+1); - NumericVector biomeq(NUM_GROUPS+1); - NumericVector FoodLoss(NUM_GROUPS+1); - NumericVector FoodGain(NUM_GROUPS+1); - NumericVector UnAssimLoss(NUM_GROUPS+1); - NumericVector ActiveRespLoss(NUM_GROUPS+1); - NumericVector DetritalGain(NUM_GROUPS+1); - NumericVector FishingGain(NUM_GROUPS+1); - NumericVector MzeroLoss(NUM_GROUPS+1); - NumericVector FishingLoss(NUM_GROUPS+1); - NumericVector DetritalLoss(NUM_GROUPS+1); - NumericVector FishingThru(NUM_GROUPS+1); - NumericVector PredSuite(NUM_GROUPS+1); - NumericVector HandleSuite(NUM_GROUPS+1); - NumericVector GearCatch(NumFishingLinks+1); - NumericVector MigrateLoss(NUM_GROUPS+1); - -// Set effective biomass for pred/prey response -// default is B/Bref - NumericVector preyYY = state_Ftime * state_Biomass/B_BaseRef * force_byprey(dd,_); - NumericVector predYY = state_Ftime * state_Biomass/B_BaseRef * force_bysearch(dd,_); - -// Set functional response biomass for juvenile and adult groups (including foraging time) - if(Nsplit > 0){ - for (isp = 1; isp <=Nsplit; isp++){ - for(ist = 1; ist <= Nstanzas[isp]; ist++){ - ieco = EcopathCode(isp, ist); - if (baseStanzaPred[ieco] > 0){ - predYY[ieco] = state_Ftime[ieco] * stanzaPred[ieco] / - baseStanzaPred[ieco]; - } - } - } - } - -// Unroll Biomass Vectors (match pred, prey biomass for all links) - NumericVector PYY = preyYY[PreyFrom]; - NumericVector PDY = predYY[PreyTo]; - -// Summed predator and prey suites for joint handling time and/or scramble functional response - for (links=1; links<=NumPredPreyLinks; links++){ - PredSuite[PreyFrom[links]] += predYY[PreyTo[links] ] * PredPredWeight[links]; - HandleSuite[PreyTo[links]] += preyYY[PreyFrom[links]] * PreyPreyWeight[links]; - } - -// Unroll the suites into a NumPredPrey length vector - NumericVector PdSuite = PredSuite[PreyFrom]; - NumericVector PySuite = HandleSuite[PreyTo]; - NumericVector Hself = HandleSelf[PreyTo]; - NumericVector Sself = ScrambleSelf[PreyTo]; - -// // Main VECTOR CALC to calculate functional response for each predator/prey link -// // (3) Additive version: primary used and published in Aydin (2004) -// // KYA 3/2/2012 setting "COUPLED" to zero means species are density dependent -// // (based on their own modul) but don't interact otherwise. This can magically -// // create and destroy energy in the system but makes them act like a set -// // of independent surplus production models for comparison purposes -// NON-VECTOR VERSION: -// Q = QQ[links] * predYY[pred] * pow(preyYY[prey], COUPLED * HandleSwitch[links]) * -// ( DD[links] / ( DD[links] - 1.0 + -// pow(HandleSelf[pred] * preyYY[prey] + -// (1. - HandleSelf[pred]) * HandleSuite[pred], -// COUPLED * HandleSwitch[links])) )* -// ( VV[links] / ( VV[links] - 1.0 + -// ScrambleSelf[pred] * predYY[pred] + -// (1. - ScrambleSelf[pred]) * PredSuite[prey]) ); -// Rcpp VECTOR VERSION - NumericVector Q1 = - QQ * PDY * vpow(PYY, HandleSwitch * COUPLED) * - ( DD / ( DD-1.0 + vpow((1.-Hself)*PYY + Hself*PySuite, COUPLED*HandleSwitch)) ) * - ( VV / ( VV-1.0 + (1.-Sself)*PDY + Sself*PdSuite) ); - Q1[0] = 1.0; // get rid of NaN - moved from KYA's code 6/12/17 - -// No vector solution here as we need to sum by both links and species - for (links=1; links<=NumPredPreyLinks; links++){ - prey = PreyFrom[links]; - pred = PreyTo[links]; - // If model is uncoupled, food loss doesn't change with prey or predator levels. - if (COUPLED){ FoodLoss[prey] += Q1[links]; } - else{ FoodLoss[prey] += state_Biomass[prey] * QQ[links]/B_BaseRef[prey]; } - FoodGain[pred] += Q1[links]; - } - -// By Species Rates - UnAssimLoss = FoodGain * UnassimRespFrac; - ActiveRespLoss = FoodGain * ActiveRespFrac * force_byactresp(dd,_); - MzeroLoss = MzeroMort * state_Biomass; - - NumericVector NetProd = FoodGain - UnAssimLoss - ActiveRespLoss - MzeroLoss - FoodLoss; - -// FISHING FUNCTIONS (multiple options depending on fishing method) - -// // MOST OF THE FOLLOWING FISHING SPECIFICATION METHODS ARE NOT SUPPORTED -// // BY THE R-CODE, only fishing by effort (for gear) or by F-rate (for -// // species) is supported at the end. -// // -// // BY CURRENT R-CODE. ONLY -// // RFISH for (gr=NUM_LIVING+NUM_DEAD+1; gr<=NUM_GROUPS; gr++){ -// // RFISH This sets EFFORT by time series of gear-target combinations -// // RFISH for (gr=NUM_LIVING+NUM_DEAD+1; gr<=NUM_GROUPS; gr++){ -// // RFISH if -1 is an input value, uses TERMINAL F (last non-negative F) -// //RFISH for (gr=NUM_LIVING+NUM_DEAD+1; gr<=NUM_GROUPS; gr++){ -// //RFISH if (y+m+d == 0){fish_Effort[gr]=1.0;} -// //RFISH else {fish_Effort[gr]=1.0;} // NOTE DEFAULT! THIS CAN BE CHANGED TO 1.0 -// //RFISH // Added 7/8/08 for forced effort -// //RFISH if (FORCED_EFFORT[gr][y] > -0.001) -// //RFISH {fish_Effort[gr]=FORCED_EFFORT[gr][y];} -// //RFISH -// //RFISH if ((FORCED_TARGET[gr]>0) && (FORCED_CATCH[gr][y]>-EPSILON)){ -// //RFISH totQ = 0.0; -// //RFISH sp = FORCED_TARGET[gr]; -// //RFISH for (links=1; links<=NumFishingLinks; links++){ -// //RFISH if ((FishingThrough[links] == gr) && -// //RFISH (FishingFrom[links]) == sp){ -// //RFISH totQ += FishingQ[links]; -// //RFISH } -// //RFISH } -// //RFISH fish_Effort[gr] = FORCED_CATCH[gr][y]/ -// //RFISH (totQ * state_Biomass[sp]); -// //RFISH if (FORCED_CATCH[gr][y] >= state_Biomass[sp]) -// //RFISH {fish_Effort[gr] = (1.0-EPSILON)*(state_Biomass[sp])/ -// //RFISH (totQ * state_Biomass[sp]);} -// //RFISH } -// //RFISH // By putting F after catch, Frates override absolute catch -// //RFISH if ((FORCED_FTARGET[gr]>0) && (FORCED_FRATE[gr][y]>-EPSILON)){ -// //RFISH totQ = 0.0; -// //RFISH sp = FORCED_FTARGET[gr]; -// //RFISH for (links=1; links<=NumFishingLinks; links++){ -// //RFISH if ((FishingThrough[links] == gr) && -// //RFISH (FishingFrom[links]) == sp){ -// //RFISH totQ += FishingQ[links]; -// //RFISH } -// //RFISH } -// //RFISH fish_Effort[gr] = FORCED_FRATE[gr][y]/totQ; -// //RFISH //if (FORCED_CATCH[gr][y] >= state_Biomass[sp]) -// //RFISH // {fish_Effort[gr] = (1.0-EPSILON)*(state_Biomass[sp])/ -// //RFISH // (totQ * state_Biomass[sp]);} -// //RFISH } -// //RFISH -// //RFISH //if ((y==0) && (m==0) && (d==0)){ -// //RFISH // cout << path_species[gr] << " " << FORCED_TARGET[gr] << " " << path_species[sp] << " " -// //RFISH // << state_Biomass[sp] << " " << FORCED_CATCH[gr][y] << " " -// //RFISH // << fish_Effort[gr] << endl; -// //RFISH //} -// //RFISH } -// - double caught; - // Apply specified Effort by Gear to catch (using Ecopath-set Q) - NumericVector Effort = (NumericVector)EffortMat(dd,_); - for (links=1; links<=NumFishingLinks; links++){ - prey = FishFrom[links]; - gr = FishThrough[links]; - dest = FishTo[links]; - egr = FishThrough[links] - (NUM_LIVING + NUM_DEAD); - caught = FishQ[links] * Effort[egr] * state_Biomass[prey]; - FishingLoss[prey] += caught; - FishingThru[gr] += caught; - FishingGain[dest] += caught; - GearCatch[links] = caught; - } - NumericVector FORCE_F = (NumericVector)FORCED_FRATE(y,_); - // Special "CLEAN" fisheries assuming q=1, so specified input is Frate - for (sp=1; sp<=NUM_LIVING+NUM_DEAD; sp++){ - caught = FORCED_CATCH(y, sp) + FORCE_F[sp] * state_Biomass[sp]; - // KYA Aug 2011 removed terminal effort option to allow negative fishing pressure - // if (caught <= -EPSILON) {caught = TerminalF[sp] * state_Biomass[sp];} - // KYA 10/6/17 Added productivity to Biomass limit for F>1 species (salmon inspired) - if (caught >= state_Biomass[sp] + NetProd[sp]){caught = (1.0 - EPSILON) * (state_Biomass[sp] + NetProd[sp]);} - if (caught<0){caught=0;} - FishingLoss[sp] += caught; - FishingThru[0] += caught; - FishingGain[0] += caught; - //if(sp==1){Rprintf("%d %g %g %g \n",sp,FORCED_FRATE(y,sp),caught,FishingLoss[sp]);} - //TerminalF[sp] = caught/state_Biomass[sp]; - } - -// KINKED CONTROL RULE - NEEDS INPUT of TARGET BIOMASS and TARGET CATCH - //FISHING double RefBio, maxcaught; - //FISHING for (sp=1; sp<=NUM_LIVING+NUM_DEAD; sp++){ - //FISHING if (TARGET_BIO[sp] > EPSILON){ - //FISHING RefBio = state_Biomass[sp] / TARGET_BIO[sp]; - //FISHING maxcaught = TARGET_F[sp] * state_Biomass[sp]; - //FISHING if (RefBio > 1.0) {caught = maxcaught;} - //FISHING else if (RefBio >= ALPHA[sp]) {caught = maxcaught * (RefBio - ALPHA[sp])/(1.0 - ALPHA[sp]);} - //FISHING else {caught = 0.0;} - //FISHING FishingLoss[sp] += caught; - //FISHING FishingThru[0] += caught; - //FISHING FishingGain[0] += caught; - //FISHING TerminalF[sp] = caught/state_Biomass[sp]; - //FISHING } - //FISHING } - -// DETRITUS - note: check interdetrital flow carefully, have had some issues -// (check by ensuring equlibrium run stays in equilibrium) - int liv, det; - double flow; - for (links=1; links<=NumDetLinks; links++){ - liv = DetFrom[links]; - det = DetTo[links]; - flow = DetFrac[links] * (MzeroLoss[liv] + UnAssimLoss[liv]); - DetritalGain[det] += flow; - if (liv > NUM_LIVING) {DetritalLoss[liv] += flow; } - } - for (sp=NUM_LIVING+1; sp<=NUM_LIVING+NUM_DEAD; sp++){ - MzeroLoss[sp] = 0.0; - } - -// Add mortality forcing - for (int i=1; i<=NUM_DEAD+NUM_LIVING; i++){ - FoodLoss[i] *= force_bymort(dd, i); - MzeroLoss[i] *= force_bymort(dd, i); - } - -// Add migration forcing - MigrateLoss = clone(state_Biomass); - for (int i=1; i<=NUM_DEAD+NUM_LIVING; i++){ - MigrateLoss[i] *= force_bymigrate(dd, i); - } - -// Sum up derivitive parts (vector sums) -// Override for group 0 (considered "the sun", never changing) - TotGain = FoodGain + DetritalGain + FishingGain; - LossPropToQ = UnAssimLoss + ActiveRespLoss; - LossPropToB = FoodLoss + MzeroLoss + FishingLoss + MigrateLoss + DetritalLoss; - TotGain[0] = 0; - LossPropToB[0] = 0; - LossPropToQ[0] = 0; - TotLoss = LossPropToQ + LossPropToB; - biomeq = TotGain/(TotLoss/state_Biomass); - biomeq[0] = 1.0; - DerivT = TotGain - TotLoss; - -// Rcpp List structure to return -// KYA 6/20/17 Rcpp bug (known) is max 18 items on List::create -// had to add Q1 (qlink), so removed LossPropToQ (used nowhere?) -// SML 8/8/17 - actually don't need most of these...commenting -// out to track catch by gear - List deriv = List::create( - //_["preyYY"]=preyYY, - //_["predYY"]=predYY, - _["TotGain"]=TotGain, - _["TotLoss"]=TotLoss, - _["DerivT"]=DerivT, - _["biomeq"]=biomeq, - _["LossPropToB"]=LossPropToB, - //_["LossPropToQ"]=LossPropToQ, - _["FoodLoss"]=FoodLoss, - _["FoodGain"]=FoodGain, - _["UnAssimLoss"]=UnAssimLoss, - _["ActiveRespLoss"]=ActiveRespLoss, - _["DetritalGain"]=DetritalGain, - _["FishingGain"]=FishingGain, - _["MzeroLoss"]=MzeroLoss, - _["FishingLoss"]=FishingLoss, - _["DetritalLoss"]=DetritalLoss, - _["FishingThru"]=FishingThru, - //_["PredSuite"]=PredSuite, - //_["HandleSuite"]=HandleSuite, - _["Qlink"]=Q1, - _["GearCatch"]=GearCatch - ); - -// Return is an Rcpp List - return(deriv); -} - -// SplitSetPred function called in sim stanza initialize and update -// This function simply sums up across stanzas to get population-level -// Biomass, Numbers, and Consumption -// [[Rcpp::export]] -int SplitSetPred(List stanzas, List state){ - int isp, ist, ia, ieco; - double Bt, pt, Nt; - - //stanza parameters - const int Nsplit = as(stanzas["Nsplit"]); - const NumericVector Nstanzas = as(stanzas["Nstanzas"]); - NumericMatrix Age1 = as(stanzas["Age1"]); - NumericMatrix Age2 = as(stanzas["Age2"]); - NumericMatrix EcopathCode = as(stanzas["EcopathCode"]); - //Parts of Stanza State - NumericMatrix NageS = as(state["NageS"]); - NumericMatrix WageS = as(state["WageS"]); - NumericMatrix QageS = as(state["QageS"]); - NumericVector stanzaPred = as(state["StanzaPred"]); - //state parameters - NumericVector state_Biomass = as(state["Biomass"]); - NumericVector state_N = as(state["N"]); - - for (isp = 1; isp <= Nsplit; isp++){ - for (ist = 1; ist <= Nstanzas[isp]; ist++){ - ieco = EcopathCode(isp, ist); - Bt = 1e-30; - pt = 1e-30; - Nt = 1e-30; - for (ia = Age1(isp, ist); ia <= Age2(isp, ist); ia++){ - Bt = Bt + NageS(ia, isp) * WageS(ia, isp); - pt = pt + NageS(ia, isp) * QageS(ia, isp); - Nt = Nt + NageS(ia, isp); - } - state_Biomass[ieco] = Bt; - state_N[ieco] = Nt; - stanzaPred[ieco] = pt; - } - } - return(0); -} - -// SplitUpdate function -// Update numbers, weight, and biomass for multistanza groups -// [[Rcpp::export]] -int SplitUpdate(List stanzas, List state, List forcing, List deriv, int yr, int mon){ - int isp, ist, ia, ieco=0, last, first; //KYA 6/12/17 ieco=0 to stop annoying warning - double Su, Gf, Nt; - - //stanza parameters - const int Nsplit = as(stanzas["Nsplit"]); - const NumericVector Nstanzas = as(stanzas["Nstanzas"]); - const NumericVector vBM = as(stanzas["vBM"]); - const NumericVector Wmat = as(stanzas["Wmat"]); - //const NumericVector Wmat001 = as(stanzas["Wmat001"]); - //const NumericVector Wmat50 = as(stanzas["Wmat50"]); - //const NumericVector WmatSpread = as(stanzas["WmatSpread"]); - //const NumericVector Amat001 = as(stanzas["Amat001"]); - //const NumericVector Amat50 = as(stanzas["Amat50"]); - //const NumericVector AmatSpread = as(stanzas["AmatSpread"]); - const NumericVector baseEggsStanza = as(stanzas["baseEggsStanza"]); - const NumericVector RscaleSplit = as(stanzas["RscaleSplit"]); - const NumericVector RzeroS = as(stanzas["RzeroS"]); - const NumericVector RecPower = as(stanzas["RecPower"]); - const NumericVector vBGFd = as(stanzas["vBGFd"]); - const NumericVector SpawnEnergy = as(stanzas["SpawnEnergy"]); - const NumericVector SpawnX = as(stanzas["SpawnX"]); - const NumericVector baseSpawnBio = as(stanzas["baseSpawnBio"]); - // The following matrices should also be const - NumericMatrix SplitAlpha = as(stanzas["SplitAlpha"]); - NumericMatrix Age1 = as(stanzas["Age1"]); - NumericMatrix Age2 = as(stanzas["Age2"]); - NumericMatrix EcopathCode = as(stanzas["EcopathCode"]); - // Parts of Stanza State - NumericVector SpawnBio = as(state["SpawnBio"]); - NumericVector EggsStanza = as(state["EggsStanza"]); - NumericMatrix NageS = as(state["NageS"]); - NumericMatrix WageS = as(state["WageS"]); - NumericMatrix QageS = as(state["QageS"]); - NumericVector stanzaPred = as(state["StanzaPred"]); - - //state parameters - const NumericVector state_Biomass = as(state["Biomass"]); - - //forcing parameters - NumericMatrix force_byrecs = as(forcing["ForcedRecs"]); - - //derivatives - const NumericVector LossPropToB = as(deriv["LossPropToB"]); - const NumericVector FoodGain = as(deriv["FoodGain"]); - - for (isp = 1; isp <= Nsplit; isp++){ - // Update numbers and body weights - SpawnBio[isp] = 0; - for(ist = 1; ist <= Nstanzas[isp]; ist++){ - ieco = EcopathCode(isp, ist); - Su = exp(-LossPropToB[ieco] / STEPS_PER_YEAR / state_Biomass[ieco]); - Gf = FoodGain[ieco] / stanzaPred[ieco]; - for(ia = Age1(isp, ist); ia <= Age2(isp, ist); ia++){ - NageS(ia, isp) = NageS(ia, isp) * Su; - WageS(ia, isp) = vBM[isp] * WageS(ia, isp) + Gf * SplitAlpha(ia, isp); - // KYA 5/7/18 - started to add alternate maturity method, commented out for now - //if(Wmat[isp]<0.0){ - // if ((WageS(ia, isp)>Wmat001[isp])&&(ia>Amat001[isp])){ - // SpawnBio[isp] += NageS(ia, isp) * WageS(ia, isp)/(1. + exp( - // -((WageS(ia, isp) - Wmat50[isp]) / WmatSpread[isp]) - // -((ia - Amat50[isp]) / AmatSpread[isp]) )); - // } - //} - //else{ - if(WageS(ia, isp) > Wmat[isp]){ - SpawnBio[isp] += NageS(ia, isp) * (WageS(ia, isp) - Wmat[isp]); - }; - //} - } - } - EggsStanza[isp] = SpawnBio[isp] * SpawnEnergy[isp] * SpawnX[isp] / - (SpawnX[isp] - 1.0 + (SpawnBio[isp] / baseSpawnBio[isp])); - EggsStanza[isp] *= force_byrecs(yr * STEPS_PER_YEAR + mon, ieco); - - //Rprintf("%g %g %g %g %g",isp,SpawnBio[isp],EggsStanza[isp],) - // Need to add monthly recruitment - - // now update n and wt looping backward over age - last = Age2(isp, Nstanzas[isp]); - first = Age1(isp, 1); - - Nt = NageS(last, isp) + NageS(last - 1, isp); - if(Nt == 0){Nt = 1e-30;} - - WageS(last, isp) = (WageS(last, isp) * NageS(last, isp) + WageS(last - 1, isp) * - NageS(last - 1, isp)) / Nt; - NageS(last, isp) = Nt; - - for(ia = last - 1; ia > first; ia--){ - NageS(ia, isp) = NageS(ia - 1, isp); - WageS(ia, isp) = WageS(ia - 1, isp); - } - - //Apply number of eggs to youngest slot. Includes Walter recruit power - if(baseEggsStanza[isp] > 0){ - NageS(first, isp) = RscaleSplit[isp] * RzeroS[isp] * pow(double(EggsStanza[isp] / - baseEggsStanza[isp]), double(RecPower[isp])); - } - WageS(first, isp) = 0; - - //Uses generalized vonB (exponent is d) - //Added for stability 4/13/07 (Unlucky Friday) - for(ia = 0; ia <= last; ia++){ - QageS(ia, isp) = pow(double(WageS(ia, isp)), double(vBGFd[isp])); - } - } - -return(0); + +#include "ecosim.h" + +//################################################################---------- +// Runge-Kutta 4th order method for integrating Ecosim equations +// Currently does not contain aged-structured species. +// [[Rcpp::export]] +List rk4_run (List params, List instate, List forcing, List fishing, List stanzas, + int StartYear, int EndYear){ + + int y, m, dd, t; +// Input rates are in units of years or years^-1. Integration is wri tten so +// that integration timesteps always line up with months, for data reasons. +// STEPS_PER_YEAR should be 12 (for months), and STEPS_PER_MONTH sets the +// rk4 integration timestep. So effective integration timestep with respect +// to input rates (years) is 1/(12*STEPS_PER_MONTH). + const int STEPS_PER_MONTH = as(params["RK4_STEPS"]); + const double hh = DELTA_T/(double)STEPS_PER_MONTH; + +// Get some basic needed numbers from the params List + const int NUM_BIO = as(params["NUM_LIVING"]) + as(params["NUM_DEAD"]); + const int NumPredPreyLinks = as(params["NumPredPreyLinks"]); + const int NumFishingLinks = as(params["NumFishingLinks"]); + +// Switches for run modes + const int BURN_YEARS = as(params["BURN_YEARS"]); + const NumericVector SENSE_LIMIT = as(params["SENSE_LIMIT"]); + const double LO_DISCARD = (SENSE_LIMIT[0]); + const double HI_DISCARD = (SENSE_LIMIT[1]); + int CRASH_YEAR = -1; + int MEASURE_MONTH = 5; + +// Flag for group-sepcific Integration method (NoIntegrate=0 means Fast Eq) + const NumericVector NoIntegrate = as(params["NoIntegrate"]); + +// Parameters needed directly for foraging time adjustment + const NumericVector B_BaseRef = as(params["B_BaseRef"]); + const NumericVector FtimeAdj = as(params["FtimeAdj"]); + const NumericVector FtimeQBOpt = as(params["FtimeQBOpt"]); +// FtimeAdj is monthly unit so adjust for sub-monthly integration + const NumericVector FtimeStep = FtimeAdj/STEPS_PER_MONTH; + +// Number of split groups + const int Nsplit = as(stanzas["Nsplit"]); + +// Parameter need to track catch by Gear + const NumericVector FishFrom = as(params["FishFrom"]); + +// Monthly output matrices + NumericMatrix out_Biomass(EndYear*12, NUM_BIO+1); + NumericMatrix out_Catch(EndYear*12, NUM_BIO+1); + NumericMatrix out_SSB(EndYear*12, NUM_BIO+1); + NumericMatrix out_rec(EndYear*12, NUM_BIO+1); + NumericMatrix out_Gear_Catch(EndYear*12, NumFishingLinks+1); +// Annual output matrices + NumericMatrix annual_Catch(EndYear, NUM_BIO+1); + NumericMatrix annual_Biomass(EndYear, NUM_BIO+1); + NumericMatrix annual_QB(EndYear, NUM_BIO+1); + NumericMatrix annual_Qlink(EndYear, NumPredPreyLinks+1); +// Accumulator for monthly catch values + NumericVector cum_Catch(NUM_BIO+1); + NumericVector cum_Gear_Catch(NumFishingLinks +1); + +//SML +// Update sums of split groups to total biomass for derivative calcs + if(Nsplit > 0){ + SplitSetPred(stanzas, instate); + } +//SML + +// Load state, set some initial values. Make sure state is COPY, not pointer + List state = clone(instate); + dd = StartYear * STEPS_PER_YEAR; // dd is monthly index for data storage + +// KYA 6/12/17 an initial derivative call just to declare deriv in right scope + List dyt = deriv_vector(params,state,forcing,fishing,stanzas,1,0,0); + NumericVector FoodGain = as(dyt["FoodGain"]); + NumericVector Qlink = as(dyt["Qlink"]); + + // MAIN LOOP STARTS HERE with years loop + for (y = StartYear; y <= EndYear; y++){ + if (y<1){stop("RK Year can't be less than 1");} + // Monthly loop + for (m = 0; m < STEPS_PER_YEAR; m++){ + cum_Catch = NumericVector(NUM_BIO+1); // monthly catch to accumulate + cum_Gear_Catch = NumericVector(NumFishingLinks+1); + dd = (y-1) * STEPS_PER_YEAR + m; + // Sub-monthly integration loop + for (t=0; t< STEPS_PER_MONTH; t++){ + double tt = (double)t*hh; // sub monthly timestep in years + // Load state vars (note: this creates pointers, not new vals) + NumericVector old_Biomass = as(state["Biomass"]); + NumericVector old_Ftime = as(state["Ftime"]); + + // Calculate base derivative and RK-4 derivative steps (overwrites YY) + List YY = state; + List k1 = deriv_vector(params,YY,forcing,fishing,stanzas,y,m,tt); + NumericVector kk1 = as(k1["DerivT"]); + + YY["Biomass"] = old_Biomass + 0.5*kk1*hh; + List k2 = deriv_vector(params,YY,forcing,fishing,stanzas,y,m,tt + 0.5*hh); + NumericVector kk2 = as(k2["DerivT"]); + + YY["Biomass"] = old_Biomass + 0.5*kk2*hh; + List k3 = deriv_vector(params,YY,forcing,fishing,stanzas,y,m,tt + 0.5*hh); + NumericVector kk3 = as(k3["DerivT"]); + + YY["Biomass"] = old_Biomass + kk3*hh; + List k4 = deriv_vector(params,YY,forcing,fishing,stanzas,y,m,tt + hh); + NumericVector kk4 = as(k4["DerivT"]); + + // Take an rk4 step + NumericVector new_Biomass = old_Biomass + hh*(kk1 + 2*kk2 + 2*kk3 + kk4)/6.0; + + // Update Foraging time state variable + // pd term is used to indicate differrent values used for + // age-structured species, defaults to Biomass for non-aged structure + NumericVector pd = old_Biomass; + FoodGain = as(k1["FoodGain"]); + Qlink = as(k1["Qlink"]); + NumericVector new_Ftime = ifelse((FoodGain>0)&(pd>0), + 0.1 + 0.9*old_Ftime* + ((1.0-FtimeStep) + FtimeStep*FtimeQBOpt/(FoodGain/pd)), + old_Ftime); + + // Accumulate Catch (small timestep, so linear average) + NumericVector FishingLoss = as(k1["FishingLoss"]); + cum_Catch += (hh * FishingLoss/old_Biomass) * (new_Biomass+old_Biomass)/2.0; + + // Track catch by gear + NumericVector old_Biomass_flink = as(old_Biomass[FishFrom]); + NumericVector new_Biomass_flink = as(new_Biomass[FishFrom]); + NumericVector GearCatch = as(k1["GearCatch"]); + cum_Gear_Catch += (hh * GearCatch / old_Biomass_flink) * (new_Biomass_flink + old_Biomass_flink)/2.0; + + // Set state to new values, including min/max traps + state["Biomass"] = pmax(pmin(new_Biomass, B_BaseRef*BIGNUM), B_BaseRef*EPSILON); + state["Ftime"] = pmin(new_Ftime, 2.0); + }// end of sub-monthly (t-indexed) loop + + // Insert Monthly Stanza (split pool) update here + //SML + // Calculate new derivative + List dyt = deriv_vector(params, state, forcing, fishing, stanzas, y, m, 0); + if(Nsplit > 0){ + SplitUpdate(stanzas, state, forcing, dyt, y, m + 1); + SplitSetPred(stanzas, state); + } + + // Make a copy of the current state for bounds testing + NumericVector cur_Biomass = as(state["Biomass"]); + + // KYA 8/9/17 one of the NA or NaN flags is reading back as a negative integer (-2^32) + // Not sure why. This sets any negative biomass (assuming this means NaN) to NA_REAL + cur_Biomass = ifelse((cur_Biomass<0),NA_REAL,cur_Biomass); + + // If the run is during the "burn-in" years, and biomass goes + // into the discard range, set flag to exit the loop. Should set "bad" + // biomass values to NA + if (y < BURN_YEARS){ cur_Biomass = ifelse((cur_BiomassB_BaseRef*HI_DISCARD), + NA_REAL,cur_Biomass); + } + + // If biomass goes crazy or hits NA, exit loop with crash signal. Note it + // should still write the NA or INF values back to the output. + if ( any(is_na(cur_Biomass)) | any(is_infinite(cur_Biomass)) | any(is_nan(cur_Biomass)) ) { + CRASH_YEAR = y; y = EndYear; m = STEPS_PER_YEAR; + } + + + // Write to monthly output matricies (vector write) + out_Biomass( dd, _) = cur_Biomass; + out_SSB(dd, _) = cur_Biomass; + out_rec(dd, _) = cur_Biomass; + out_Catch( dd, _) = cum_Catch; + out_Gear_Catch(dd, _) = cum_Gear_Catch; + annual_Catch(y-1, _) = annual_Catch(y-1, _) + cum_Catch; + if (m==MEASURE_MONTH){ + annual_Biomass(y-1, _) = cur_Biomass; + annual_QB(y-1, _) = FoodGain/cur_Biomass; + annual_Qlink(y-1, _) = Qlink; + } + } // End of main months loop + + }// End of years loop + +// Write Last timestep (note: SSB and rec only used for age-structure species) + //out_Biomass( dd+1, _) = as(state["Biomass"]); + //out_SSB(dd+1, _) = as(state["Biomass"]); + //out_rec(dd+1, _) = as(state["Biomass"]); + //out_Catch( dd+1, _) = out_Catch( dd, _); + +// Create Rcpp list to output +List outdat = List::create( + _["out_Biomass"]=out_Biomass, + _["out_Catch"]=out_Catch, + _["out_Gear_Catch"]=out_Gear_Catch, + _["annual_Catch"]=annual_Catch, + _["annual_Biomass"]=annual_Biomass, + _["annual_QB"]=annual_QB, + _["annual_Qlink"]=annual_Qlink, + _["end_state"]=state, + _["crash_year"]=CRASH_YEAR); + +// Return is an Rcpp List + return(outdat); +} + +//-----#################################################################---- +// Adams_Basforth two-step method for integrating ecosim equations. +// Fixed monthly timestep with "fast integration" Walters et al. '97 method +// for faster-turnover species. +// Currently does not contain aged-structured species. +// [[Rcpp::export]] +List Adams_run (List params, List instate, List forcing, List fishing, List stanzas, + int StartYear, int EndYear, List InitDeriv){ + +int y, m, dd; + +// Get some basic needed numbers from the params List + const int NUM_BIO = as(params["NUM_LIVING"]) + as(params["NUM_DEAD"]); + const int NumPredPreyLinks = as(params["NumPredPreyLinks"]); + const int NumFishingLinks = as(params["NumFishingLinks"]); + +// Forcing Biomass + //const int NumForcedBio = as(fitting["NumForcedBio"]); + //const IntegerVector BforceNum = as(fitting["BforceNum"]); + // KYA TODO 11/1/2017 put force_bybio in RK! + NumericMatrix force_bybio = as(forcing["ForcedBio"]); + +// Switches for run modes + const int BURN_YEARS = as(params["BURN_YEARS"]); + const NumericVector SENSE_LIMIT = as(params["SENSE_LIMIT"]); + const double LO_DISCARD = (SENSE_LIMIT[0]); + const double HI_DISCARD = (SENSE_LIMIT[1]); + int CRASH_YEAR = -1; + int MEASURE_MONTH = 5; + +// Flag for group-sepcific Integration method (NoIntegrate=0 means Fast Eq) + const NumericVector NoIntegrate = as(params["NoIntegrate"]); + +// Parameters needed directly for foraging time adjustment + const NumericVector B_BaseRef = as(params["B_BaseRef"]); + const NumericVector FtimeAdj = as(params["FtimeAdj"]); + const NumericVector FtimeQBOpt = as(params["FtimeQBOpt"]); + +// Parameters from stanzas + const int Nsplit = as(stanzas["Nsplit"]); + +// Parameter need to track catch by Gear + const NumericVector FishFrom = as(params["FishFrom"]); + +// Monthly output matrices + NumericMatrix out_Biomass( EndYear * 12, NUM_BIO + 1); + NumericMatrix out_Catch( EndYear * 12, NUM_BIO + 1); + NumericMatrix out_SSB(EndYear * 12, NUM_BIO + 1); + NumericMatrix out_rec(EndYear * 12, NUM_BIO + 1); + NumericMatrix out_Gear_Catch(EndYear*12, NumFishingLinks+1); +// Annual output matrices + NumericMatrix annual_Catch(EndYear, NUM_BIO+1); + NumericMatrix annual_Biomass(EndYear, NUM_BIO+1); + NumericMatrix annual_QB(EndYear, NUM_BIO+1); + NumericMatrix annual_Qlink(EndYear, NumPredPreyLinks+1); + +// Load state and call initial derivative (todo: allow other start times) +// Use Clone to make sure state/stanzas are copies of instate/instanzas, not pointers + List state = clone(instate); + //List stanzas = clone(instanzas); + + // Update sums of split groups to total biomass for derivative calcs + if(Nsplit > 0){ + SplitSetPred(stanzas, state); + } + + // Use the initial derivative calculated outside of function + List dyt = InitDeriv; + + dd = StartYear * STEPS_PER_YEAR; + +// MAIN LOOP STARTS HERE +// ASSUMES STEPS_PER_MONTH will always be 1.0, took out divisions + for (y = StartYear; y <= EndYear; y++){ + if (y<1){stop("Adams Year can't be less than 1");} + // Monthly loop + for (m = 0; m < STEPS_PER_YEAR; m++){ + dd = (y-1) * STEPS_PER_YEAR + m; // dd is index for monthly output + // Load old state and old derivative + NumericVector old_Biomass = as(state["Biomass"]); + NumericVector old_Ftime = as(state["Ftime"]); + NumericVector dydt0 = as(dyt["DerivT"]); + NumericVector stanzaPred = as(state["StanzaPred"]); + + // Calculate new derivative + dyt = deriv_vector(params, state, forcing, fishing, stanzas, y, m, 0); + + // Extract needed parts of the derivative + NumericVector dydt1 = as(dyt["DerivT"]); + NumericVector FoodGain = as(dyt["FoodGain"]); + NumericVector biomeq = as(dyt["biomeq"]); + NumericVector FishingLoss = as(dyt["FishingLoss"]); + NumericVector Qlink = as(dyt["Qlink"]); + + // Now Update the new State Biomass using Adams-Basforth + NumericVector new_Biomass = + ifelse( NoIntegrate == 0, + (1.0 - SORWT) * biomeq + SORWT * old_Biomass, + ifelse( NoIntegrate > 0, + old_Biomass + (DELTA_T / 2.0) * (3.0 * dydt1 - dydt0), + old_Biomass)); + + // Then Update Foraging Time + NumericVector pd = ifelse(NoIntegrate < 0, stanzaPred, old_Biomass); + NumericVector new_Ftime = ifelse((FoodGain > 0) & (pd > 0), + 0.1 + 0.9 * old_Ftime * ((1.0 - FtimeAdj) + FtimeAdj * FtimeQBOpt / + (FoodGain / pd)), + old_Ftime); + + // Monthly Stanza (split pool) update + if(Nsplit > 0){ + SplitUpdate(stanzas, state, forcing, dyt, y, m + 1); + SplitSetPred(stanzas, state); + } + new_Biomass = ifelse(NoIntegrate < 0, as(state["Biomass"]), new_Biomass); + + // Calculate catch assuming fixed Frate and exponential biomass change. + // kya 9/10/15 - replaced with linear, diff on monthly scale is minor + NumericVector new_Catch = (DELTA_T * FishingLoss / old_Biomass) * + (new_Biomass + old_Biomass) / 2.0; + + // Track catch by gear + NumericVector old_Biomass_flink = as(old_Biomass[FishFrom]); + NumericVector new_Biomass_flink = as(new_Biomass[FishFrom]); + NumericVector GearCatch = as(dyt["GearCatch"]); + NumericVector new_Gear_Catch = (DELTA_T * GearCatch / old_Biomass_flink) * + (new_Biomass_flink + old_Biomass_flink)/2.0; + + // NumericVector new_Catch = + // ifelse( new_Biomass==old_Biomass, + // FishingLoss*DELTA_T, + // (FishingLoss*DELTA_T/old_Biomass) * + // (new_Biomass-old_Biomass)/log(new_Biomass/old_Biomass) + // ); + + // KYA 9/13/17 - noticed that cur_Biomass is never copied back into state["Biomass"] after + // bounds testing. Error? Moved state["Biomass"] setting, hopefully nothing breaks... + // Set state to new values, including min/max traps + //state["Biomass"] = pmax(pmin(new_Biomass, B_BaseRef * BIGNUM), B_BaseRef * EPSILON); + //state["Ftime"] = pmin(new_Ftime, 2.0); + + // Make a copy of the current state for bounds testing + NumericVector cur_Biomass = pmax(pmin(new_Biomass, B_BaseRef * BIGNUM), B_BaseRef * EPSILON); // as(state["Biomass"]); + + NumericVector bforce = force_bybio((y-1) * STEPS_PER_YEAR + m, _); + cur_Biomass = ifelse(bforce>B_BaseRef * EPSILON, bforce, cur_Biomass); + + // insert forced biomass levels + //for (i=0; i=0){cur_Biomass[sp]=BforceVal(sp,m);} */ + //} + + // KYA 8/9/17 one of the NA or NaN flags is reading back as a negative integer (-2^32) + // Not sure why. This sets any negative biomass (assuming this means NaN) to NA_REAL + cur_Biomass = ifelse((cur_Biomass<0),NA_REAL,cur_Biomass); + + // If the run is during the "burn-in" years, and biomass goes + // into the discard range, set flag to exit the loop. Should set "bad" + // biomass values to NA + if (y < BURN_YEARS){ cur_Biomass = ifelse((cur_BiomassB_BaseRef*HI_DISCARD), + NA_REAL,cur_Biomass); + } + + // If biomass goes crazy or hits NA, exit loop with crash signal. Note it + // should still write the NA or INF values back to the output. + //NOJUV make sure crash tests work for juveniles. + + if ( any(is_na(cur_Biomass)) | any(is_infinite(cur_Biomass)) | any(is_nan(cur_Biomass)) ) { + CRASH_YEAR = y; y = EndYear; m = STEPS_PER_YEAR; + } + + // KYA 9/13/17 - Now copy cur_Biomass into state + state["Biomass"] = cur_Biomass; + state["Ftime"] = pmin(new_Ftime, 2.0); + + // Write to output matricies + out_Biomass( dd, _) = old_Biomass; + out_SSB(dd, _) = old_Biomass; + out_rec(dd, _) = old_Biomass; + out_Catch( dd, _) = new_Catch; + out_Gear_Catch(dd, _) = new_Gear_Catch; + annual_Catch(y-1, _) = annual_Catch(y-1, _) + new_Catch; + if (m==MEASURE_MONTH){ + annual_Biomass(y-1, _) = old_Biomass; + annual_QB(y-1, _) = FoodGain/old_Biomass; + annual_Qlink(y-1, _) = Qlink; + } + + //NOJUV for (i = 1; i <= juv_N; i++){ + //NOJUV out_SSB(dd, JuvNum[i]) = 0.0; + //NOJUV out_SSB(dd, AduNum[i]) = SpawnBio[i]; + //NOJUV out_rec(dd, AduNum[i]) = NageS(firstMoAdu[i], i) * WageS(firstMoAdu[i], i); + + } // End of main months loop + + }// End of years loop + +// Write Last timestep + //out_Biomass( dd+1, _) = as(state["Biomass"]); + //out_SSB(dd+1, _) = as(state["Biomass"]); + //out_rec(dd+1, _) = as(state["Biomass"]); + //out_Catch( dd+1, _) = out_Catch( dd, _); // the "next" time interval + //out_Gear_Catch(dd+1, _) = out_Gear_Catch(dd, _); +//NOJUV for (i = 1; i <= juv_N; i++){ +//NOJUV out_SSB(dd, JuvNum[i]) = 0.0; +//NOJUV out_SSB(dd, AduNum[i]) = SpawnBio[i]; +//NOJUV out_rec(dd, AduNum[i]) = NageS(firstMoAdu[i], i) * WageS(firstMoAdu[i], i); +//NOJUV } + +// Create Rcpp list to output + List outdat = List::create( + _["out_Biomass"]=out_Biomass, + _["out_Catch"]=out_Catch, + _["out_Gear_Catch"]=out_Gear_Catch, + _["annual_Catch"]=annual_Catch, + _["annual_Biomass"]=annual_Biomass, + _["annual_QB"]=annual_QB, + _["annual_Qlink"]=annual_Qlink, + _["end_state"]=state, + _["crash_year"]=CRASH_YEAR, + _["dyt"]=dyt); + +// Return is an Rcpp List + return(outdat); + +} + +//################################################################---------- +// Main derivative (dB/dt) calculations for ecosim model, using Rcpp vector +// package. +// [[Rcpp::export]] +List deriv_vector(List params, List state, List forcing, List fishing, List stanzas, + int inyear, int m, double tt){ + +int sp, links, prey, pred, gr, egr, dest, isp, ist, ieco; + + //Rcout << inyear <<" "<< m << std::endl; + if (inyear<1){stop("Derivative Year can't be less than 1");} + +// forcing time index (in months) + // KYA 11/1/17 - added offset to deal with 0 vs 1 indexing in forcing files + // (matters when trying to line up with "acutal" years) + const int y = inyear - 1; + const int dd = y*STEPS_PER_YEAR+m; + +// Base model size - number of groups and number of links (flows) by type + const int NUM_GROUPS = as(params["NUM_GROUPS"]); + const int NUM_LIVING = as(params["NUM_LIVING"]); + const int NUM_DEAD = as(params["NUM_DEAD"]); + const int NumPredPreyLinks = as(params["NumPredPreyLinks"]); + const int NumFishingLinks = as(params["NumFishingLinks"]); + const int NumDetLinks = as(params["NumDetLinks"]); + const int COUPLED = as(params["COUPLED"]); + +// NUM_GROUPS length input vectors + const NumericVector B_BaseRef = as(params["B_BaseRef"]); + const NumericVector MzeroMort = as(params["MzeroMort"]); + const NumericVector UnassimRespFrac = as(params["UnassimRespFrac"]); + const NumericVector ActiveRespFrac = as(params["ActiveRespFrac"]); + const NumericVector HandleSelf = as(params["HandleSelf"]); + const NumericVector ScrambleSelf = as(params["ScrambleSelf"]); + //const NumericVector fish_Effort = as(params["fish_Effort"]); + +// NumPredPreyLinks Length vectors + const IntegerVector PreyFrom = as(params["PreyFrom"]); + const IntegerVector PreyTo = as(params["PreyTo"]); + const NumericVector QQ = as(params["QQ"]); + const NumericVector DD = as(params["DD"]); + const NumericVector VV = as(params["VV"]); + const NumericVector HandleSwitch = as(params["HandleSwitch"]); + const NumericVector PredPredWeight = as(params["PredPredWeight"]); + const NumericVector PreyPreyWeight = as(params["PreyPreyWeight"]); + +// NumFishingLinks lenghted vectors + const IntegerVector FishFrom = as(params["FishFrom"]); + const IntegerVector FishThrough = as(params["FishThrough"]); + const IntegerVector FishTo = as(params["FishTo"]); + const NumericVector FishQ = as(params["FishQ"]); + const IntegerVector DetFrom = as(params["DetFrom"]); + const IntegerVector DetTo = as(params["DetTo"]); + const NumericVector DetFrac = as(params["DetFrac"]); + +// Age-structured parameters + const int Nsplit = as(stanzas["Nsplit"]); + const NumericVector Nstanzas = as(stanzas["Nstanzas"]); + const NumericVector baseStanzaPred = as(stanzas["baseStanzaPred"]); + NumericMatrix EcopathCode = as(stanzas["EcopathCode"]); + +// State vectors + const NumericVector state_Biomass = as(state["Biomass"]); + const NumericVector state_Ftime = as(state["Ftime"]); + const NumericVector stanzaPred = as(state["StanzaPred"]); + +//FISHING NumericVector TerminalF = as(params["TerminalF"]); +//FISHING NumericVector TARGET_BIO = as(params["TARGET_BIO"]); +//FISHING NumericVector TARGET_F = as(params["TARGET_F"]); +//FISHING NumericVector ALPHA = as(params["ALPHA"]); + +// "Environmental" forcing matrices (dd-indexed month x species) +// SHOULD BE CONST, but no row extraction for CONST (per Rcpp issues wiki) + NumericMatrix force_byprey = as(forcing["ForcedPrey"]); + NumericMatrix force_bymort = as(forcing["ForcedMort"]); + NumericMatrix force_bysearch = as(forcing["ForcedSearch"]); + NumericMatrix force_bymigrate = as(forcing["ForcedMigrate"]); + NumericMatrix force_byactresp = as(forcing["ForcedActresp"]); + +// Fishing forcing matrices (indexed year x species) +// SHOULD BE CONST, but no row extraction for CONST (per Rcpp issues wiki) + NumericMatrix FORCED_FRATE = as(fishing["ForcedFRate"]); + NumericMatrix FORCED_CATCH = as(fishing["ForcedCatch"]); + NumericMatrix EffortMat = as(fishing["ForcedEffort"]); + +// Components of derivative calculated here + NumericVector TotGain(NUM_GROUPS+1); + NumericVector TotLoss(NUM_GROUPS+1); + NumericVector LossPropToB(NUM_GROUPS+1); + NumericVector LossPropToQ(NUM_GROUPS+1); + NumericVector DerivT(NUM_GROUPS+1); + NumericVector biomeq(NUM_GROUPS+1); + NumericVector FoodLoss(NUM_GROUPS+1); + NumericVector FoodGain(NUM_GROUPS+1); + NumericVector UnAssimLoss(NUM_GROUPS+1); + NumericVector ActiveRespLoss(NUM_GROUPS+1); + NumericVector DetritalGain(NUM_GROUPS+1); + NumericVector FishingGain(NUM_GROUPS+1); + NumericVector MzeroLoss(NUM_GROUPS+1); + NumericVector FishingLoss(NUM_GROUPS+1); + NumericVector DetritalLoss(NUM_GROUPS+1); + NumericVector FishingThru(NUM_GROUPS+1); + NumericVector PredSuite(NUM_GROUPS+1); + NumericVector HandleSuite(NUM_GROUPS+1); + NumericVector GearCatch(NumFishingLinks+1); + NumericVector MigrateLoss(NUM_GROUPS+1); + +// Set effective biomass for pred/prey response +// default is B/Bref + NumericVector preyYY = state_Ftime * state_Biomass/B_BaseRef * force_byprey(dd,_); + NumericVector predYY = state_Ftime * state_Biomass/B_BaseRef * force_bysearch(dd,_); + +// Set functional response biomass for juvenile and adult groups (including foraging time) + if(Nsplit > 0){ + for (isp = 1; isp <=Nsplit; isp++){ + for(ist = 1; ist <= Nstanzas[isp]; ist++){ + ieco = EcopathCode(isp, ist); + if (baseStanzaPred[ieco] > 0){ + predYY[ieco] = state_Ftime[ieco] * stanzaPred[ieco] / + baseStanzaPred[ieco]; + } + } + } + } + +// Unroll Biomass Vectors (match pred, prey biomass for all links) + NumericVector PYY = preyYY[PreyFrom]; + NumericVector PDY = predYY[PreyTo]; + +// Summed predator and prey suites for joint handling time and/or scramble functional response + for (links=1; links<=NumPredPreyLinks; links++){ + PredSuite[PreyFrom[links]] += predYY[PreyTo[links] ] * PredPredWeight[links]; + HandleSuite[PreyTo[links]] += preyYY[PreyFrom[links]] * PreyPreyWeight[links]; + } + +// Unroll the suites into a NumPredPrey length vector + NumericVector PdSuite = PredSuite[PreyFrom]; + NumericVector PySuite = HandleSuite[PreyTo]; + NumericVector Hself = HandleSelf[PreyTo]; + NumericVector Sself = ScrambleSelf[PreyTo]; + +// // Main VECTOR CALC to calculate functional response for each predator/prey link +// // (3) Additive version: primary used and published in Aydin (2004) +// // KYA 3/2/2012 setting "COUPLED" to zero means species are density dependent +// // (based on their own modul) but don't interact otherwise. This can magically +// // create and destroy energy in the system but makes them act like a set +// // of independent surplus production models for comparison purposes +// NON-VECTOR VERSION: +// Q = QQ[links] * predYY[pred] * pow(preyYY[prey], COUPLED * HandleSwitch[links]) * +// ( DD[links] / ( DD[links] - 1.0 + +// pow(HandleSelf[pred] * preyYY[prey] + +// (1. - HandleSelf[pred]) * HandleSuite[pred], +// COUPLED * HandleSwitch[links])) )* +// ( VV[links] / ( VV[links] - 1.0 + +// ScrambleSelf[pred] * predYY[pred] + +// (1. - ScrambleSelf[pred]) * PredSuite[prey]) ); +// Rcpp VECTOR VERSION + NumericVector Q1 = + QQ * PDY * vpow(PYY, HandleSwitch * COUPLED) * + ( DD / ( DD-1.0 + vpow((1.-Hself)*PYY + Hself*PySuite, COUPLED*HandleSwitch)) ) * + ( VV / ( VV-1.0 + (1.-Sself)*PDY + Sself*PdSuite) ); + Q1[0] = 1.0; // get rid of NaN - moved from KYA's code 6/12/17 + +// No vector solution here as we need to sum by both links and species + for (links=1; links<=NumPredPreyLinks; links++){ + prey = PreyFrom[links]; + pred = PreyTo[links]; + // If model is uncoupled, food loss doesn't change with prey or predator levels. + if (COUPLED){ FoodLoss[prey] += Q1[links]; } + else{ FoodLoss[prey] += state_Biomass[prey] * QQ[links]/B_BaseRef[prey]; } + FoodGain[pred] += Q1[links]; + } + +// By Species Rates + UnAssimLoss = FoodGain * UnassimRespFrac; + ActiveRespLoss = FoodGain * ActiveRespFrac * force_byactresp(dd,_); + MzeroLoss = MzeroMort * state_Biomass; + + + // Add mortality forcing + for (int i=1; i<=NUM_DEAD+NUM_LIVING; i++){ + FoodLoss[i] *= force_bymort(dd, i); + MzeroLoss[i] *= force_bymort(dd, i); + } + + // Add migration forcing + MigrateLoss = clone(state_Biomass); + for (int i=1; i<=NUM_DEAD+NUM_LIVING; i++){ + MigrateLoss[i] *= force_bymigrate(dd, i); + } + + NumericVector NetProd = FoodGain - UnAssimLoss - ActiveRespLoss - MzeroLoss - FoodLoss - MigrateLoss; + +// FISHING FUNCTIONS (multiple options depending on fishing method) + +// // MOST OF THE FOLLOWING FISHING SPECIFICATION METHODS ARE NOT SUPPORTED +// // BY THE R-CODE, only fishing by effort (for gear) or by F-rate (for +// // species) is supported at the end. +// // +// // BY CURRENT R-CODE. ONLY +// // RFISH for (gr=NUM_LIVING+NUM_DEAD+1; gr<=NUM_GROUPS; gr++){ +// // RFISH This sets EFFORT by time series of gear-target combinations +// // RFISH for (gr=NUM_LIVING+NUM_DEAD+1; gr<=NUM_GROUPS; gr++){ +// // RFISH if -1 is an input value, uses TERMINAL F (last non-negative F) +// //RFISH for (gr=NUM_LIVING+NUM_DEAD+1; gr<=NUM_GROUPS; gr++){ +// //RFISH if (y+m+d == 0){fish_Effort[gr]=1.0;} +// //RFISH else {fish_Effort[gr]=1.0;} // NOTE DEFAULT! THIS CAN BE CHANGED TO 1.0 +// //RFISH // Added 7/8/08 for forced effort +// //RFISH if (FORCED_EFFORT[gr][y] > -0.001) +// //RFISH {fish_Effort[gr]=FORCED_EFFORT[gr][y];} +// //RFISH +// //RFISH if ((FORCED_TARGET[gr]>0) && (FORCED_CATCH[gr][y]>-EPSILON)){ +// //RFISH totQ = 0.0; +// //RFISH sp = FORCED_TARGET[gr]; +// //RFISH for (links=1; links<=NumFishingLinks; links++){ +// //RFISH if ((FishingThrough[links] == gr) && +// //RFISH (FishingFrom[links]) == sp){ +// //RFISH totQ += FishingQ[links]; +// //RFISH } +// //RFISH } +// //RFISH fish_Effort[gr] = FORCED_CATCH[gr][y]/ +// //RFISH (totQ * state_Biomass[sp]); +// //RFISH if (FORCED_CATCH[gr][y] >= state_Biomass[sp]) +// //RFISH {fish_Effort[gr] = (1.0-EPSILON)*(state_Biomass[sp])/ +// //RFISH (totQ * state_Biomass[sp]);} +// //RFISH } +// //RFISH // By putting F after catch, Frates override absolute catch +// //RFISH if ((FORCED_FTARGET[gr]>0) && (FORCED_FRATE[gr][y]>-EPSILON)){ +// //RFISH totQ = 0.0; +// //RFISH sp = FORCED_FTARGET[gr]; +// //RFISH for (links=1; links<=NumFishingLinks; links++){ +// //RFISH if ((FishingThrough[links] == gr) && +// //RFISH (FishingFrom[links]) == sp){ +// //RFISH totQ += FishingQ[links]; +// //RFISH } +// //RFISH } +// //RFISH fish_Effort[gr] = FORCED_FRATE[gr][y]/totQ; +// //RFISH //if (FORCED_CATCH[gr][y] >= state_Biomass[sp]) +// //RFISH // {fish_Effort[gr] = (1.0-EPSILON)*(state_Biomass[sp])/ +// //RFISH // (totQ * state_Biomass[sp]);} +// //RFISH } +// //RFISH +// //RFISH //if ((y==0) && (m==0) && (d==0)){ +// //RFISH // cout << path_species[gr] << " " << FORCED_TARGET[gr] << " " << path_species[sp] << " " +// //RFISH // << state_Biomass[sp] << " " << FORCED_CATCH[gr][y] << " " +// //RFISH // << fish_Effort[gr] << endl; +// //RFISH //} +// //RFISH } +// + double caught; + // Apply specified Effort by Gear to catch (using Ecopath-set Q) + NumericVector Effort = (NumericVector)EffortMat(dd,_); + for (links=1; links<=NumFishingLinks; links++){ + prey = FishFrom[links]; + gr = FishThrough[links]; + dest = FishTo[links]; + egr = FishThrough[links] - (NUM_LIVING + NUM_DEAD); + caught = FishQ[links] * Effort[egr] * state_Biomass[prey]; + FishingLoss[prey] += caught; + FishingThru[gr] += caught; + FishingGain[dest] += caught; + GearCatch[links] = caught; + } + NumericVector FORCE_F = (NumericVector)FORCED_FRATE(y,_); + // Special "CLEAN" fisheries assuming q=1, so specified input is Frate + for (sp=1; sp<=NUM_LIVING+NUM_DEAD; sp++){ + caught = FORCED_CATCH(y, sp) + FORCE_F[sp] * state_Biomass[sp]; + // KYA Aug 2011 removed terminal effort option to allow negative fishing pressure + // if (caught <= -EPSILON) {caught = TerminalF[sp] * state_Biomass[sp];} + // KYA 10/6/17 Added productivity to Biomass limit for F>1 species (salmon inspired) + if (caught >= state_Biomass[sp] + NetProd[sp]){caught = (1.0 - EPSILON) * (state_Biomass[sp] + NetProd[sp]);} + if (caught<0){caught=0;} + FishingLoss[sp] += caught; + FishingThru[0] += caught; + FishingGain[0] += caught; + //if(sp==1){Rprintf("%d %g %g %g \n",sp,FORCED_FRATE(y,sp),caught,FishingLoss[sp]);} + //TerminalF[sp] = caught/state_Biomass[sp]; + } + +// KINKED CONTROL RULE - NEEDS INPUT of TARGET BIOMASS and TARGET CATCH + //FISHING double RefBio, maxcaught; + //FISHING for (sp=1; sp<=NUM_LIVING+NUM_DEAD; sp++){ + //FISHING if (TARGET_BIO[sp] > EPSILON){ + //FISHING RefBio = state_Biomass[sp] / TARGET_BIO[sp]; + //FISHING maxcaught = TARGET_F[sp] * state_Biomass[sp]; + //FISHING if (RefBio > 1.0) {caught = maxcaught;} + //FISHING else if (RefBio >= ALPHA[sp]) {caught = maxcaught * (RefBio - ALPHA[sp])/(1.0 - ALPHA[sp]);} + //FISHING else {caught = 0.0;} + //FISHING FishingLoss[sp] += caught; + //FISHING FishingThru[0] += caught; + //FISHING FishingGain[0] += caught; + //FISHING TerminalF[sp] = caught/state_Biomass[sp]; + //FISHING } + //FISHING } + +// DETRITUS - note: check interdetrital flow carefully, have had some issues +// (check by ensuring equlibrium run stays in equilibrium) + int liv, det; + double flow; + for (links=1; links<=NumDetLinks; links++){ + liv = DetFrom[links]; + det = DetTo[links]; + flow = DetFrac[links] * (MzeroLoss[liv] + UnAssimLoss[liv]); + DetritalGain[det] += flow; + if (liv > NUM_LIVING) {DetritalLoss[liv] += flow; } + } + for (sp=NUM_LIVING+1; sp<=NUM_LIVING+NUM_DEAD; sp++){ + MzeroLoss[sp] = 0.0; + } + + +// Sum up derivitive parts (vector sums) +// Override for group 0 (considered "the sun", never changing) + TotGain = FoodGain + DetritalGain + FishingGain; + LossPropToQ = UnAssimLoss + ActiveRespLoss; + LossPropToB = FoodLoss + MzeroLoss + FishingLoss + MigrateLoss + DetritalLoss; + TotGain[0] = 0; + LossPropToB[0] = 0; + LossPropToQ[0] = 0; + TotLoss = LossPropToQ + LossPropToB; + biomeq = TotGain/(TotLoss/state_Biomass); + biomeq[0] = 1.0; + DerivT = TotGain - TotLoss; + +// Rcpp List structure to return +// KYA 6/20/17 Rcpp bug (known) is max 18 items on List::create +// had to add Q1 (qlink), so removed LossPropToQ (used nowhere?) +// SML 8/8/17 - actually don't need most of these...commenting +// out to track catch by gear + List deriv = List::create( + //_["preyYY"]=preyYY, + //_["predYY"]=predYY, + _["TotGain"]=TotGain, + _["TotLoss"]=TotLoss, + _["DerivT"]=DerivT, + _["biomeq"]=biomeq, + _["LossPropToB"]=LossPropToB, + //_["LossPropToQ"]=LossPropToQ, + _["FoodLoss"]=FoodLoss, + _["FoodGain"]=FoodGain, + _["UnAssimLoss"]=UnAssimLoss, + _["ActiveRespLoss"]=ActiveRespLoss, + _["DetritalGain"]=DetritalGain, + _["FishingGain"]=FishingGain, + _["MzeroLoss"]=MzeroLoss, + _["FishingLoss"]=FishingLoss, + _["DetritalLoss"]=DetritalLoss, + _["FishingThru"]=FishingThru, + //_["PredSuite"]=PredSuite, + //_["HandleSuite"]=HandleSuite, + _["Qlink"]=Q1, + _["GearCatch"]=GearCatch + ); + +// Return is an Rcpp List + return(deriv); +} + +// SplitSetPred function called in sim stanza initialize and update +// This function simply sums up across stanzas to get population-level +// Biomass, Numbers, and Consumption +// [[Rcpp::export]] +int SplitSetPred(List stanzas, List state){ + int isp, ist, ia, ieco; + double Bt, pt, Nt; + + //stanza parameters + const int Nsplit = as(stanzas["Nsplit"]); + const NumericVector Nstanzas = as(stanzas["Nstanzas"]); + NumericMatrix Age1 = as(stanzas["Age1"]); + NumericMatrix Age2 = as(stanzas["Age2"]); + NumericMatrix EcopathCode = as(stanzas["EcopathCode"]); + //Parts of Stanza State + NumericMatrix NageS = as(state["NageS"]); + NumericMatrix WageS = as(state["WageS"]); + NumericMatrix QageS = as(state["QageS"]); + NumericVector stanzaPred = as(state["StanzaPred"]); + //state parameters + NumericVector state_Biomass = as(state["Biomass"]); + NumericVector state_N = as(state["N"]); + + for (isp = 1; isp <= Nsplit; isp++){ + for (ist = 1; ist <= Nstanzas[isp]; ist++){ + ieco = EcopathCode(isp, ist); + Bt = 1e-30; + pt = 1e-30; + Nt = 1e-30; + for (ia = Age1(isp, ist); ia <= Age2(isp, ist); ia++){ + Bt = Bt + NageS(ia, isp) * WageS(ia, isp); + pt = pt + NageS(ia, isp) * QageS(ia, isp); + Nt = Nt + NageS(ia, isp); + } + state_Biomass[ieco] = Bt; + state_N[ieco] = Nt; + stanzaPred[ieco] = pt; + } + } + return(0); +} + +// SplitUpdate function +// Update numbers, weight, and biomass for multistanza groups +// [[Rcpp::export]] +int SplitUpdate(List stanzas, List state, List forcing, List deriv, int yr, int mon){ + int isp, ist, ia, ieco=0, last, first; //KYA 6/12/17 ieco=0 to stop annoying warning + double Su, Gf, Nt; + + //stanza parameters + const int Nsplit = as(stanzas["Nsplit"]); + const NumericVector Nstanzas = as(stanzas["Nstanzas"]); + const NumericVector vBM = as(stanzas["vBM"]); + const NumericVector Wmat = as(stanzas["Wmat"]); + //const NumericVector Wmat001 = as(stanzas["Wmat001"]); + //const NumericVector Wmat50 = as(stanzas["Wmat50"]); + //const NumericVector WmatSpread = as(stanzas["WmatSpread"]); + //const NumericVector Amat001 = as(stanzas["Amat001"]); + //const NumericVector Amat50 = as(stanzas["Amat50"]); + //const NumericVector AmatSpread = as(stanzas["AmatSpread"]); + const NumericVector baseEggsStanza = as(stanzas["baseEggsStanza"]); + const NumericVector RscaleSplit = as(stanzas["RscaleSplit"]); + const NumericVector RzeroS = as(stanzas["RzeroS"]); + const NumericVector RecPower = as(stanzas["RecPower"]); + const NumericVector vBGFd = as(stanzas["vBGFd"]); + const NumericVector SpawnEnergy = as(stanzas["SpawnEnergy"]); + const NumericVector SpawnX = as(stanzas["SpawnX"]); + const NumericVector baseSpawnBio = as(stanzas["baseSpawnBio"]); + // The following matrices should also be const + NumericMatrix SplitAlpha = as(stanzas["SplitAlpha"]); + NumericMatrix Age1 = as(stanzas["Age1"]); + NumericMatrix Age2 = as(stanzas["Age2"]); + NumericMatrix EcopathCode = as(stanzas["EcopathCode"]); + // Parts of Stanza State + NumericVector SpawnBio = as(state["SpawnBio"]); + NumericVector EggsStanza = as(state["EggsStanza"]); + NumericMatrix NageS = as(state["NageS"]); + NumericMatrix WageS = as(state["WageS"]); + NumericMatrix QageS = as(state["QageS"]); + NumericVector stanzaPred = as(state["StanzaPred"]); + + //state parameters + const NumericVector state_Biomass = as(state["Biomass"]); + + //forcing parameters + NumericMatrix force_byrecs = as(forcing["ForcedRecs"]); + + //derivatives + const NumericVector LossPropToB = as(deriv["LossPropToB"]); + const NumericVector FoodGain = as(deriv["FoodGain"]); + + for (isp = 1; isp <= Nsplit; isp++){ + // Update numbers and body weights + SpawnBio[isp] = 0; + for(ist = 1; ist <= Nstanzas[isp]; ist++){ + ieco = EcopathCode(isp, ist); + Su = exp(-LossPropToB[ieco] / STEPS_PER_YEAR / state_Biomass[ieco]); + Gf = FoodGain[ieco] / stanzaPred[ieco]; + for(ia = Age1(isp, ist); ia <= Age2(isp, ist); ia++){ + NageS(ia, isp) = NageS(ia, isp) * Su; + WageS(ia, isp) = vBM[isp] * WageS(ia, isp) + Gf * SplitAlpha(ia, isp); + // KYA 5/7/18 - started to add alternate maturity method, commented out for now + //if(Wmat[isp]<0.0){ + // if ((WageS(ia, isp)>Wmat001[isp])&&(ia>Amat001[isp])){ + // SpawnBio[isp] += NageS(ia, isp) * WageS(ia, isp)/(1. + exp( + // -((WageS(ia, isp) - Wmat50[isp]) / WmatSpread[isp]) + // -((ia - Amat50[isp]) / AmatSpread[isp]) )); + // } + //} + //else{ + if(WageS(ia, isp) > Wmat[isp]){ + SpawnBio[isp] += NageS(ia, isp) * (WageS(ia, isp) - Wmat[isp]); + }; + //} + } + } + EggsStanza[isp] = SpawnBio[isp] * SpawnEnergy[isp] * SpawnX[isp] / + (SpawnX[isp] - 1.0 + (SpawnBio[isp] / baseSpawnBio[isp])); + EggsStanza[isp] *= force_byrecs(yr * STEPS_PER_YEAR + mon, ieco); + + //Rprintf("%g %g %g %g %g",isp,SpawnBio[isp],EggsStanza[isp],) + // Need to add monthly recruitment + + // now update n and wt looping backward over age + last = Age2(isp, Nstanzas[isp]); + first = Age1(isp, 1); + + Nt = NageS(last, isp) + NageS(last - 1, isp); + if(Nt == 0){Nt = 1e-30;} + + WageS(last, isp) = (WageS(last, isp) * NageS(last, isp) + WageS(last - 1, isp) * + NageS(last - 1, isp)) / Nt; + NageS(last, isp) = Nt; + + for(ia = last - 1; ia > first; ia--){ + NageS(ia, isp) = NageS(ia - 1, isp); + WageS(ia, isp) = WageS(ia - 1, isp); + } + + //Apply number of eggs to youngest slot. Includes Walter recruit power + if(baseEggsStanza[isp] > 0){ + NageS(first, isp) = RscaleSplit[isp] * RzeroS[isp] * pow(double(EggsStanza[isp] / + baseEggsStanza[isp]), double(RecPower[isp])); + } + WageS(first, isp) = 0; + + //Uses generalized vonB (exponent is d) + //Added for stability 4/13/07 (Unlucky Friday) + for(ia = 0; ia <= last; ia++){ + QageS(ia, isp) = pow(double(WageS(ia, isp)), double(vBGFd[isp])); + } + } + +return(0); } \ No newline at end of file