Description Usage Arguments Examples
Funciton for running all specified surveys of paper 1 of the PELFOSS project.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | runAllPelfossPaper1(
dir,
type = "Parallel",
run = type,
survey = "Herring_IESNS",
speedFact = 1,
condPar = NULL,
LcmMean = NULL,
b = NULL,
year = c(2010, 2012),
res = c(4, 10),
dateshift = c(-30, 0, 30),
reversed = c(FALSE, TRUE),
seed = 1,
nboot = 100,
radius = 10,
subset = "all",
cores = 1,
...
)
|
dir |
The directory of the PELFOSS folder structure (see |
type |
The survey design type (see |
run |
The name of the simulation run (which is three timings (-30, 0, +30 days), two directions (normal, reversed), and two resolutions (low, high), in total 12 individual runs). |
survey |
The name(s) of the survey(s) to run. Must be one or more of "Herring_IESNS", "Herring_NASSHS", "Herring_NASSHS_fishery", "Mackerel_IESSNS", "Mackerel_IESSNS_sept" and "Mackerel_IESSNS_sept_fishery", which are the surveys used in the Paper 1 of the PELFOSS project. |
speedFact |
A factor to speed the survey up or down by. Values larger than 1 speed up and values smaller than 1 slow down. |
condPar |
A vector of two elements giving the parameters a and b in the length-weight relationship Wg = a * Lcm^b, where Wg is the weight in grams and Lcm is the length in cm. Typical values are e.g., a = 0.01 and b = 3. If not set, this will be estimated from the super individuals, possibly inside a radius given as the second elements of |
LcmMean |
The typical length of the fish, representing the mean acoustic backscatter which refects the square of fish length. This can typically be estimated as sqrt(mean(L^2)). If not set, this will be estimated from the super individuals, possibly inside a radius given as the second elements of |
year, res, dateshift, reversed |
These parameters are linked to the folder structure specifide by |
seed |
A single integer, or a list of seeds used in the funciton, including the following seeds: ('transect') for drawing transects using surveyPlanner(), ('trawl') for drawing trawl stations along the transects with probability as a funciton of the NASC (see |
nboot |
Number of bootstrap replicates. |
radius |
A vector of one or two elements giving the radius inside which to sample trawl stations, and the radius inside which to estimate the parameters a, b and L in the length-weight relationship. If only one element is given, the length-weight relationship is estimated from all adult super individuals. |
subset |
Either "all" (the default) or an integer vector giving the subset of the simulations to run. |
cores |
The number of cores to use for writing XML files and for the bootstrapping in the StoX project, given either as a named list such as list(biotic=1, acoustic=1, bootstrap=1), og a single numeric setting the cores for all. |
... |
Additional inputs overriding the defaults returned by pelfossDefaults(). |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | ## Not run:
# Script for running experiments for Paper 1 in the PELFOSS project:
# The experiment requires the Rstox and pelfoss package to be installed (see https://github.com/Sea2Data/Rstox and https://github.com/Sea2Data/pelfoss for install instructions):
library(pelfoss)
library(Rstox)
# Define the directory in which to run the simulation experiments:
dir <- "~/Projects/PELFOSS"
# Download the simulation experiment folder to the experiment directory:
expermientURL <- ""
temp <- download.file(expermientURL, dir)
unzip(temp)
# Specify to use parallel transect lines:
type <- "Parallel"
# Specify the number of bootstrap replicates used in the variance estimation of the survey estimates:
nboot <- 100
# Define the year and resolution, and the shift by date and direction, which will constitute a grid in the function runAllPelfossPaper1():
year <- 2012
res <- 10
dateshift <- c(-30, 0, 30)
reversed <- c(FALSE, TRUE)
# Define the radius inside which the trawl stations are drawn:
radius <- 10
# Define the surveys to run:
survey = c(
"Herring_IESNS",
"Herring_NASSHS",
"Herring_NASSHS_fishery",
"Mackerel_IESSNS",
"Mackerel_IESSNS_sept",
"Mackerel_IESSNS_sept_fishery"
)
# Define the names of the
runs <- c(
"Parallel",
"Parallel_Fixed_abL",
"Parallel_Fixed_abL_SpeedTimes50"
)
# Run for seeds 1 and 2:
seeds <- c(1, 2)
# Write xml files and run boostrapping on multiple cores:
cores <- 8
################
##### Runs #####
################
############################################################
##### 1. Parallel, with with estimation of W0 and L0: ######
############################################################
for(seed %in% seeds){
Parallel_Fixed_abL <- runAllPelfossPaper1(
type=type, run=runs[1], survey=survey, dir=dir, # Paths and names
year=year, res=res, dateshift=dateshift, reversed=reversed, # spec
seed=seed, nboot=nboot, radius=radius, subset="all", cores=cores
)
}
############################################################
############################################################
##### 2. Parallel, with 'condPar' and 'LcmMean' fixed: #####
############################################################
for(seed %in% seeds){
Parallel_Fixed_abL <- runAllPelfossPaper1(
type=type, run=runs[2], survey=survey, dir=dir, # Paths and names
condPar=c(0.01, 3), LcmMean=30,
year=year, res=res, dateshift=dateshift, reversed=reversed, # spec
seed=seed, nboot=nboot, radius=radius, subset="all", cores=cores
)
}
############################################################
############################################################
##### 3. Parallel, with 'condPar' and 'LcmMean' fixed ######
############# and survey conducted on one day: #############
############################################################
for(seed %in% seeds){
Parallel_Fixed_abL <- runAllPelfossPaper1(
type=type, run=runs[3], survey=survey, dir=dir, # Paths and names
speedFact=50, condPar=c(0.01, 3), LcmMean=30,
year=year, res=res, dateshift=dateshift, reversed=reversed, # spec
seed=seed, nboot=nboot, radius=radius, subset="all", cores=cores
)
}
############################################################
###################
##### Reports #####
###################
# Get all reports (set copy = FALSE to speed up if rerunning this function):
reports <- lapply(runs, reportAllPelfoss, dir=dir, copy=TRUE)
names(reports) <- runs
# Show the parameters:
headPar <- lapply(runs, function(this) head(reports[[this]]$par))
names(headPar) <- runs
headPar
#################
##### Plots #####
#################
# Plots with ylim up ro 2.15:
temp <- lapply(runs, plotPelfossReports, dir = dir, by = "InsideAll", ylim = c(0, 2.15), subdir = "allPlots_max2.15_cv_allSeeds", case_adj = c(0.5, 0.95), add.cv = TRUE)
# Read the reports back in from the experiment referred to in the PELFOSS Paper 1:
run <- runs[2]
r <- readPelfossReports(run, dir=dir)
# Write a table for use in supplementary materials:
columnsToKeep <- c(
"Survey",
"Resolution",
"Year",
"Direction",
"Timing",
"Seed",
"TSB_meanByInsideAll",
"TSB_5percentByInsideAll",
"TSB_95percentByInsideAll",
"Ab.Sum.cv"
)
newNames <- c(
"Survey",
"Resolution",
"Year",
"Direction",
"Timing",
"Seed",
"TSB_mean",
"TSB_5percent",
"TSB_95percent",
"TSB_CV"
)
rsmall <- r[columnsToKeep]
names(rsmall) <- newNames
head(rsmall)
outfile <- file.path(dir, "runs", run, "reports", "AllSurveysReportsSmall.txt")
write.table(rsmall, file=outfile, sep="\t", dec=".", row.names=FALSE, fileEncoding="UTF-8")
#######################
##### Diagnostics #####
#######################
##### Absolute relative change from seed 1 to seed 2:
summary(abs(dd$TSB_mean[dd$Seed == 2] - dd$TSB_mean[dd$Seed == 1]) / dd$TSB_mean[dd$Seed == 1])
##### CVs for the 6 surveys:
surveys <- unique(dd$Survey)
CV <- sapply(surveys, function(x) summary(dd$TSB_CV[dd$Survey == x]))
colnames(CV) <- surveys
round(CV, digits=2)
# Herring_IESNS Herring_NASSHS Herring_NASSHS_fishery Mackerel_IESSNS Mackerel_IESSNS_sept Mackerel_IESSNS_sept_fishery
# Min. 0.12 0.02 0.01 0.08 0.08 0.05
# 1st Qu. 0.13 0.06 0.02 0.13 0.10 0.11
# Median 0.18 0.08 0.03 0.16 0.12 0.13
# Mean 0.18 0.08 0.04 0.15 0.22 0.18
# 3rd Qu. 0.21 0.09 0.04 0.18 0.38 0.29
# Max. 0.32 0.14 0.08 0.19 0.49 0.35
##### Average relative estimates for the Herring_NASSHS shifted by +30 days in the normal and reversed direction:
mean(dd$TSB_mean[dd$Survey == "Herring_NASSHS" & dd$Direction == "Normal" & dd$Timing == "30days"])
mean(dd$TSB_mean[dd$Survey == "Herring_NASSHS" & dd$Direction == "Reversed" & dd$Timing == "30days"])
##### The range of the relative estimates for Herring_NASSHS_fishery versus the other herring surveys:
# Herring_NASSHS:
valid <- dd$Survey == "Herring_NASSHS"
range_Herring_NASSHS <- range(dd$TSB_mean[valid])
range_Herring_NASSHS
diff(range_Herring_NASSHS) / mean(range_Herring_NASSHS)
# Herring_NASSHS_fishery:
valid <- dd$Survey == "Herring_NASSHS_fishery" & dd$Timing != "-30days"
range_Herring_NASSHS_fishery <- range(dd$TSB_mean[valid])
range_Herring_NASSHS_fishery
diff(range_Herring_NASSHS_fishery) / mean(range_Herring_NASSHS_fishery)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.