Script_CIEM.R 18.9 KB
Newer Older
matbuoro's avatar
matbuoro committed
1
2
rm(list=ls())   # Clear memory

matbuoro's avatar
matbuoro committed
3
4
5
6
7
8
# TO DO
# - Scorff: revoir les données de l année N-1 pour prendre en compte les bécards
# - Oir: vérifier les données adultes de l'année 1986' (différence capturés vs marqués NEGATIVE!!!)
# - Oir : demander les fecondités des 1SW et MSW à Fred
# - OIR: chercher les données de surface de production accessible aux spawners dans les données de juvéniles
# ' Bresle: vérifier tx fecondité et sex-ratio
matbuoro's avatar
matbuoro committed
9
10


matbuoro's avatar
matbuoro committed
11
12
13
14
15
16
year <- 2016




###################################################################################################################
matbuoro's avatar
matbuoro committed
17
######## Table 7 - Exploitation rate in the rivers Scorff ######
matbuoro's avatar
matbuoro committed
18
###################################################################################################################
matbuoro's avatar
matbuoro committed
19
20
21
22
23
24
25
26

## SCORFF
site <- "Scorff"
stade <- "adult"

# load dataset
load(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/Scorff/adult/data/data_',stade,"_",year,'.Rdata',sep="")) # chargement des données

matbuoro's avatar
matbuoro committed
27

matbuoro's avatar
matbuoro committed
28
29
30
31
32
## Cm_F[t,a]: Annual number of marked fish caught by fishing per sea age category and showed at Moulin des Princes. 1:1SW, 2:MSW  
## Cum_F[t,a]: Annual number of unmarked fish caught by fishing per sea age category and showed at Moulin des Princes. 1:1SW, 2:MSW
C_F_1SW <- data$Cm_F[,1] + data$Cum_F[,1] # marked + unmarked 1SW fish caugth by fishing
C_F_MSW <- data$Cm_F[,2] + data$Cum_F[,2] # marked + unmarked MSW fish caugth by fishing

matbuoro's avatar
matbuoro committed
33
34
35
36
37
# /!\ Annual number of fish caught by fishing per sea age category from 1994 to 2002 / Not all reported then
#data$C_F # 94 -> 2002
C_F_1SW[1:length(data$C_F[,1])] <- data$C_F[,1]
C_F_MSW[1:length(data$C_F[,2])] <- data$C_F[,2]

matbuoro's avatar
matbuoro committed
38
39
40
41
42
43
44
45
46
47
48
49
# load estimations of size popualtions
load("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/Scorff/adult/results/Results_adult_2016.RData")
n_1SW <- fit$median$n_1SW # medians
n_MSW <- fit$median$n_MSW # medians

Expl_rate <- cbind(
  Expl_rate_1SW = (C_F_1SW / n_1SW)*100,
  Expl_rate_MSW = (C_F_MSW / n_MSW)*100  
    )

Expl_rate <- rbind(Expl_rate,colMeans(Expl_rate))

matbuoro's avatar
matbuoro committed
50
rownames(Expl_rate) <- c(seq(1994,year,1), "Average")
matbuoro's avatar
matbuoro committed
51
52
colnames(Expl_rate) <- c("1SW (%)", "MSW (%)")

matbuoro's avatar
matbuoro committed
53
#write.csv(round(Expl_rate,1), file=paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table7_Scorff_',year,'.csv',sep=""))
matbuoro's avatar
matbuoro committed
54
55


matbuoro's avatar
matbuoro committed
56
57
58
59
con <- file(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table7_Scorff_',year,'.csv',sep=""), open="wt")
writeLines(paste("# Table 7 - Exploitation rate in the river Scorff - 1994-",year,")",sep=""), con)
write.csv( round(Expl_rate,1), con)
close(con)
matbuoro's avatar
matbuoro committed
60

matbuoro's avatar
matbuoro committed
61
62
63
64
65
66
67


###################################################################################################################
######## Table 8 - Index rivers :spawning stock, egg deposition and attainment of CLs ######
###################################################################################################################

##________________________NIVELLE (starting in 1984)
matbuoro's avatar
matbuoro committed
68
69
70
71
72
site <- "Nivelle"
stade <- "adult"

load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/Nivelle/adult/results/Results_adult_",year,".RData",sep=""))

matbuoro's avatar
matbuoro committed
73
years <- seq(1984, year, 1)
matbuoro's avatar
matbuoro committed
74
75
76
77
78
table <- array(, dim=c(length(years), 4))
colnames(table) <- c("1SW",	"MSW",		"eggs (million)",	"eggs/CL")
rownames(table) <- years

#Conservation Limit:
matbuoro's avatar
matbuoro committed
79
CL = 1.44 # A REVISER?
matbuoro's avatar
matbuoro committed
80

matbuoro's avatar
matbuoro committed
81
82
83
84
85
86
87
88
# Spawners:
table[,"1SW"] <- fit$median$e_1SW # spawners 1SW
table[,"MSW"] <- fit$median$e_MSW # spawners MSW

# Eggs
table[,"eggs (million)"] <- fit$median$eggs_tot / 1e6 # depose eggs
table[,"eggs/CL"] <- table[,"eggs (million)"] / CL

matbuoro's avatar
matbuoro committed
89
90
#write.csv(round(table,2), file=paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table8_',site,"_",year,'.csv',sep=""))
con <- file(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table8_',site,"_",year,'.csv',sep=""), open="wt")
matbuoro's avatar
matbuoro committed
91
writeLines(paste("# Table 8 - Index rivers :spawning stock and egg deposition and attainment of CLs -",site," (",year,")
matbuoro's avatar
matbuoro committed
92
93
94
95
                             CL = 1.44 (millions)
                 ",sep=""), con)
write.csv( round(table,2), con)
close(con)
matbuoro's avatar
matbuoro committed
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

##________________________ SCORFF (starting in 1994)
site <- "Scorff"
stade <- "adult"
nyear <- length(seq(1994,year,1))

load("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/Scorff/tacon/data/data_tacon_2016.Rdata") # DATA
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))

years <- seq(1984, year, 1)
table <- array(, dim=c(length(years), 4))
colnames(table) <- c("1SW",	"MSW",		"eggs (million)",	"eggs/CL")
rownames(table) <- years

# Spawners:
table[,"1SW"] <- c(rep(NA,10), fit$median$e_1SW) # spawners 1SW
table[,"MSW"] <- c(rep(NA,10),fit$median$e_MSW) # spawners MSW

# Eggs:
mcmc <- fit$sims.matrix
e_1SW.mcmc <- mcmc[,paste("e_1SW[",1:nyear,"]",sep="")]
e_MSW.mcmc <- mcmc[,paste("e_MSW[",1:nyear,"]",sep="")]

#Conservation Limit de taux de depose oeufs
CL = 300 # eggs/100m²


fec_1SW = 0.45 * 3485 # fecondité 1SW Female
fec_MSW = 0.80 * 5569 # fecondite MSW Female
eggs_tot.mcmc = e_1SW.mcmc * fec_1SW + e_MSW.mcmc * fec_MSW
eggs_tot <- apply(eggs_tot.mcmc,2,quantile, probs=0.5) #median

S_prod <- colSums(data$S_Sc) + 31 # surface de production juveniles accessible aux spawners / ajout de 31 pour tenir compte des affluents non proscptés
CL_eggs <- S_prod[2:(nyear+1)] * CL # /!\ data$S_Sc starts in 1993 instead of 1994

ratio_CL <- eggs_tot / CL_eggs
  
table[,"eggs (million)"] <- c(rep(NA,10),eggs_tot / 1e6) # depose eggs
table[,"eggs/CL"] <- c(rep(NA,10),ratio_CL)

matbuoro's avatar
matbuoro committed
136
137
#write.csv(round(table,2), file=paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table8_',site,"_",year,'.csv',sep=""))
con <- file(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table8_',site,"_",year,'.csv',sep=""), open="wt")
matbuoro's avatar
matbuoro committed
138
writeLines(paste("# Table 8 - Index rivers :spawning stock and egg deposition and attainment of CLs -",site," (",year,") 
139
                 CL = ",round(mean(CL_eggs/1e6),2)," (with 3 eggs/m²) /!\ revised from data in 2016 by Buoro & Prévost
matbuoro's avatar
matbuoro committed
140
141
142
                 ",sep=""), con)
write.csv( round(table,2), con)
close(con)
matbuoro's avatar
matbuoro committed
143
144


matbuoro's avatar
matbuoro committed
145
146
147
148
149
##_______________________________ OIR (starting in 1984)
site <- "Oir"
stade <- "adult"
nyear <- length(seq(1984,year,1))

matbuoro's avatar
matbuoro committed
150
#load("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/data/data_",stade,"_",year,".RData",sep="")) # DATA
matbuoro's avatar
matbuoro committed
151
152
153
154
155
156
157
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))


# /!\ regarder difference capturés - marqués (data$C_MC - data$Cm_MC)-> nombre negatif en 1986!!!!
# retirer les individus non marqués des effectifs estimés n (n - (data$C_MC - data$Cm_MC))

years <- seq(1984, year, 1)
matbuoro's avatar
matbuoro committed
158
nyear <- length(years)
matbuoro's avatar
matbuoro committed
159
160
161
162
163
164
165
166
167
168
table <- array(, dim=c(length(years), 4))
colnames(table) <- c("1SW",	"MSW",		"eggs (million)",	"eggs/CL")
rownames(table) <- years

# Spawners:
table[,"1SW"] <- fit$median$Nesc_1SW # spawners 1SW
table[,"MSW"] <- fit$median$Nesc_MSW # spawners MSW

# Eggs:
mcmc <- fit$sims.matrix
matbuoro's avatar
matbuoro committed
169
170
e_1SW.mcmc <- mcmc[,paste("Nesc_1SW[",1:nyear,"]",sep="")] # female only
e_MSW.mcmc <- mcmc[,paste("Nesc_MSW[",1:nyear,"]",sep="")] # female only
matbuoro's avatar
matbuoro committed
171

matbuoro's avatar
matbuoro committed
172
173
174
175
176
177
178
179
prop.female <- read.csv(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/data/prop-female.csv",sep=""))
fec_1SW = prop.female[,2] * 4635 # fecondité 1SW # Prevost 1996
fec_MSW = prop.female[,3] * 7965 # fecondite MSW # prevost 1996

eggs_tot.mcmc <- array(,dim=dim(e_1SW.mcmc))
for (i in 1:dim(mcmc)[1]){
eggs_tot.mcmc[i,] = e_1SW.mcmc[i,] * fec_1SW + e_MSW.mcmc[i,] * fec_MSW
}
matbuoro's avatar
matbuoro committed
180
181
182
eggs_tot <- apply(eggs_tot.mcmc,2,quantile, probs=0.5) #median

# calculs basés sur la conservation limit des tableaux CIEM!! A REFAIRE à partir des données MAIS
matbuoro's avatar
matbuoro committed
183
#/!\ chercher les données de surface de production dans les données de juvéniles
matbuoro's avatar
matbuoro committed
184
#Conservation Limit de taux de depose oeufs
185
186
187
188
# CL = 3 # eggs/m²
# S_prod <- rep(26714,length(years)) # surface de production juveniles accessible aux spawners / pas de variation depuis le debut du suivi
# CL_eggs <- S_prod * CL # /!\ data$S_Sc starts in 1993 instead of 1994
CL_eggs <- 0.12 # extracted from table 8 CIEM
matbuoro's avatar
matbuoro committed
189
190

#Conservation Limit de taux de depose oeufs
matbuoro's avatar
matbuoro committed
191
#CL_eggs = 0.12 # issue des tableaux CIEM, A REVOIR!!!
192
ratio_CL <- eggs_tot / (CL_eggs * 1e6)
matbuoro's avatar
matbuoro committed
193
194
195
196

table[,"eggs (million)"] <- eggs_tot / 1e6 # depose eggs
table[,"eggs/CL"] <- ratio_CL

matbuoro's avatar
matbuoro committed
197
198
#write.csv(round(table,2), file=paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table8_',site,"_",year,'.csv',sep=""))
con <- file(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table8_',site,"_",year,'.csv',sep=""), open="wt")
matbuoro's avatar
matbuoro committed
199
writeLines(paste("# Table 8 - Index rivers :spawning stock and egg deposition and attainment of CLs -",site," (",year,") 
200
                                  CL =",CL_eggs,"
matbuoro's avatar
matbuoro committed
201
202
203
                 ",sep=""), con)
write.csv( round(table,2), con)
close(con)
matbuoro's avatar
matbuoro committed
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226



##_______________________________ BRESLE (starting in 1984)
site <- "Bresle"
stade <- "adult"
nyear <- length(seq(1984,year,1))

load("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/Bresle/adult/data/data_adult_2016.Rdata") # DATA
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))


# /!\ regarder difference capturés - marqués (data$C_MC - data$Cm_MC)-> nombre negatif en 1986!!!!
# retirer les individus non marqués des effectifs estimés n (n - (data$C_MC - data$Cm_MC))

years <- seq(1984, year, 1)
table <- array(, dim=c(length(years), 4))
colnames(table) <- c("1SW",	"MSW",		"eggs (million)",	"eggs/CL")
rownames(table) <- years

# Spawners:
table[,"1SW"] <- fit$median$n_1SW # spawners 1SW
table[,"MSW"] <- fit$median$n_MSW # spawners MSW
matbuoro's avatar
matbuoro committed
227

matbuoro's avatar
matbuoro committed
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# Eggs:
mcmc <- fit$sims.matrix
e_1SW.mcmc <- mcmc[,paste("n_1SW[",1:nyear,"]",sep="")] # female only
e_MSW.mcmc <- mcmc[,paste("n_MSW[",1:nyear,"]",sep="")] # female only


#S_prod <- colSums(data$S_Sc) # surface de production juveniles accessible aux spawners 
#CL_eggs <- S_prod[2:(nyear+1)] * CL 

fec_1SW = 0.45 * 3485 # fecondité 1SW Female # A REVOIR
fec_MSW = 0.80 * 5569 # fecondite MSW Female # A REVOIR
eggs_tot.mcmc = e_1SW.mcmc * fec_1SW + e_MSW.mcmc * fec_MSW
eggs_tot <- apply(eggs_tot.mcmc,2,quantile, probs=0.5) #median

# calculs basés sur la conservation limit des tableaux CIEM!! A REFAIRE à partir des données MAIS
#/!\ chercher les données de surface d eproduction dans les données de juvéniles

#Conservation Limit de taux de depose oeufs
246
247
CL_eggs = 0.36 # issue des tableaux CIEM, A REVOIR?
ratio_CL <- eggs_tot / (CL_eggs * 1e6)
matbuoro's avatar
matbuoro committed
248
249
250
251

table[,"eggs (million)"] <- eggs_tot / 1e6 # depose eggs
table[,"eggs/CL"] <- ratio_CL

matbuoro's avatar
matbuoro committed
252
253
#write.csv(round(table,2), file=paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table8_',site,"_",year,'.csv',sep=""))
con <- file(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table8_',site,"_",year,'.csv',sep=""), open="wt")
matbuoro's avatar
matbuoro committed
254
writeLines(paste("# Table 8 - Index rivers :spawning stock and egg deposition and attainment of CLs -",site," (",year,") 
matbuoro's avatar
matbuoro committed
255
                                  CL =",CL_eggs,"
matbuoro's avatar
matbuoro committed
256
                 ",sep=""), con)
matbuoro's avatar
matbuoro committed
257
258
write.csv( round(table,2), con)
close(con)
matbuoro's avatar
matbuoro committed
259
260
261
262
263




###################################################################################################################
matbuoro's avatar
matbuoro committed
264
######## Table 9 - juvenile and adult salmon  numbers (estim.), in-river return rate in the monitored rivers ######
matbuoro's avatar
matbuoro committed
265
266
267
268
269
270
271
272
273
274
###################################################################################################################

# Nota : juvenile fish are smolts, except in r. Nivelle (parrs O+). Adult numbers refer to the smolt year N: runs of N+1 and N+2 


##________________________NIVELLE (starting in 1984)
site <- "Nivelle"

years <- seq(1984, year, 1)
table <- array(, dim=c(length(years), 4))
matbuoro's avatar
matbuoro committed
275
colnames(table) <- c( "PARR 0+ year","0+ parr", 	"adults",	"survival rate (%)")
matbuoro's avatar
matbuoro committed
276
rownames(table) <- years
matbuoro's avatar
matbuoro committed
277
278
#smolt.years <- years+1
table[,1] <- years #smolt.years
matbuoro's avatar
matbuoro committed
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
  
## JUVENILES
stade <- "tacon"
#load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/Nivelle/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))
YOY_tot_q <- read.table(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/Nivelle/",stade,"/results/YOY_tot.txt",sep=""), header = TRUE)
table[,2] <- YOY_tot_q[,"q0.5"]

## ADULTS
stade <- "adult"
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/Nivelle/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))
n_1SW <- fit$median$n_1SW # spawners 1SW
n_MSW <- fit$median$n_MSW # spawners MSW

for (y in 1:(nrow(table))){
table[y,3] <- n_1SW[y+2] + n_MSW[y+3] # Parr 0+ become 1SW 2 years later / MSW 3 years later; /!\ NA reported if one of the two is missing!!!
}

## SURVIVAL
table[,4] <- (table[,3] / table[,2])*100

matbuoro's avatar
matbuoro committed
299
300
301
#write.csv(round(table,2), file=paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table9_',site,"_",year,'.csv',sep=""))
con <- file(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table9_',site,"_",year,'.csv',sep=""), open="wt")
writeLines(paste("# Table 9 - juvenile and adult salmon  numbers (estim.) in-river return rate in the monitored rivers - ",site," (",year,")
matbuoro's avatar
matbuoro committed
302
                  Nota : juvenile fish are smolts except in r. Nivelle which are parrs O+ (cohort parr 0+ = smolt.years -1). 
matbuoro's avatar
matbuoro committed
303
304
305
306
                  Adult numbers refer to the smolt year N: runs of N+1 and N+2
                  These are estimated trap-return numbers of wild fish except in 94-95 years in Nivelle when some stocked fish returned. 
                 Stocking is considered to adjust numbers"
                  ,sep=""), con)
matbuoro's avatar
matbuoro committed
307
write.csv( round(table,2), con, row.names = FALSE)
matbuoro's avatar
matbuoro committed
308
close(con)
matbuoro's avatar
matbuoro committed
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338


##________________________OIR (starting in 1984)
site <- "Oir"

years <- seq(1984, year, 1)
table <- array(, dim=c(length(years), 4))
colnames(table) <- c( "smolt year","smolt", 	"adults",	"survival rate (%)")
rownames(table) <- years
smolt.years <- years
table[,1] <- smolt.years

## JUVENILES
stade <- "smolt"
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))
table[,2] <- c(NA,NA,fit$median$Nesc) # capture of smolts started in 1986

## ADULTS
stade <- "adult"
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))
n_1SW <- fit$median$Nesc_1SW # spawners 1SW
n_MSW <- fit$median$Nesc_MSW # spawners MSW

for (y in 1:(nrow(table))){
  table[y,3] <- n_1SW[y+1] + n_MSW[y+2] # Smolt 1+ become 1SW 1 years later / MSW 2 years later; /!\ NA reported if one of the two is missing!!!
}

## SURVIVAL
table[,4] <- (table[,3] / table[,2])*100 

matbuoro's avatar
matbuoro committed
339
340
341
#write.csv(round(table,2), file=paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table9_',site,"_",year,'.csv',sep=""))
con <- file(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table9_',site,"_",year,'.csv',sep=""), open="wt")
writeLines(paste("# Table 9 - juvenile and adult salmon  numbers (estim.) in-river return rate in the monitored rivers - ",site," (",year,")
matbuoro's avatar
matbuoro committed
342
                  Nota : juvenile fish are smolts except in r. Nivelle which are parrs O+ (cohort parr 0+ = smolt.years -1). 
matbuoro's avatar
matbuoro committed
343
344
345
346
                  Adult numbers refer to the smolt year N: runs of N+1 and N+2
                  These are estimated trap-return numbers of wild fish except in 94-95 years in Nivelle when some stocked fish returned. 
                 Stocking is considered to adjust numbers"
                 ,sep=""), con)
matbuoro's avatar
matbuoro committed
347
write.csv( round(table,2), con, row.names = FALSE)
matbuoro's avatar
matbuoro committed
348
close(con)
matbuoro's avatar
matbuoro committed
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381

##________________________BRESLE (starting in 1984)
site <- "Bresle"

years <- seq(1982, year, 1)
table <- array(, dim=c(length(years), 4))
colnames(table) <- c( "smolt year","smolt", 	"adults",	"survival rate (%)")
rownames(table) <- years
smolt.years <- years
table[,1] <- smolt.years

## JUVENILES (1982 to now ; # /!\ NO CAPTURE IN 1988 to 1991 & 2001)
stade <- "smolt"
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))
Nesc <- fit$median$Nesc # escapement from river
table[1:6,2] <- Nesc[1:6] # 1982 to 1987
table[11:19,2] <- Nesc[7:15] # 1992 to 2000
table[21:nrow(table),2] <- Nesc[16:length(Nesc)] # 2002 to now


## ADULTS (1984 to now)
stade <- "adult"
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))
n_1SW <- c(NA,NA,fit$median$n_1SW) # spawners 1SW
n_MSW <- c(NA,NA,fit$median$n_MSW) # spawners MSW

for (y in 1:(nrow(table))){
  table[y,3] <- n_1SW[y+1] + n_MSW[y+2] # Smolt 1+ become 1SW 1 years later / MSW 2 years later; /!\ NA reported if one of the two is missing!!!
}

## SURVIVAL
table[,4] <- (table[,3] / table[,2])*100 

matbuoro's avatar
matbuoro committed
382
383
384
#write.csv(round(table,2), file=paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table9_',site,"_",year,'.csv',sep=""))
con <- file(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table9_',site,"_",year,'.csv',sep=""), open="wt")
writeLines(paste("# Table 9 - juvenile and adult salmon  numbers (estim.) in-river return rate in the monitored rivers - ",site," (",year,")
matbuoro's avatar
matbuoro committed
385
                  Nota : juvenile fish are smolts except in r. Nivelle which are parrs O+ (cohort parr 0+ = smolt.years -1). 
matbuoro's avatar
matbuoro committed
386
387
388
389
                  Adult numbers refer to the smolt year N: runs of N+1 and N+2
                  These are estimated trap-return numbers of wild fish except in 94-95 years in Nivelle when some stocked fish returned. 
                 Stocking is considered to adjust numbers"
                 ,sep=""), con)
matbuoro's avatar
matbuoro committed
390
write.csv( round(table,2), con, row.names = FALSE)
matbuoro's avatar
matbuoro committed
391
close(con)
matbuoro's avatar
matbuoro committed
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420


##________________________SCORFF (starting in 1994)
site <- "Scorff"

years <- seq(1984, year, 1)
table <- array(, dim=c(length(years), 4))
colnames(table) <- c( "smolt year","smolt", 	"adults",	"survival rate (%)")
rownames(table) <- years
smolt.years <- years
table[,1] <- smolt.years

## JUVENILES from 1995 to now on
stade <- "smolt"
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))
Nesc <- fit$median$Nesc # escapement from river
table[12:nrow(table),2] <- Nesc # 1995 to now



## ADULTS (1984 to now)
stade <- "adult"
load(paste("~/Documents/RESEARCH/PROJECTS/ORE/Abundance/",site,"/",stade,"/results/Results_",stade,"_",year,".RData",sep=""))
n_1SW <- c(rep(NA,10), fit$median$e_1SW) # spawners 1SW
n_MSW <- c(rep(NA,10),fit$median$e_MSW) # spawners MSW

for (y in 1:(nrow(table))){
  table[y,3] <- n_1SW[y+1] + n_MSW[y+2] # Smolt 1+ become 1SW 1 years later / MSW 2 years later; /!\ NA reported if one of the two is missing!!!
}
matbuoro's avatar
matbuoro committed
421

matbuoro's avatar
matbuoro committed
422
423
## SURVIVAL
table[,4] <- (table[,3] / table[,2])*100 
matbuoro's avatar
matbuoro committed
424

matbuoro's avatar
matbuoro committed
425
426
427
#write.csv(round(table,2), file=paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table9_',site,"_",year,'.csv',sep=""))
con <- file(paste('~/Documents/RESEARCH/PROJECTS/ORE/Abundance/CIEM/Table9_',site,"_",year,'.csv',sep=""), open="wt")
writeLines(paste("# Table 9 - juvenile and adult salmon  numbers (estim.) in-river return rate in the monitored rivers - ",site," (",year,")
matbuoro's avatar
matbuoro committed
428
                  Nota : juvenile fish are smolts except in r. Nivelle which are parrs O+ (cohort parr 0+ = smolt.years -1). 
matbuoro's avatar
matbuoro committed
429
430
431
432
                  Adult numbers refer to the smolt year N: runs of N+1 and N+2
                  These are estimated trap-return numbers of wild fish except in 94-95 years in Nivelle when some stocked fish returned. 
                 Stocking is considered to adjust numbers"
                 ,sep=""), con)
matbuoro's avatar
matbuoro committed
433
434
write.csv( round(table,2), con, row.names = FALSE)
close(con)