Commit 60c957cd authored by Poulet Camille's avatar Poulet Camille
Browse files

Upload files for script source

parent 0a9161c8
#read the XML file to upload the set of parameters included in GR3D-US
fishXML <- xmlToList(xmlParse("../../data/input/northeastamerica/fishRIOBasin_Sapidissima.xml"))
#Upload parameters linked to reproduction
reproducePar = data.frame(t(unlist(fishXML[[1]][["processes"]][["processesEachStep"]][["species.ReproduceAndSurviveAfterReproductionWithDiagnose"]]))) %>%
select(-c(synchronisationMode, reproductionSeason, proportionOfFemaleAtBirth,
sigmaRecruitment, maxNumberOfSuperIndividualPerReproduction, withDiagnose,
displayFluxesOnConsole)) %>%
rename("TminRep" = "tempMinRep",
"ToptRep" = "tempOptRep",
"TmaxRep" = "tempMaxRep",
"ratioS95_S50" = "ratioS95__S50",
"deltaT" = "delta__t") %>%
mutate_all(~as.numeric(as.character(.)))
#Upload parameters linked to survival in river
survivePar = data.frame(t(unlist(fishXML[[1]][["processes"]][["processesEachStep"]][["species.Survive"]]))) %>%
select(-synchronisationMode) %>%
rename("TminSurv" = "tempMinSurvivalSpawnerInRiv",
"ToptSurv" = "tempOptSurvivalSpawnerInRiv",
"TmaxSurv" = "tempMaxSurvivalSpawnerInRiv",
"survProbOptRiver" = "survivalProbOptSpawnerInRiv") %>%
mutate_all(~as.numeric(as.character(.)))
#Upload parameters linked to growth at sea
growPar = data.frame(t(unlist(fishXML[[1]][["processes"]][["processesEachStep"]][["species.Grow"]]))) %>%
select(-synchronisationMode ) %>%
mutate(linfVonBertForMale = fishXML[[1]][["linfVonBertForMale"]],
linfVonBertForFemale = fishXML[[1]][["linfVonBertForFemale"]],
lengthAtHatching = fishXML[[1]][["lengthAtHatching"]],
lFirstMaturityForMale = fishXML[[1]][["lFirstMaturityForMale"]],
lFirstMaturityForFemale = fishXML[[1]][["lFirstMaturityForFemale"]]) %>%
mutate_all(~as.numeric(as.character(.)))
#-------------------------------------
#Read and upload environmental data
#-------------------------------------
#---------Temperature ----------------
#temperature in river basins
tempInriver <- read_csv("../../data/input/northeastamerica/observed_river_temperatures.csv")
#temperature in inshore basins
tempInInshore <- read_csv("../../data/input/northeastamerica/observed_inshore_temperatures.csv")
#temperature in offshore basins
tempInOffshore <- read_csv("../../data/input/northeastamerica/observed_offshore_temperatures.csv")
#connections between inshore and offshore
#---------Characteristic----------------
#characteristics of the river basins
nea_riverbasin_features <- read_csv("../../data/input/northeastamerica/nea_riverbasins.csv")
#Upload presence and absence in US river basins
nea_presence <- read_csv("../../data/input/northeastamerica/nea_presence.csv")
#upload connections between inshore and offshore basins
connections <- read_csv("../../data/input/northeastamerica/inshore_offshore_connections.csv")
\ No newline at end of file
#----------------------------------------------
# Temperature effect
#----------------------------------------------
# temperature effect in GR3D
# from Rosso
temperatureEffect = function(tempWater, Tmin, Topt, Tmax){
......@@ -18,9 +20,9 @@ thermalRange = function(pct = 0.8, Tmin, Topt, Tmax){
#optimalThermalRange(Tmin = 3, Topt = 17, Tmax =27)
# ----------------------------------------------
# growth simulation
#=---------------------------------------------
#----------------------------------------------
# Growth simulation
#---------------------------------------------
# von Bertalaffy : L = f(age)
vonBertalanffyGrowth = function(age, L0, Linf, K){
t0 = log(1 - L0 / Linf) / K
......@@ -88,3 +90,113 @@ strayerSurvival = function(distance, m ){
# m: extra mortality rate for strayers (L-1)
return(exp(-m * distance))
}
#-------------------------------------------------------
# Spwaner survival before reproduction
# Dome-shape curve with temperature effect
#-------------------------------------------------------
spawnerSurvivalPreReproduction <- function(Triver,Tmin, Topt, Tmax){
#River survival
survProbOptRiver = survivePar$survProbOptRiver
spRiver = survProbOptRiver * TemperatureEffect(Triver, Tmin, Topt, Tmax)
#StockAfterSurv = S * SpRiver
return(spRiver)
}
#----------------------------------------------
# Stock Recruitement relationship
#See Rougier et al, 2014; 2015 and Jatteau et al., 2017
#----------------------------------------------
#survival of larvae 14dph from Jatteau et al, 2017
stockRecruitementRelationship <- function(Triver,Tmin, Topt, Tmax, survivalStock) {
surfaceWatershed = 84810 #Surface de la Garonne
lambda = reproducePar$lambda
deltaT = reproducePar$deltaT
survOptRep = reproducePar$survOptRep
n = reproducePar$eta #simule l'effet allee
ratioS95_S50 = reproducePar$ratioS95_S50
alpha = reproducePar$a #species fecundity
survProbOptRiver = survivePar$survProbOptRiver
periodAtSea = 5 - deltaT
###--------------------- SR relationship -----------------
#parametre c de la RS de BH intgrant un effet du BV considr
cj = lambda/surfaceWatershed
#parametre b reprsentant la mortalit densit dpendante de la RS de BH intgrant un effet de la temperature
# bj = (-(1/deltaTrecruitement))*
# log(survOptRep * temperatureEffect(temp, 9.8, 20.0, 26.0))
bj = -log(survOptRep * temperatureEffect(Triver, Tmin , Topt , Tmax)) / deltaT
#parametre a (fcondit de l'espce) de la RS de BH intgrant un effet de la temperature
alphaj = (bj * exp(-bj * deltaT)) / (cj * (1 - exp(-bj * deltaT)))
alphaj[is.na(alphaj)] <- 0
#Bj = paramtre de la relation SR intgrant l'effet de la temprature
betaj = bj/(alpha*cj*(1 - exp(-bj*deltaT)))
#p = proportion de gniteurs participant la reproduction en focntion de la quantit de gniteur total
#p = 1/(1+exp(-log(19)*(S-n)/(Ratio*surfaceWatershed)))
S95 = n * surfaceWatershed
S50 = S95/ratioS95_S50
p = 1/(1 + exp(-log(19)*(survivalStock - S50)/(S95 - S50)))
#relation Stock Recrutement ie calcul le nombre de recrues en fonction du nombre de gniteurs et de la T en intgrant l'effet Allee
#R0 = aj * S * p
alleeEffect = 1/(1 + exp(-log(19)*(survivalStock - n/ratioS95_S50*surfaceWatershed)/(n*surfaceWatershed - n/ratioS95_S50*surfaceWatershed)))
Rj = (alphaj * SurvivalStock * alleeEffect)/(betaj + survivalStock * alleeEffect)
#Rj = ((aj * S) * p)/(Bj +S * p)
stockRecruitement = as.vector(Rj)
return(stockRecruitement)
}
# ----------------------------------------------
# Spawner survival after reproduction
#----------------------------------------------
#Logit with temperature effect
spawnerSurvivalPostReproduction <- function(Triver,Tref, coeffa, coeffb){
spRiverPostSpawn = (coeffb/ (1 + exp(coeffa*(Triver-Tref))))
return(spRiverPostSpawn)
}
#Dome-shape curve with temperature effect
spawnerSurvivalPostReproductionWithBellCurve <- function(Triver, Tmin, Topt, Tmax, coeffa, coeffb){
#P1:
#SpRiverPostSpawn = probSurvAfterRepro/(probSurvAfterRepro + (1 - probSurvAfterRepro)*exp(-coeffLogit*(TemperatureEffect(Triver, Tmin, Topt, Tmax))))
#P2:
#SpRiverPostSpawn = probSurvAfterRepro/(probSurvAfterRepro + (1 - probSurvAfterRepro)*exp(-coeffLogit))
#SpRiverPostSpawnTempEffect = (probSurvAfterRepro/(probSurvAfterRepro + (1 - probSurvAfterRepro)*exp(-coeffLogit))) * TemperatureEffect(Triver, Tmin, Topt, Tmax)
#P3:
spRiverPostSpawn = coeffb * temperatureEffect(Triver, Tmin, Topt, Tmax)
stockAfterSpawn = S * spRiverPostSpawn
return(spRiverPostSpawn)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment