server.R 19.4 KB
Newer Older
Jean-Francois Rey's avatar
Jean-Francois Rey committed
1

2
simul_params <- createSimulParams(outputDir = paste0(ROOT_PATH,"/www/tmp/"))
Jean-Francois Rey's avatar
Jean-Francois Rey committed
3

4
5
6
7
## Pathogen parameters
simul_params <- setPathogen(simul_params, loadPathogen("rust"))
## Initial conditions
simul_params <- setInoculum(simul_params, 5e-4)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
8

9
## Outputs
10
11
12
13
simul_params <- setOutputs(simul_params, list(epid_outputs="audpc", evol_outputs=""
                                              , thres_breakdown = 50000
                                              , GLAnoDis = 1.48315
                                              , audpc100S = 0.38))
14
15


Jean-Francois Rey's avatar
Jean-Francois Rey committed
16
17
18
19
20
21
22
# Server
server <- function(input, output, session) {
  # Functions
  ######################################################################################
  # Test if the cultivars proportion sum is 1
  ProportionValidation <- function () {
    if (input$demo == "RO") {
23
      sum <-
Jean-Francois Rey's avatar
Jean-Francois Rey committed
24
25
26
        ((input$prop0 + input$prop1) + (input$prop0 + input$prop2)) / 2
    }
    else {
27
      sum <- input$prop0 + input$prop1 + input$prop2
Jean-Francois Rey's avatar
Jean-Francois Rey committed
28
29
30
31
    }
    
    shinyjs::enable(id = "generateLandscape")
    shiny::removeUI(selector = "#propError")
32
33
    if (sum != 1 ||
        is.na(sum)) {
Jean-Francois Rey's avatar
Jean-Francois Rey committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
      shiny::insertUI(
        selector = "#generateLandscape",
        where = "afterEnd",
        ui = tags$div(
          id = "propError",
          class = "alert alert-warning",
          "The cultivars total proportion should be equal to 1 (100%)"
        )
      )
      shinyjs::disable(id = "generateLandscape")
    }
  }

  #############################################################################
  # Observe EVENT
  #############################################################################

  # About
  # Modal Dialog
  observeEvent(input$About, {
    showModal(modalDialog(
Jean-Francois Rey's avatar
Jean-Francois Rey committed
55
                title = paste0("About : Landsepi V", packageVersion("landsepiDev")),
Jean-Francois Rey's avatar
Jean-Francois Rey committed
56
57
58
59
                easyClose = TRUE,
                size = "l",
                footer = NULL,
                div(HTML("<h1>Landsepi: Landscape Epidemiology and Evolution</h1>
60
61
62
63
64
65
66
67
                          <h3> A stochastic, spatially-explicit, demo-genetic model 
                         simulating the spread and evolution of a plant pathogen in a heterogeneous landscape 
                         to assess resistance deployment strategies. It is based on a spatial geometry for describing 
                         the landscape and allocation of different cultivars, a dispersal kernel for the 
                         dissemination of the pathogen, and a SEIR ('Susceptible-Exposed-Infectious-Removed’) 
                         structure with a discrete time step. It provides a useful tool to assess the performance 
                         of a wide range of deployment options with respect to their epidemiological, 
                         evolutionary and economic outcomes.</h3>
Jean-Francois Rey's avatar
Jean-Francois Rey committed
68
69
                          <h3> Authors:</h3> J-L Gaussen, J. Papaïx, J-F Rey, L. Rimbaud
                          <h3>Package project:</h3><a href='https://CRAN.R-project.org/package=landsepi' target='_blank'> CRAN package</a><br/><a href='https://gitlab.paca.inra.fr/CSIRO-INRA/landsepi' target='_blank'> Source code</a>
Jean-Francois Rey's avatar
Jean-Francois Rey committed
70
                          <br/> License GPL-3
Jean-Francois Rey's avatar
Jean-Francois Rey committed
71
                          <h3> How to cite the package:</h3> <b>Rimbaud L, Papaïx J, Rey J-F (2019).</b> landsepi: Landscape Epidemiology and Evolution. R package version 0.1.0, &lt;URL: https://cran.r-project.org/package=landsepi&gt;.
Jean-Francois Rey's avatar
Jean-Francois Rey committed
72
                          <h3> Full model description:</h3> <b>Rimbaud L, Papaïx J, Rey J-F, Barrett LG and Thrall PH. 2018.</b> Assessing the durability and efficiency of landscape-based strategies to deploy plant resistance to pathogens. PLoS Computational Biology 14(4): e1006067. <a href='https://doi.org/10.1371/journal.pcbi.1006067' target='_blank'>https://doi.org/10.1371/journal.pcbi.1006067</a>
Jean-Francois Rey's avatar
Jean-Francois Rey committed
73
74
                          <div>
                          <img src='LogoINRAE_Fr_rvb_web.png' alt='INRAE' style='width:50px; margin-left: 10px;' />
Jean-Francois Rey's avatar
Jean-Francois Rey committed
75
                          <img src='logoBIOSP.jpeg' alt='BioSP' style='width:50px; margin-left: 10px;'/>
Jean-Francois Rey's avatar
Jean-Francois Rey committed
76
                          <img src='PATHO_inra_logo.png' alt='Pathologie végétale' style='width:50px; margin-left: 10px;'/>
Jean-Francois Rey's avatar
Jean-Francois Rey committed
77
                          <img src='CSIRO_Logo.png' alt='CSIRO' style='width:40px; margin-left: 10px;'/>
Jean-Francois Rey's avatar
Jean-Francois Rey committed
78
                          </div>
Jean-Francois Rey's avatar
Jean-Francois Rey committed
79
80
81
82
83
84
85
86
87
88
89
                "))
    ))
  })

  # Inputs / Outputs
  ######################################################################################
  # Landscape
  shiny::observeEvent(input$landscape, {
    ProportionValidation()
    shinyjs::disable(id = "runSimulation")
  })
90
  shiny::observeEvent(input$aggregLevel, {
Jean-Francois Rey's avatar
Jean-Francois Rey committed
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    ProportionValidation()
    shinyjs::disable(id = "runSimulation")
  })

  # Proportion validation
  shiny::observeEvent(input$prop0, {
    ProportionValidation()
    shinyjs::disable(id = "runSimulation")
  })
  shiny::observeEvent(input$prop1, {
    ProportionValidation()
    shinyjs::disable(id = "runSimulation")
  })
  shiny::observeEvent(input$prop2, {
    ProportionValidation()
    shinyjs::disable(id = "runSimulation")
  })
  ######################################################################################
  # Rotation period validation
  shiny::observeEvent(input$rotationPeriod, {
    shinyjs::enable(id = "generateLandscape")
    shinyjs::disable(id = "runSimulation")
    shiny::removeUI(selector = "#rotationPeriodError")
    if (input$demo == "RO") {
      if (input$rotationPeriod < 1 ||
          input$rotationPeriod >= input$nYear ||
          is.na(input$rotationPeriod)) {
        shiny::insertUI(
          selector = "#generateLandscape",
          where = "afterEnd",
          ui = tags$div(
            id = "rotationPeriodError",
            class = "alert alert-warning",
            paste0(
              "The rotation period should be between 1 and ", input$nYear," (the simulation duration)")
          )
        )
        shinyjs::disable(id = "generateLandscape")
      }
    }
  })
  ######################################################################################
  # nYear validation
  shiny::observeEvent(input$nYear, {
    #shinyjs::enable(id = "generateLandscape")
    #shinyjs::enable(id = "runSimulation")
    shinyjs::disable(id = "runSimulation")
    
    shiny::removeUI(selector = "#nYearError")
    if (input$nYear < 1 || input$nYear > 100 || is.na(input$nYear)) {
      shiny::insertUI(
        selector = "#generateLandscape",
        where = "afterEnd",
        ui = tags$div(
          id = "nYearError",
          class = "alert alert-warning",
          paste0(
            "The simulation duration should be between 1 and 100")
        )
      )
      shinyjs::disable(id = "generateLandscape")
      shinyjs::disable(id = "runSimulation")
    }
154
155
156
    else {
      simul_params <<- setTime(simul_params, Nyears = input$nYear, nTSpY = input$nTSpY)
      shinyjs::enable(id = "generateLandscape")}
Jean-Francois Rey's avatar
Jean-Francois Rey committed
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
  })
  ######################################################################################
  # nTSpY validation
  shiny::observeEvent(input$nTSpY, {
    #shinyjs::enable(id = "runSimulation")
    shinyjs::disable(id = "runSimulation")
    
    shiny::removeUI(selector = "#nTSpYError")
    if (input$nTSpY < 1 || input$nTSpY > 365 || is.na(input$nTSpY)) {
      shiny::insertUI(
        selector = "#runSimulation",
        where = "afterEnd",
        ui = tags$div(
          id = "nTSpYError",
          class = "alert alert-warning",
          paste0(
            "The time step should be between 1 and 365")
        )
      )
      shinyjs::disable(id = "runSimulation")
    }
178
179
180
181
    else {
      simul_params <<- setTime(simul_params, Nyears = input$nYear, nTSpY = input$nTSpY)
      shinyjs::enable(id = "generateLandscape")
    }
Jean-Francois Rey's avatar
Jean-Francois Rey committed
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  })
  ######################################################################################
  # seed validation
  shiny::observeEvent(input$seed, {
    #shinyjs::enable(id = "generateLandscape")
    #shinyjs::enable(id = "runSimulation")
    shinyjs::disable(id = "runSimulation")
    
    shiny::removeUI(selector = "#seedError")
    if (input$seed < 0 || input$seed > 99999 || is.na(input$seed)) {
      shiny::insertUI(
        selector = "#generateLandscape",
        where = "afterEnd",
        ui = tags$div(
          id = "seedError",
          class = "alert alert-warning",
          paste0(
            "The seed should be between 0 and 99999")
        )
      )
      shinyjs::disable(id = "generateLandscape")
      shinyjs::disable(id = "runSimulation")
    }
205
    else simul_params <<- setSeed(simul_params, input$seed)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
206
207
208
209
  })
  ######################################################################################
  # Handle the download gpkg button
  output$export <-
210
    shiny::downloadHandler(filename = "landsepi_landscape.gpkg",
Jean-Francois Rey's avatar
Jean-Francois Rey committed
211
                           content <- function(file) {
212
213
                             simul_params <<- saveDeploymentStrategy(simul_params)
                             file.copy(file.path(simul_params@OutputDir, simul_params@OutputGPKG), file)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
214
215
216
217
218
219
220
221
222
                           },
                           contentType = "application/x-sqlite3")
  ######################################################################################
  # Handle the "Generate the landscape" button
  shiny::observeEvent(input$generateLandscape, {
    withProgress(message = "Generating Landscape, Please wait...", value = 0, {
      shinyjs::disable(id = "generateLandscape")
      shinyjs::disable(id = "export")
      output$video <- NULL
223
224
      #if(!dir.exists(paste0(ROOT_PATH,"/www/tmp/"))) dir.create(paste0(ROOT_PATH,"/www/tmp/"))
      #setwd(paste0(ROOT_PATH,"/www/tmp/"))
Jean-Francois Rey's avatar
Jean-Francois Rey committed
225
226
      
      # Remove old files
227
      cleanDir(simul_params@OutputDir)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
228
229
230
231
232
      
      switch(
        input$demo,
        MO = {
          rotation_period = 0
233
          rotation_sequence = list(c(simul_params@Croptypes$croptypeID))
Jean-Francois Rey's avatar
Jean-Francois Rey committed
234
          prop = list(c(input$prop0, input$prop1, input$prop2))
235
          # aggregLevel = strtoi(input$aggregLevel)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
236
237
238
        },
        MI = {
          rotation_period = 0
239
          rotation_sequence = simul_params@Croptypes$croptypeID
Jean-Francois Rey's avatar
Jean-Francois Rey committed
240
          prop = list(c(input$prop0, input$prop1))
241
          # aggregLevel = strtoi(input$aggregLevel)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
242
243
244
245
246
        },
        RO = {
          rotation_period = input$rotationPeriod
          prop = list(c(input$prop0, input$prop1),
                      c(input$prop0, input$prop2))
247
          # aggregLevel = strtoi(input$aggregLevel)
248
249
          rotation_sequence <- list(c(simul_params@Croptypes$croptypeID[1], simul_params@Croptypes$croptypeID[2])
                                    , c(simul_params@Croptypes$croptypeID[1], simul_params@Croptypes$croptypeID[3]))
Jean-Francois Rey's avatar
Jean-Francois Rey committed
250
251
        },
        PY = {
252
          rotation_sequence = simul_params@Croptypes$croptypeID
Jean-Francois Rey's avatar
Jean-Francois Rey committed
253
254
          rotation_period = 0
          prop = list(c(input$prop0, input$prop1))
255
          # aggregLevel = strtoi(input$aggregLevel)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
256
257
258
259
260
261
        },
        {
          # Default case
          print("input$generateLandscape : Unknown input$demo")
        }
      )
262
      simul_params <<- setSeed(simul_params, input$seed)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
263
264
265

      incProgress(0.4)
      # Run the landscape generation
266
267
268
269
270
271
272
      simul_params <<- setLandscape(simul_params, loadLandscape(input$landscape))
      ## Dispersal parameters
      simul_params <<- setDispersalPathogen(simul_params, loadDispersalPathogen(input$landscape))
      ## Dispersal parameters
      disp_host <- loadDispersalHost(simul_params, type = "no")
      simul_params <<- setDispersalHost(simul_params, disp_host)
      
273
      ## Define the value of aggreg from aggregLevel
Jean-Francois Rey's avatar
Jean-Francois Rey committed
274

275
      switch(input$aggregLevel
Jean-Francois Rey's avatar
Jean-Francois Rey committed
276
             , "low" = {
277
278
279
               aggreg = 0.07
               algo = "periodic"
               }
Jean-Francois Rey's avatar
Jean-Francois Rey committed
280
             , "medium" = {
281
282
283
               aggreg = 0.25
               algo = "exp"
               }
Jean-Francois Rey's avatar
Jean-Francois Rey committed
284
             , "high" = {
285
286
               aggreg = 10
               algo = "periodic"
Jean-Francois Rey's avatar
Jean-Francois Rey committed
287
288
289
290
291
             }
             , {
               aggreg = 0.25
               algo = "exp"
             }
292
      )
Jean-Francois Rey's avatar
Jean-Francois Rey committed
293

294
295
296
297
298
299
      simul_params <<- allocateLandscapeCroptypes(simul_params
                                               , rotation_period = rotation_period
                                               , rotation_sequence = rotation_sequence
                                               , rotation_realloc = FALSE
                                               , prop = prop
                                               , aggreg = aggreg
300
                                               , algo = algo
301
                                               , graphic = TRUE
Jean-Francois Rey's avatar
Jean-Francois Rey committed
302
      )
303
      
Jean-Francois Rey's avatar
Jean-Francois Rey committed
304
      setwd(ROOT_PATH)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
305
306
307
308
309
310
      
      incProgress(0.5)
      # Print the image of the landscape
      #TODO Loop images for rotation demo
      #output$landscape <- shiny::renderImage({
      #  list(
Jean-Francois Rey's avatar
Jean-Francois Rey committed
311
      #    src = file.path("www/tmp", "landscape_year1.png"),
Jean-Francois Rey's avatar
Jean-Francois Rey committed
312
313
314
315
316
317
      #    contentType = 'image/png',
      #    width = "70%",
      #    height = "auto",
      #   alt = "Landscape"
      #  )
      #}, deleteFile = FALSE)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
318
      
Jean-Francois Rey's avatar
Jean-Francois Rey committed
319
320
      shinyjs::show(id = "landscapeimg")
      output$landscapeimg <- renderPlot({
321
        imgs <- normalizePath(list.files(simul_params@OutputDir,pattern=".png",full.names = TRUE))
Jean-Francois Rey's avatar
Jean-Francois Rey committed
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
        pngs = lapply(imgs, readPNG)
        asGrobs = lapply(pngs, rasterGrob)
        p <- grid.arrange(grobs=asGrobs, nrow=1 )
        })

      # Using slick : trouble with images size...
      #output$landscape <- renderSlickR({
      #  imgs <- list.files("www",pattern=".png",full.names = TRUE)
      #  slickR(imgs, slickOpts=list(adaptiveHeight=FALSE, respondTo="min"), height = "auto")
      #})
      
      shinyjs::enable(id = "generateLandscape")
      shinyjs::enable(id = "runSimulation")
    })
  })
  
  #############################################################################
  # Stop simulation : Kill future promise
  future_process <- NULL
  observeEvent(input$stopSimulation, {
                 cat(file=stderr(), "STOP button -> stop process ",future_process$job$pid, "\n")
               tools::pskill(future_process$job$pid,signal = tools::SIGTERM)
               tools::pskill(future_process$job$pid,signal = tools::SIGKILL)
  })
 
  ######################################################################################
  # Handle the "Run simulation" button

  shiny::observeEvent(input$runSimulation, {
    withProgress(message = "Running Simulation, please wait...", value = 0 , {
352
353
354
      progressBar <- Progress$new()
      progressBar$set(value = NULL, message = "Running Simulation, please wait...")
      #setwd(paste0(ROOT_PATH,"/www/tmp/"))
Jean-Francois Rey's avatar
Jean-Francois Rey committed
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
      
      shinyjs::disable(id = "inputpanel")
      shinyjs::disable(id = "generateLandscape")
      shinyjs::disable(id = "runSimulation")
      shinyjs::disable(id = "export")
      shinyjs::enable(id = "stopSimulation")
      
      progressBar$set(value = 0.4)

      plan(list(multicore, multiprocess))

      #progressBarTime <- Progress$new()
      #future({
      #  progressBarTime$set(value = 0, message = "please wait...")
      #  for(time in 1:(nYear*1.5)) {
      #    cat(file=stderr(), time/(nYear*1.5), "\n")
      #    progressBarTime$set(value = (time/(nYear*1.5)))
      #    Sys.sleep(1)
      # }
      #  ~progressBarTime$close()
      #
      #})
377
378
      #cat(file=stderr(), simul_params)
      #print(simul_params)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
379
380
      
      future_process <<- future({
381
        res <- landsepiDev::runSimul(simul_params,
382
                                     graphic = FALSE, videoMP4 = TRUE)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
      })
      
      then(future_process, onFulfilled = function(value) {
        progressBar$set(value = 0.8, message = "Simulation ended : making video...")
        
        shinyjs::enable(id = "inputpanel")
        shinyjs::enable(id = "generateLandscape")
        #shinyjs::enable(id = "runSimulation")
        shinyjs::enable(id = "export")
        shinyjs::disable(id = "runSimulation")
        shinyjs::disable(id = "stopSimulation")

        output$landscapeimg <- NULL
        hide(id = "landscapeimg")
        
        output$video <-
          shiny::renderUI(
            tags$video(
              id = "video",
              type = "video/mp4",
Jean-Francois Rey's avatar
Jean-Francois Rey committed
403
              src = paste0("tmp/",basename(simul_params@OutputDir),"/video.mp4?rand=",as.integer(Sys.time())),
Jean-Francois Rey's avatar
Jean-Francois Rey committed
404
405
406
407
408
409
410
411
              controls = "controls",
              width = "100%",
              height = "auto"
            )
          )
        #setwd(dirname(getwd()))
      },
      onRejected = function(err) {
Jean-Francois Rey's avatar
Jean-Francois Rey committed
412
413
        setwd(ROOT_PATH)
        cat(file=stderr(), "\n ### KILL'EM ALL ### -> Kill simulation \n")
414
        cleanDir(simul_params@OutputDir)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
415
416
417
418
419
420
421
422
423
        shinyjs::enable(id = "inputpanel")
        shinyjs::enable(id = "generateLandscape")
        shinyjs::disable(id = "runSimulation")
        shinyjs::disable(id = "stopSimulation")
        future_process <- NULL
        0
      }) %>%
      finally(~progressBar$close())

Jean-Francois Rey's avatar
Jean-Francois Rey committed
424
     setwd(ROOT_PATH)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
425
426
427
428
429
430
431
432
    })
  })
  ######################################################################################
  # Handle the demo list
  shiny::observeEvent(input$demo, {
    # Cultivar tab
    switch (
      input$demo,
433
434
435
436
      MO = {simul_params <<- loadDemoMO(simul_params) },
      MI = {simul_params <<- loadDemoMI(simul_params) },
      RO = { simul_params <<- loadDemoRO(simul_params) },
      PY = { simul_params <<- loadDemoPY(simul_params) },
Jean-Francois Rey's avatar
Jean-Francois Rey committed
437
438
439
440
441
      {
        # Default case
        print("input$demo : Unknown input$demo")
      }
    )
442

Jean-Francois Rey's avatar
Jean-Francois Rey committed
443
    output$croptypes <- {
444
      RenderCroptypes(simul_params@Croptypes)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
445
446
    }
    output$cultivars <- {
447
      RenderCultivars(simul_params@CultivarsGenes)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
448
449
450
451
452
453
    }
    shinyjs::disable(id = "croptypes")
    shinyjs::disable(id = "cultivars")
    
    # Landscape tab
    shiny::updateSelectInput(session, "landscape", selected = 1)
454
    simul_params <<- setLandscape(simul_params, loadLandscape(1))
455
    shiny::updateSelectInput(session, "aggregLevel", selected = "low")
Jean-Francois Rey's avatar
Jean-Francois Rey committed
456
457
458
459
460
461
462
463
464
465
466
467
468
    
    # Enable all the conditionnal inputs by default, we disable it later if needed
    shinyjs::disable(id = "prop2")
    shinyjs::disable(id = "rotationPeriod")
    # Set
    shiny::updateNumericInput(session, "prop2", value = 0)
    shiny::updateNumericInput(session, "rotationPeriod", value = 0)
    
    if (input$demo == "MO") {
      shinyjs::enable(id = "prop2")
      shiny::updateNumericInput(session, "prop0", value = 0.33)
      shiny::updateNumericInput(session, "prop1", value = 0.33)
      shiny::updateNumericInput(session, "prop2", value = 0.34)
469
      shiny::updateSelectInput(session, "aggregLevel", selected = "high")
Jean-Francois Rey's avatar
Jean-Francois Rey committed
470
471
472
473
    }
    else if (input$demo == "MI" || input$demo == "PY") {
      shiny::updateNumericInput(session, "prop0", value = 0.5)
      shiny::updateNumericInput(session, "prop1", value = 0.5)
474
      shiny::updateSelectInput(session, "aggregLevel", selected = "high")
Jean-Francois Rey's avatar
Jean-Francois Rey committed
475
476
477
478
479
480
481
    }
    else if (input$demo == "RO") {
      shinyjs::enable(id = "prop2")
      shinyjs::enable(id = "rotationPeriod")
      shiny::updateNumericInput(session, "prop0", value = 0.5)
      shiny::updateNumericInput(session, "prop1", value = 0.5)
      shiny::updateNumericInput(session, "prop2", value = 0.5)
482
      shiny::updateNumericInput(session, "rotationPeriod", value = 2)
483
484
485
486
      shiny::updateSelectInput(session, "aggregLevel", selected = "medium")
    }
    else if (input$demo == "PY") {
      shiny::updateSelectInput(session, "aggregLevel", selected = "low")
Jean-Francois Rey's avatar
Jean-Francois Rey committed
487
488
489
490
491
    }
    
    # More parameters tab
    shiny::updateNumericInput(session, "nYear", value = 30)
    shiny::updateNumericInput(session, "nTSpY", value = 120)
492
    simul_params <<- setTime(simul_params, Nyears = 30, nTSpY = 120)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
493
    shiny::updateNumericInput(session, "seed", value = 12345)
494
    simul_params <<- setSeed(simul_params, 12345)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
495
496
497
498
499
500
501
502
503
504
    
    # Disable button
    shinyjs::disable(id = "runSimulation")
    shinyjs::disable(id = "stopSimulation")
    shinyjs::disable(id = "export")
    
    # Remove image
    output$landscapeimg <- NULL
  })
}