Commit 1321df01 authored by Poulet Camille's avatar Poulet Camille
Browse files

Correction on variable names

parent f45992ea
......@@ -184,7 +184,7 @@ Stich2020_sel <- read_csv("../NEA_calibration_offline/Stich_Table 9.csv") %>%
mutate(L0_theo = vonBertalanffyLengthAtHatch(Linf, K, t0))
#create a data frame and compute L at age with values from Stich
growthInOffshore <- expand_grid(basin_name = nea_riverBasinFeatures$basin_name , age = seq(0,9.75,.25)) %>%
growthInBasin <- expand_grid(basin_name = nea_riverBasinFeatures$basin_name , age = seq(0,9.75,.25)) %>%
mutate(season = case_when (
(age - floor(age)) == 0.00 ~ 'spring',
(age - floor(age)) == 0.25 ~ 'summer',
......@@ -201,18 +201,18 @@ growthInOffshore <- expand_grid(basin_name = nea_riverBasinFeatures$basin_name ,
mutate(LStich = vonBertalanffyGrowth(age, L0_theo, Linf, K) / 10) %>% # in cm
ungroup()
growthInOffshore <-growthInOffshore %>%
growthInBasin <-growthInBasin %>%
inner_join(tempEffectInOffshore,
by = c("basin_name" = "inshore_basin_name", "season")) %>%
right_join(tempEffectInFreshWat,
by = c("basin_name","season"))
growthInOffshore <- growthInOffshore %>%
mutate(temperature = ifelse(season == "spring" & age == 0, temperature_RI,
ifelse(season == "summer" & age == 0.25, temperature_RI,
ifelse(season == "fall" & age == 0.50, temperature_RI, temperature_O)))) %>%
growthInBasin <- growthInBasin %>%
mutate(temperature_RIO = ifelse(season == "spring" & age == 0, temperature_RI,
ifelse(season == "summer" & age == 0.25, temperature_RI,
ifelse(season == "fall" & age == 0.50, temperature_RI, temperature_O)))) %>%
arrange(basin_name,age,season) %>%
select(basin_name, offshore_basin_name, metapop,age, season, temperature_O, LStich)
select(basin_name, offshore_basin_name, metapop,age, season, temperature_RIO, LStich)
#group_by(metapop,age,season) %>%
#summarize(LStich = unique(LStich))
......@@ -587,7 +587,7 @@ growParOptim <- data.frame(value = growth_optimal$par) %>%
rownames_to_column("parameter")
#Rdata
save(growth_optimal, res, res_B, res_C, file = "growth_optimal.RData")
#save(growth_optimal, res, res_B, res_C, file = "growth_optimal.RData")
#csv
write_csv(growParOptim, "growParOptim.csv")
......@@ -607,17 +607,18 @@ dataVerif <- computeGrowAllBasins(data = dataCalibration,
# graph by meta pop
dataVerif %>% group_by(metapop, age) %>%
summarise(L = mean(L), LStich = mean(LStich), .groups = 'drop') %>%
summarise(L = mean(L), LStich = mean(LStich), .groups ='drop') %>%
mutate(metapop = factor(metapop, levels = c('northern iteroparous', 'southern iteroparous', 'semelparous'))) %>%
ggplot(aes(x = age, color = metapop)) +
geom_line(aes(y = LStich)) +
geom_line(aes(y = L))
save(dataVerif, growth_optimal,res, res_B, res_C, file = "growth_optimal.RData")
# thermal response curve with average seasonal temperature experienced by fish
dataTemperatureMetapop <- dataVerif %>%
group_by(metapop, season) %>%
summarise(temperature = mean(temperature), .groups = 'drop') %>%
summarise(temperature = mean(temperature), .groups='drop') %>%
mutate(tempEffect = temperatureEffect(temperature, parGrowthUsed$tempMinGrow, parGrowthUsed$tempOptGrow, parGrowthUsed$tempMaxGrow ),
metapop = factor(metapop, levels = c('northern iteroparous', 'southern iteroparous', 'semelparous')),
season = factor(season, levels = c('winter', 'spring', 'summer', 'fall')))
......@@ -636,7 +637,7 @@ data.frame(temperature = seq(0,40,0.1)) %>%
```{r draw growth curves}
load("growth_optimal.RData")
#load("growth_optimal.RData")
growthCurves = computeGrowOpt(growth_optimal$par, growthInOffshore)
save(growthCurves, file = "growthCurves.RData")
......@@ -680,30 +681,6 @@ df %>%
```
```{r growth try, echo = FALSE, warning=FALSE}
#k depending on water temperature in ofsshore basins
kTempEffect = function(kopt, temp, Tmin, Topt, Tmax){
kTemp <- kopt * temperatureEffect(temp,
Tmin,
Topt,
Tmax)
return(kTemp)}
#Generic function
vonBertalanffyGrowthWithTempEffect = function(temp, age, L0, Linf, Kopt, Tmin, Topt, Tmax){
koptTemp = kTempEffect(Kopt, temp, Tmin, Topt, Tmax)
t0 = log(1 - L0 / Linf) / koptTemp
return(Linf * (1 - exp(-koptTemp * (age - t0))))
}
```
......
parameter,value
<<<<<<< HEAD
Tmin,0
Topt,4.5125688473103995
Tmax,76.23141515590089
L0,6.5184840221819975
Linf,47.53851690994118
K,0.4964834345987972
=======
Tmin,-12.713186580960963
Topt,-35.999892199799476
Tmax,77.91401250769903
L0,6.437410947346945
Linf,47.55230062211272
K,1.2212313819420748
>>>>>>> develop
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