View source: R/00-mohawkHudsonRiverModel.R
mohawkHudsonRiverModel | R Documentation |
Dam passage performance standard model for Mohawk and Hudson rivers, NY, USA
mohawkHudsonRiverModel(
species = "shad",
pMohawk = 0,
nRuns = 1,
nYears = 40,
n_adults = 10000,
timing = rep(1, 26),
upstream = list(federal = 1, C01 = 1, C02 = 1, C03 = 1, C04 = 1, C05 = 1, C06 = 1, E02
= 1, E03 = 1, E04 = 1, E05 = 1, E06 = 1, E07 = 1, E08 = 1, E09 = 1, E10 = 1, E11 = 1,
E12 = 1, E13 = 1, E14 = 1, E15 = 1, E16 = 1, E17 = 1, E18 = 1, E19 = 1, E20 = 1),
downstream = list(federal = 1, C01 = 1, C02 = 1, C03 = 1, C04 = 1, C05 = 1, C06 = 1,
E02 = 1, E03 = 1, E04 = 1, E05 = 1, E06 = 1, E07 = 1, E08 = 1, E09 = 1, E10 = 1, E11
= 1, E12 = 1, E13 = 1, E14 = 1, E15 = 1, E16 = 1, E17 = 1, E18 = 1, E19 = 1, E20 = 1),
downstream_juv = list(federal = 1, C01 = 1, C02 = 1, C03 = 1, C04 = 1, C05 = 1, C06 =
1, E02 = 1, E03 = 1, E04 = 1, E05 = 1, E06 = 1, E07 = 1, E08 = 1, E09 = 1, E10 = 1,
E11 = 1, E12 = 1, E13 = 1, E14 = 1, E15 = 1, E16 = 1, E17 = 1, E18 = 1, E19 = 1, E20
= 1),
lockMortality = 0,
inRiverF = 0,
commercialF = 0,
bycatchF = 0,
indirect = 1,
latent = 1,
M = NULL,
watershed = FALSE,
k_method = "cumulative",
k_acre = 100,
sensitivity = FALSE,
spatially_explicit_output = FALSE,
output_years = NULL,
output_p_repeat = FALSE
)
species |
Species for which the model will be
run. Current options include American |
nRuns |
The number of times that the model will be run. |
nYears |
The number of years for which each run will last. The default is 40 years to match default FERC license duration. |
n_adults |
Number of starting adults in population. |
timing |
The amount of time required for upstream passage by individual fish (in days), where the default (1) indicates a 24-h dam passage performance standard and the value is specified as a proportion of 1 day. Values greater than 1 correspond to times greater than 24 h and values less than 1 correspond to times less than 24-h. |
upstream |
A named list of upstream dam passage efficiencies at each dam in the Hudson River and its largest tributary, the Mohawk River. Users may specify a single value of upstream passage at each dam, or a vector of upstream passage efficiencies at each dam. Note that passage efficiences passed as vectors are randomly sampled during each model run (not each year). Therefore, multiple model runs are necessary if more than one passage efficiency is supplied for any dam. As a rough rule of thumb we advise a minimum of 100 runs per combination of management parameters (upstream timing and passage, and downstream survival through dams). |
downstream |
A named list of downstream dam passage efficiencies at each dam in the Mohawk and Hudson rivers including navigational locks. |
downstream_juv |
A named list of downstream dam passage efficiencies at each dam in the Mohawk and Hudson rivers for juveniles. |
lockMortality |
Probability that a fish dies during upstream passage at each lock. A single value is applied to all locks. |
inRiverF |
Annual, recreational harvest in river. Parameterized as an annual rate [0, 1]. |
commercialF |
Commercial fishery mortality in marine environment incurred through targeted fisheries. Parameterized as an annual rate [0, 1]. |
bycatchF |
Marine bycatch mortality of species in non-target fisheries. Parameterized as an annual rate [0, 1]. Takes a single value and applies to all fully recruited age classes depending on species (blueback ages 3 through maxAge and shad ages 2 through max age) assuming knife-edge recruitment. |
indirect |
Indirect mortality incurred during freshwater migration as a result of dam-related impacts (e.g., injury, predation, etc.). |
latent |
Latent mortality incurred during estuary passage as a result of dam-related impacts (e.g., injury, delay, etc.). |
M |
Instantaneous natural mortality. |
watershed |
A logical indicating whether or not to use the same dam passage efficiencies at all dams for upstream and downstream. If watershed = TRUE, then the first element in lists 'upstream', 'downstream', and 'downstream_juv' are recycled for all subsequent dams. |
k_method |
Method used to impose carrying capacity. The default, 'cumulative', assumes that carrying capacity is based on all available habitat through the most upstream occupied production units in a given migration route. The alternative, 'discrete' assumes that carrying capacity is applied within discrete production units based on the numbers, and was the method used in Stich et al. (2019). |
k_acre |
Carrying capacity as number of adult fish per acre. |
sensitivity |
Whether to return a dataframe for sensitivity analysis. The default is set to FALSE for faster run time and smaller memory load in parallel processing. |
spatially_explicit_output |
Whether to return population size in each production unit. |
output_years |
Whether to return all years (default = 'NULL') or only final year of each simulation ('"last"'). |
output_p_repeat |
A logical indicating whether to return pRepeat by age (in years) with the output. The default value is 'FALSE' to limit output size in physical memory. |
Returns a dataframe when sensitivity = FALSE (default).
Returns a list of two named dataframes when sensitivity = TRUE.
The first dataframe (res
) contains user-defined
inputs and available model outputs depending on optional arguments.
The second dataframe (sens
) contains input variables for
sensitivity analysis if desired. If run in parallel, returns a list of
lists of dataframes.
The following named columns may be returned in res
:
year
Year of simulation
species
Species used for simulation
pMohawk
Probability of fish using the Mohawk River during upstream migration and spawning.
timing_federal...timing_E20
Passage timing input by user
federal_us...E20_us
User-specified upstream passage efficiencies
federal_ds...E20_ds
User-specified downstream passage efficiencies
federal_dsj...E20_dsj
User-specified juvenile downstream passage efficiencies
lockMortality
User-specified mortality during upstream passage of locks
F.inRiver
User-specified recreational fishing mortality
F.commercial
User-specified recreational fishing mortality
F.bycatch
User-specified recreational fishing mortality
indirect
User-specified indirect mortality dams
latent
User-specified latent mortality
pRepeat_Age1...pRepeat_AgeN
Age-specific probability of repeat spawning
N_1a...N21b
Production unit-specific population size after in-river fishery mortality
populationSize
Number of spawners returning to the river
The following named columns are returned in sens
:
S.downstream
Downstream survival per kilometer
S.marine
Marine survival as an annual rate
popStart
Starting population size
p.female
Probability of being female
S.prespawnM
Prespawn survival rate for males
S.postspawnM
Postspawn survival rate for males
S.prespawnF
Postspawn survival rate for males
S.postspawnF
Postspawn survival rate for males
S.juvenile
Hatch to out-migrant survival rate
b.Arr
Mean arrival date for males
r.Arr
Mean arrival date for females
ATUspawn1
Accumulated thermal units at initiation of spawn
ATUspawn2
Accumulated thermal units at termination of spawn
Dspawn1
Initial spawning date
Dspawn2
Terminal spawning date
linF
L-infinity parameter from the von Bertalanffy growth function for females
kF
K parameter from the von Bertalanffy growth function for females
t0F
t0 parameter from the von Bertalanffy growth function for females
linM
L-infinity parameter from the von Bertalanffy growth function for males
kM
K parameter from the von Bertalanffy growth function for males
t0M
t0 parameter from the von Bertalanffy growth function for males
b.length
Mean length of males
r.length
Mean length of females
spawnInt
Mean spawning interval
batchSize
Mean batch size
resTime
Mean residence time
s.Optim
Mean optimal ground speed
d.Max
Mean maximum daily movement rate
tortuosity
Path tortuosity parameter
motivation
Seasonal change in fish "motivation" for upstream movement
daily.move
Mean realized daily movement rate
habStoch
Habitat stochasticity
Production units delineated by dams in the watershed. Circles are log proportional to carrying capacity in each unit. Black dots indicate no suitable habitat in a unit.
Currently, internal functions rely on list2env
to return
lists to a temporary environment created in the
mohawkHudsonRiverModel
function. Consequently, lists
that are exported must be limited in size. Therefore,
users currently need to limit the number of runs per
call (nRuns
argument) to less than 10 or R will
hit memory limits quickly. In reality, serial
execution is prohibitively slow unless implemented
using manual parallel processing (e.g., bash scripting).
In order to achieve a desired number of runs for a given
set of inputs, the recommended approach is to use
parallel execution as demonstrated using the snowfall
package in the website examples.
# Parallel execution on a local cluster
## Not run:
# Load R packages
library(snowfall)
library(rlecuyer)
library(shadia)
library(tidyverse)
# Initialize parallel socket cluster
sfInit(parallel = TRUE, cpus = 7, type = "SOCK")
# Define a model run as a function
model <- function(x) {
# Run the model
sim <- mohawkHudsonRiverModel(nYears = 40, species = "blueback")
# Output
return(sim)
}
# Export libraries or data to workers
sfLibrary(shadia)
# Distribute calculation to workers
niterations <- 30
# Use sfLapply() to distribute simulations to workers
# and run the model with these settings in parallel
result <- sfLapply(1:niterations, model)
# Stop snowfall
Sys.time() - start
# Extract user inputs and population metrics
resdf <- do.call(rbind, result)
# . Abundance at mouth ----
library(tidyverse)
plotter <- resdf %>%
group_by(year) %>%
summarize(
pop = mean(populationSize),
lci = CI(populationSize)[1],
uci = CI(populationSize)[2],
.groups = "keep"
)
ggplot(plotter, aes(x = year, y = pop)) +
geom_line(lwd = 1) +
geom_ribbon(aes(x = year, ymin = lci, ymax = uci, color = NULL)) +
xlab("Year") +
ylab("Millions of spawners") +
scale_y_continuous(
breaks = seq(0, 10e7, .5e6),
labels = format(seq(0, 100, 0.5), digits = 2)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.