Skip to content
Snippets Groups Projects
Commit 772e7039 authored by thierrychambert's avatar thierrychambert
Browse files

Added "calib0" for vr display to avoid run error ("calibrated")

parent 26847b9b
No related branches found
No related tags found
No related merge requests found
...@@ -246,6 +246,8 @@ server <- function(input, output, session){ ...@@ -246,6 +246,8 @@ server <- function(input, output, session){
fecundities = NULL, fecundities = NULL,
survivals = NULL, survivals = NULL,
s_calib0 = NULL,
f_calib0 = NULL,
s_calibrated = NULL, s_calibrated = NULL,
f_calibrated = NULL, f_calibrated = NULL,
vr_calibrated = NULL, vr_calibrated = NULL,
...@@ -876,7 +878,7 @@ server <- function(input, output, session){ ...@@ -876,7 +878,7 @@ server <- function(input, output, session){
nrow = 1, dimnames = list(NULL, "Erreur")) nrow = 1, dimnames = list(NULL, "Erreur"))
}else{ }else{
make_mat_popsizes(data_sf = data_sf, species = input$species_choice, pop_size = param$pop_size_mean, make_mat_popsizes(data_sf = data_sf, species = input$species_choice, pop_size = param$pop_size_mean,
pop_size_unit = input$pop_size_unit, s = param$s_calibrated, f = param$f_calibrated) pop_size_unit = input$pop_size_unit, s = param$s_calib0, f = param$f_calib0)
} # end if } # end if
}, },
width = "500px", width = "500px",
...@@ -1004,8 +1006,8 @@ server <- function(input, output, session){ ...@@ -1004,8 +1006,8 @@ server <- function(input, output, session){
tab_species <- make_mat_vr(data_sf = data_sf, species = input$species_choice) tab_species <- make_mat_vr(data_sf = data_sf, species = input$species_choice)
ages <- tab_species$classes_age ages <- tab_species$classes_age
matrix(data = c(param$s_calibrated, param$f_calibrated), matrix(data = c(param$s_calib0, param$f_calib0),
nrow = length(param$s_calibrated), nrow = length(param$s_calib0),
ncol = 2, ncol = 2,
dimnames = list(ages, c("Survie", "Fcondit")) dimnames = list(ages, c("Survie", "Fcondit"))
) )
...@@ -1019,7 +1021,7 @@ server <- function(input, output, session){ ...@@ -1019,7 +1021,7 @@ server <- function(input, output, session){
delay(ms = 300, delay(ms = 300,
output$lambda0_info <- renderText({ output$lambda0_info <- renderText({
req(all(!is.na(input$mat_fill_vr))) req(all(!is.na(input$mat_fill_vr)))
lam <- lambda(build_Leslie(s = param$s_calibrated, f = param$f_calibrated)) lam <- lambda(build_Leslie(s = param$s_calib0, f = param$f_calib0))
taux <- round(lam-1,2)*100 taux <- round(lam-1,2)*100
if(taux < 0) Text <- "Dclin : " else Text <- "Croissance : " if(taux < 0) Text <- "Dclin : " else Text <- "Croissance : "
if(taux == 0) Text <- "Population stable : " if(taux == 0) Text <- "Population stable : "
...@@ -1321,8 +1323,8 @@ server <- function(input, output, session){ ...@@ -1321,8 +1323,8 @@ server <- function(input, output, session){
param$fecundities <- input$mat_fill_vr[,2] param$fecundities <- input$mat_fill_vr[,2]
# for now, until calibration is really done # for now, until calibration is really done
param$s_calibrated <- param$survivals param$s_calib0 <- param$survivals
param$f_calibrated <- param$fecundities param$f_calib0 <- param$fecundities
}) # end observeEvent }) # end observeEvent
##### #####
...@@ -1330,11 +1332,24 @@ server <- function(input, output, session){ ...@@ -1330,11 +1332,24 @@ server <- function(input, output, session){
############################################# #############################################
## Calibration of survivals & fecundities ## Calibration of survivals & fecundities
##------------------------------------------- ##-------------------------------------------
## Calibration 1 : just for information display
observeEvent({ observeEvent({
input$run
input$button_calibrate_vr input$button_calibrate_vr
},{ },{
vr_calib0 <- calibrate_params(
inits = init_calib(s = param$survivals, f = param$fecundities, lam0 = param$pop_growth_mean),
f = param$fecundities, s = param$survivals, lam0 = param$pop_growth_mean
)
param$s_calib0 <- head(vr_calib0, length(param$survivals))
param$f_calib0 <- tail(vr_calib0, length(param$fecundities))
})
## Calibration 2 : for simulation run
observeEvent({
input$run
},{
# We also define rMAX and theta here # We also define rMAX and theta here
rMAX_species <- rMAX_spp(surv = tail(param$survivals,1), afr = min(which(param$fecundities != 0))) rMAX_species <- rMAX_spp(surv = tail(param$survivals,1), afr = min(which(param$fecundities != 0)))
param$rMAX_species <- rMAX_species param$rMAX_species <- rMAX_species
......
...@@ -566,6 +566,7 @@ rm(list = ls(all.names = TRUE)) ...@@ -566,6 +566,7 @@ rm(list = ls(all.names = TRUE))
), ),
)}, # close fluidRow )}, # close fluidRow
br(),
actionButton(inputId = "button_calibrate_vr", label = "Calibrer survies et fcondits"), actionButton(inputId = "button_calibrate_vr", label = "Calibrer survies et fcondits"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment