Commit 815ada2e authored by Poulet Camille's avatar Poulet Camille
Browse files

Growth optimisation with english comments

parent e5939329
......@@ -199,7 +199,7 @@ Stich2020_sel <- read_csv("../NEA_calibration_offline/Stich_Table 9.csv") %>%
filter(parameter == "K" | parameter == "Linf"|parameter == "t0") %>%
dplyr::rename("catchment"="cachtment") %>%
select(parameter,catchment,mean) %>%
pivot_wider(names_from = parameter, values_from = mean) %>%
pivot_wider(names_from = parameter, values_from = mean)
Stich2020_sel %>%
flextable() %>%
......@@ -344,6 +344,8 @@ growthInBasin %>%
distinct(basin_name, obs_1900_1950)
```
As Stich et al 2020 provided a growth curve for both sex combined, we draw a parameters set for unisex based on the growth parameters for males and females from the XML file.
```{r Growth in GR3D with temperature effect, echo = FALSE, warning=FALSE}
#define parameters for both sex based on value from the XML file
......@@ -364,6 +366,7 @@ growParUnisex <- growPar %>%
```{r}
# new ====
#save all file that will be needed for optimization process as SOS data
save(growParUnisex,growthInBasin, nea_presence, Stich2020_sel, file = 'SOS.rdata' )
rm(list = ls())
......@@ -371,7 +374,7 @@ load('SOS.rdata')
source("../GR3D_Rdescription/GR3Dfunction.R")
```
Based on growth curves from Stich et al, 2020, we looked for growth parameters (L0, Linf, Kopt) and the thermal range regulating growth, that minimize the square distance between the mean growth curve derived from Stich et al, 2020 and the growth curve to implemented into the GR3D model for each meta-population.
```{r growth optimisation function Camille, echo = FALSE, warning=FALSE}
#vector on paramters to get optimized
......@@ -482,7 +485,7 @@ par2parGrowth = function(par){
return(parGrowth)
}
# avec Topt, Tmin = Topt - espsilonMinus, Tmax = Topt + epsilonPlus
# with Topt, Tmin = Topt - espsilonMinus, Tmax = Topt + epsilonPlus
objFn = function(par, data) {
growPar = par2parGrowth(par)
data = computeGrowAllBasins(data, growPar)
......@@ -499,7 +502,7 @@ objFn = function(par, data) {
return(SSE)
}
# équivalent de la fonction computeSSE (un peu plus rapide)
# same as computeSSE but faster
objFn_B = function(par, data) {
growPar = enframe(par) %>%
pivot_wider() %>% mutate(sigmaDeltaLVonBert = 0)
......@@ -517,7 +520,7 @@ objFn_B = function(par, data) {
return(SSE)
}
# équivalent de la fonction objFn_B mais avec la possibilité de fixer des parametres
# same as objFn_B with a vector for starting initaila values
objFn_C = function(par, data, fixedPar) {
growPar = enframe(c(par, fixedPar)) %>% pivot_wider() %>%
mutate(sigmaDeltaLVonBert = 0)
......@@ -539,7 +542,7 @@ objFn_C = function(par, data, fixedPar) {
```{r starting parameters for optimisation}
# starting point from XML
vecPar = growParModifed %>%
vecPar = growParUnisex %>%
select(tempMinGrow, tempOptGrow, tempMaxGrow, lengthAtHatching, Linf, kOpt) %>%
pivot_longer(tempMinGrow:kOpt, names_to = "parameter", values_to = "value")
vecPar = as.vector(vecPar$value)
......@@ -593,7 +596,7 @@ dataCalibration = growthInBasin %>%
```
Avec uniqument le jeu de Stich cela part en vrille avec objFn_B et computeSSE ( sans donner les mémes resultats argh) avec Topt < Tmin. On a des résulats corrects avec objFn ( avec Topt +- epsilon). Mais comme on va utiliser l'option en fixant Tmin et Tmax
<!-- Avec uniqument le jeu de Stich cela part en vrille avec objFn_B et computeSSE ( sans donner les mémes resultats argh) avec Topt < Tmin. On a des résulats corrects avec objFn ( avec Topt +- epsilon). Mais comme on va utiliser l'option en fixant Tmin et Tmax -->
```{r optimisation run}
......
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