-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata.R
60 lines (51 loc) · 1.95 KB
/
data.R
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
## Preprocess data, write TAF data tables
## Before: PLE7DFleet_2016.txt, stockobject.RData (bootstrap/data)
## After: assess.dat, datage.csv, input.RData, latage.csv, survey_fr.csv,
## survey_uk.csv, wdiscards.csv, wlandings.csv, wstock.csv (data)
library(icesTAF)
suppressMessages(library(FLAssess))
library(splines)
suppressMessages(library(mgcv))
library(methods)
source("utilities.R")
mkdir("data")
## Get stock data
load("bootstrap/data/stockobject.RData")
range(stock)["minfbar"] <- 3
range(stock)["maxfbar"] <- 6
stock <- trim(stock, age=1:10)
[email protected] <- [email protected] # temporary, to setPlusGroup weights
stock <- setPlusGroup(stock, 7)
## Get survey data
indices <- readFLIndices("bootstrap/data/PLE7DFleet_2016.txt", na.strings="-1")
indices <- FLIndices(indices[[1]], trim(indices[[2]], age=1:6))
## Extract tables
latage <- flr2taf([email protected])
wlandings <- flr2taf([email protected]); wlandings[wlandings==0] <- NA
datage <- flr2taf([email protected])
wdiscards <- flr2taf([email protected]); wdiscards[wdiscards==0] <- NA
wstock <- flr2taf([email protected]); wstock[wstock==0] <- NA
survey.uk <- flr2taf(indices[[1]]@index)
survey.fr <- flr2taf(indices[[2]]@index)
## Rename plus group
latage <- plus(latage)
wlandings <- plus(wlandings)
datage <- plus(datage)
wdiscards <- plus(wdiscards)
wstock <- plus(wstock)
## Write tables to data directory
setwd("data")
write.taf(latage) # 2.3.1
write.taf(wlandings) # 2.3.2
write.taf(datage) # 2.3.3
write.taf(wdiscards) # 2.3.4
write.taf(wstock) # 2.3.5
write.taf(survey.uk) # 2.6.1a
write.taf(survey.fr) # 2.6.1b
setwd("..")
## Write model input files
control <- FLAAP.control(pGrp=1, qplat.surveys=5, qplat.Fmatrix=6, Fage.knots=4,
Ftime.knots=14, Wtime.knots=5, mcmc=FALSE)
path <- "data" # required inside assessment() function
suppressWarnings(assessment(stock, indices, control, input=TRUE, model=FALSE))
save(control, indices, stock, file="data/input.RData")