Commit e5939329 authored by Poulet Camille's avatar Poulet Camille
Browse files

Plot of survival curves according to hypothesis

parent 31d06ade
......@@ -191,7 +191,7 @@ spawnerSurvivalPostReproductionTempRef <- function(Triver,Tref, coeffa, coeffb){
}
#Dome-shape curve with temperature effect
spawnerSurvivalPostReproductionWithBellCurve <- function(Triver, Tmin, Topt, Tmax, coeffa, coeffb){
spawnerSurvivalPostReproductionWithBellCurve <- function(Triver, Tmin, Topt, Tmax, coeffb){
#P1:
#SpRiverPostSpawn = probSurvAfterRepro/(probSurvAfterRepro + (1 - probSurvAfterRepro)*exp(-coeffLogit*(TemperatureEffect(Triver, Tmin, Topt, Tmax))))
......
......@@ -102,12 +102,15 @@ quantile_spring = nea_presence_temp%>%
summarise(Tmin = min(spring_river_temperature),
Q1 = quantile(spring_river_temperature, 0.01),
Q5 = quantile(spring_river_temperature, 0.05),
Med = median(spring_river_temperature),
Mean = mean(spring_river_temperature),
Q95 = quantile(spring_river_temperature, 0.95),
Q99 = quantile(spring_river_temperature, 0.99),
Tmax = max(spring_river_temperature),.groups = 'drop')
#flextable() %>%
#autofit()
#----------------------------------------------------------------------
#see how many times and which watershed had survival below each quantile
nea_presence_temp %>%
......@@ -131,14 +134,13 @@ nea_presence_temp %>%
freq_out = ((n_occurence_out/n_tot)*100),.groups ='drop') %>%
distinct()
#summarize(n = n_distinct(basin_name))
#-----------------
nea_presence_temp %>%
group_by(obs_1900_1950) %>%
filter(spring_river_temperature > quantile(spring_river_temperature, 0.95)) %>%
group_by(year) %>%
summarize(n = n_distinct(basin_name))
filter(spring_river_temperature > quantile(spring_river_temperature, 0.99)) %>%
group_by(basin_name) %>%
summarize(n = n_distinct(year)) %>%
inner_join(nea_riverBasinFeatures %>% select(basin_name, lat_outlet), by = 'basin_name')
#arrange(desc(n))
#-------------------
......@@ -153,6 +155,25 @@ nea_presence_temp %>%
summarize(n = n())
#arrange(desc(n))
#----------------------
nea_presence_temp %>%
filter(basin_name == 'St. Johns') %>%
ggplot()+
geom_histogram(aes(x = spring_river_temperature > quantile_spring$Q99), position = 'identity',binwidth = 0.2, stat ='count')
#-------------------------------------------------------------
#Do the same for spring and summer temperature combined
#--------------------------------------------------------------
quantile_ss = nea_presence_temp%>%
group_by(obs_1900_1950) %>%
summarise(Tmin = min(c(spring_river_temperature, summer_river_temperature)),
Q1 = quantile(c(spring_river_temperature,summer_river_temperature), 0.01),
Q5 = quantile(c(spring_river_temperature,summer_river_temperature), 0.05),
Med = median(c(spring_river_temperature,summer_river_temperature)),
Mean = mean(c(spring_river_temperature,summer_river_temperature)),
Q95 = quantile(c(spring_river_temperature,summer_river_temperature), 0.95),
Q99 = quantile(c(spring_river_temperature,summer_river_temperature), 0.99),
Tmax = max(c(spring_river_temperature,summer_river_temperature)),.groups = 'drop')
```
......@@ -447,7 +468,7 @@ ToptSurv = TminSurv + lambda *(TmaxSurv - TminSurv)
ggp_A = ggplot() +
geom_line(aes(temperature, temperatureEffect (temperature, res_0A$par['TminSurv'],
geom_line(aes(temperature, temperatureEffect(temperature, res_0A$par['TminSurv'],
Topt = ToptSurv,
res_0A$par['TmaxSurv'])))+
geom_vline(xintercept = c(8,26))
......@@ -468,7 +489,7 @@ ToptSurv = TminSurv + lambda *(TmaxSurv - TminSurv)
ggp_quant = ggplot() +
geom_line(aes(temperature, temperatureEffect (temperature, res_0A_quantile$par['TminSurv'],
geom_line(aes(temperature, temperatureEffect(temperature, res_0A_quantile$par['TminSurv'],
Topt = ToptSurv,
res_0A_quantile$par['TmaxSurv'])))+
geom_vline(xintercept = c(8,26))
......@@ -628,6 +649,8 @@ quantile_sum = nea_presence_temp%>%
summarise(Tmin = min(summer_river_temperature),
Q1 = quantile(summer_river_temperature, 0.01),
Q5 = quantile(summer_river_temperature, 0.05),
Med = median(summer_river_temperature),
Mean = mean(summer_river_temperature),
Q95 = quantile(summer_river_temperature, 0.95),
Q99 = quantile(summer_river_temperature, 0.99),
Tmax = max(summer_river_temperature),.groups = 'drop')
......
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