-
Notifications
You must be signed in to change notification settings - Fork 1
/
00_Explanatory_Figures.R
141 lines (103 loc) · 4.67 KB
/
00_Explanatory_Figures.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
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
# Explanatory figures
setwd("C:/Github/Ecotest/")
source("99_Indicators.R")
source("99_data_plots.R")
MMSE = readRDS("C:/temp/Ecotest/Batching/Independent_F/MMSE_1.rda")
nsim<-MMSE@nsim
nyears<-MMSE@nyears
proyears = MMSE@proyears
allyears = nyears+proyears
yrs = 2013+(-nyears+1):(proyears-1)
# --------- Time series data ---------------------------------------------------------------------------
sno = 1; fno = 1
dat = MMSE@PPD[[sno]][[1]][[1]]
Iobs<-dat@Ind
Cobs<-dat@Cat
CAL = dat@CAL
mids = dat@CAL_mids
matage = MMSE@multiHist[[sno]][[fno]]@AtAge$Maturity[,,1]
lenage = MMSE@multiHist[[sno]][[fno]]@AtAge$Length[,,1]
L50 = sapply(1:nsim,function(X,matage,lenage)approx(x=matage[X,],y=lenage[X,],xout=0.5)$y,matage=matage,lenage=lenage)
# Catches
jpeg("Figures/Presentation 1 April 24/Catch_explanatory.jpg",res=600,width=7,height=6,units="in")
simno = 4; x = Cobs[simno,]
par(mfrow=c(2,1),mai=c(0.5,0.5,0.05,0.05),omi=c(0,0.5,0,0))
exp_trend(x, Iyr=95, yrs, nyears,ylab="",relplot=T )
exp_trend(x, Iyr=95, yrs, nyears,ylab="",slpplot=T )
mtext("Catch",2,line=0.3,outer=T)
dev.off()
# CPUE
jpeg("Figures/Presentation 1 April 24/CPUE_explanatory.jpg",res=600,width=7,height=6,units="in")
simno = 4; x = Iobs[simno,]
par(mfrow=c(2,1),mai=c(0.5,0.5,0.05,0.05),omi=c(0,0.5,0,0))
exp_trend(x, Iyr=95, yrs, nyears,ylab="",relplot=T )
exp_trend(x, Iyr=95, yrs, nyears,ylab="",slpplot=T )
mtext("Nominal CPUE",2,line=0.3,outer=T)
dev.off()
# Mean length
jpeg("Figures/Presentation 1 April 24/ML_explanatory.jpg",res=600,width=7,height=6,units="in")
simno = 4;
CALi = CAL[simno,,]
totlen = CALi*t(array(mids,dim(t(CALi))))
x = apply(totlen,1,sum)/apply(CALi,1,sum)
par(mfrow=c(2,1),mai=c(0.5,0.5,0.05,0.05),omi=c(0,0.5,0,0))
exp_trend(x, Iyr=95, yrs, nyears,ylab="",relplot=T )
exp_trend(x, Iyr=95, yrs, nyears,ylab="",slpplot=T )
mtext("Mean length (cm)",2,line=0.3,outer=T)
dev.off()
# var length
jpeg("Figures/Presentation 1 April 24/varlen_explanatory.jpg",res=600,width=7,height=6,units="in")
simno = 4;
CALi = CAL[simno,,]
x = sapply(1:dim(CALi)[1],function(X,CALi,mids){
sd(rep(mids,CALi[X,]))/mean(rep(mids,CALi[X,]))
},CALi=CALi,mids=mids)
par(mfrow=c(2,1),mai=c(0.5,0.5,0.05,0.05),omi=c(0,0.5,0,0))
exp_trend(x, Iyr=95, yrs, nyears,ylab="",relplot=T )
exp_trend(x, Iyr=95, yrs, nyears,ylab="",slpplot=T )
mtext("Variability length (CV)",2,line=0.3,outer=T)
dev.off()
# Fraction matuire
jpeg("Figures/Presentation 1 April 24/fracmat_explanatory.jpg",res=600,width=7,height=6,units="in")
simno = 4;
CALi = CAL[simno,,]
L50i = L50[simno]
x = sapply(1:dim(CALi)[1],function(X,CALi,mids,L50i){
indivs = rep(mids,CALi[X,])
mean(indivs > L50i,na.rm=T)
},CALi=CALi,mids=mids,L50i=L50i)
par(mfrow=c(2,1),mai=c(0.5,0.5,0.05,0.05),omi=c(0,0.5,0,0))
exp_trend(x, Iyr=95, yrs, nyears,ylab="",relplot=T )
exp_trend(x, Iyr=95, yrs, nyears,ylab="",slpplot=T )
mtext("Fraction mature in catch",2,line=0.3,outer=T)
dev.off()
# --------- Catch ratios -----------------------------------------------------------------------------------
sno1 = 5; sno2 = 6; fno = 1; simno = 1; Iyr = 95; ind = 1:Iyr
Cobs1 = MMSE@PPD[[sno1]][[1]][[1]]@Cat[simno,]
Cobs2 = MMSE@PPD[[sno2]][[1]][[1]]@Cat[simno,]
Snames = sapply(MMSE@Snames,function(x)substr(x,1,3))
CS1 = smooth2(Cobs1)
CS2 = smooth2(Cobs2)
rat = CS1/CS2
jpeg("Figures/Presentation 1 April 24/catch_ratio_explanatory.jpg",res=600,width=8,height=6,units="in")
par(mfcol=c(3,2),mai=c(0.3,0.3,0.05,0.05),omi=c(0,0.5,0,0))
plot(yrs[ind],Cobs1[ind],ylim=c(0,quantile(Cobs1[ind],0.99)),col = "#99999999",pch=19,xlab="",ylab=""); grid()
lines(yrs[ind],CS1[ind],col="#ff000099",lwd=2); legend('topleft',Snames[sno1],text.col="#ff000099", bty="n")
mtext("Catch",2,line=2.5)
plot(yrs[ind],Cobs2[ind],ylim=c(0,quantile(Cobs2[ind],0.99)),col = "#99999999",pch=19,xlab="",ylab=""); grid()
lines(yrs[ind],CS2[ind],col="#0000ff99",lwd=2); legend('topleft',Snames[sno2],text.col="#0000ff99", bty="n")
mtext("Catch",2,line=2.5)
plot(yrs[ind],rat[ind],ylim=c(0,max(rat[ind])),type="l",col="purple",xlab="",ylab="",lwd=2); grid()
legend('topleft',legend=paste0("Catch ",Snames[sno1]," / Catch ",Snames[sno2]),text.col="purple",bty="n")
mtext("Catch ratio",2,line=2.5)
exp_trend(rat, Iyr=95, yrs, nyears,ylab="Catch ratio",relplot=T,pointcol='white',smoothcol="purple")
exp_trend(rat, Iyr=95, yrs, nyears,ylab="Catch ratio",slpplot=T,pointcol='white',smoothcol="purple")
exp_trend(rat, Iyr=95, yrs, nyears,ylab="Catch ratio",muplot=T,pointcol='white',smoothcol="purple")
dev.off()
nsim<-MMSE@nsim
nyears<-MMSE@nyears
proyears = MMSE@proyears
allyears = nyears+proyears
datlist<-list()
Iobs<-dat@Ind
Cobs<-dat@Cat