Skip to content

Commit

Permalink
Merge pull request #25 from JGCRI/1.1.4
Browse files Browse the repository at this point in the history
1.1.4 update
  • Loading branch information
evanoffPNNL authored Nov 9, 2020
2 parents bd1ca41 + 3c8b709 commit 93a7382
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 21 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ To navigate directly to the `hectorui` app **CLICK the following image**:

[![`hectorui` map scenario interface](https://raw.githubusercontent.com/JGCRI/hectorui/master/paper/figure1.png)](https://jgcri.shinyapps.io/HectorUI/)

_The map scenario interface to `hectorui` that allows the user to parameterize inputs and visualize run outputs interactively. Image contains a link to the application._
## Installing Locally

To install hectorui as an R package for local use, please follow these steps in your R command line:

- library(devtools)
- devtools::install_github("JGCRI/hectorui")

## Contributing to `hectorui`

We welcome contributions to `hectorui` from the development community. Please contact us if you want to collaborate! The `hectorui` GitHub repository is accessible here: [GitHub Repository](https://github.com/JGCRI/hectorui)
We welcome contributions to `hectorui` from the development community. Please contact us if you want to collaborate! The `hectorui` GitHub repository is accessible here: [`hector-ui` GitHub Repository](https://github.com/JGCRI/hectorui)

For more information about contributing, please contact Jason Evanoff at jason.evanoff@pnnl.gov or Chris Vernon at chris.vernon@pnnl.gov

77 changes: 58 additions & 19 deletions inst/shinyApp/parameters.r
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Contains parameter related functions and observers

#' Assign Parameters from numeric components to core
#' Assign Parameters from model to core
#'
#' @return no return value
#' @export
#'
#' @examples
setCoreParameters <- function(hcore)
{
hector::setvar(hcore, dates = NA, var = globalParameters['aero'], values = c(as.double(paramsList[['alpha']])), unit = "unitless")
hector::setvar(hcore, dates = NA, var = globalParameters['beta'], values = c(as.double(paramsList[['beta']])), unit = "unitless")
hector::setvar(hcore, dates = NA, var = globalParameters['diff'], values = c(as.double(paramsList[['diff']])), unit = "cm2/s")
hector::setvar(hcore, dates = NA, var = globalParameters['ecs'], values = c(as.double(paramsList[['S']])), unit = "degC")
hector::setvar(hcore, dates = NA, var = globalParameters['pco2'], values = c(as.double(paramsList[['C']])), unit = "ppmv CO2")
hector::setvar(hcore, dates = NA, var = globalParameters['q10'], values = c(as.double(paramsList[['q10_rh']])), unit = "unitless")
hector::setvar(hcore, dates = NA, var = globalParameters['volc'], values = c(as.double(paramsList[['volscl']])), unit = "unitless")
hector::setvar(hcore, dates = NA, var = globalParameters['aero'], values = c(as.double(paramsList[['alpha']])), unit = "unitless")
hector::setvar(hcore, dates = NA, var = globalParameters['beta'], values = c(as.double(paramsList[['beta']])), unit = "unitless")
hector::setvar(hcore, dates = NA, var = globalParameters['diff'], values = c(as.double(paramsList[['diff']])), unit = "cm2/s")
hector::setvar(hcore, dates = NA, var = globalParameters['ecs'], values = c(as.double(paramsList[['S']])), unit = "degC")
hector::setvar(hcore, dates = NA, var = globalParameters['pco2'], values = c(as.double(paramsList[['C']])), unit = "ppmv CO2")
hector::setvar(hcore, dates = NA, var = globalParameters['q10'], values = c(as.double(paramsList[['q10_rh']])), unit = "unitless")
hector::setvar(hcore, dates = NA, var = globalParameters['volc'], values = c(as.double(paramsList[['volscl']])), unit = "unitless")
}

#' Assign Parameters from parameter model values into numeric input components
Expand Down Expand Up @@ -161,51 +161,90 @@ setParameters <- function()
if(length(hcores) > 0)
{
newVals <- vector()
pass_check <- TRUE
# Run through variables and make sure none are left empty and update the top level scope paramsList variable
# and the hector core with any changed values
# and the hector core with any changed values.
tryCatch(
{
for(i in 1:length(hcores))
{
if(!is.na(input$input_aero))
if(!is.na(input$input_aero) && input$input_aero <= 1 && input$input_aero > 0)
{
hector::setvar(hcores[[i]], dates = NA, var = globalParameters['aero'], values = c(as.double(input$input_aero)), unit = "unitless")
paramsList['alpha'] <<- as.double(input$input_aero)
}
if(!is.na(input$input_beta))
else
{
shinyalert::shinyalert("Input Error:", "Aeroscale Forcing value out of bounds. Please use (0,1) as limits.", type = "error")
pass_check <- FALSE
}
if(!is.na(input$input_beta) && input$input_beta > 0 && input$input_beta <= 5)
{
hector::setvar(hcores[[i]], dates = NA, var = globalParameters['beta'], values = c(as.double(input$input_beta)), unit = "unitless")
paramsList['beta'] <<- as.double(input$input_aero)
}
if(!is.na(input$input_diff))
else
{
shinyalert::shinyalert("Input Error:", "CO2 Fertilization Factor value out of bounds. Please use (0,5) as limits.", type = "error")
pass_check <- FALSE
}
if(!is.na(input$input_diff) && input$input_diff > 0)
{
hector::setvar(hcores[[i]], dates = NA, var = globalParameters['diff'], values = c(as.double(input$input_diff)), unit = "cm2/s")
paramsList['diff'] <<- as.double(input$input_aero)
}
if(!is.na(input$input_ecs))
else
{
shinyalert::shinyalert("Input Error:", "Ocean Heat Diffusivity value out of bounds. Please use (>0) as limits.", type = "error")
pass_check <- FALSE
}
if(!is.na(input$input_ecs) && input$input_ecs >=1 && input$input_ecs <= 6)
{
hector::setvar(hcores[[i]], dates = NA, var = globalParameters['ecs'], values = c(as.double(input$input_ecs)), unit = "degC")
paramsList['S'] <<- as.double(input$input_aero)
}
if(!is.na(input$input_pco2))
else
{
shinyalert::shinyalert("Input Error:", "ECS value out of bounds. Please use (1,6) as limits.", type = "error")
pass_check <- FALSE
}
if(!is.na(input$input_pco2) && input$input_pco2 >= 250 && input$input_pco2 <= 300)
{
hector::setvar(hcores[[i]], dates = NA, var = globalParameters['pco2'], values = c(as.double(input$input_pco2)), unit = "ppmv CO2")
paramsList['C'] <<- as.double(input$input_aero)
}
if(!is.na(input$input_q10))
else
{
shinyalert::shinyalert("Input Error:", "Preindustrial CO2 value out of bounds. Please use (250, 300) as limits.", type = "error")
pass_check <- FALSE
}
if(!is.na(input$input_q10) && input$input_q10 > 0 && input$input_q10 <= 10)
{
hector::setvar(hcores[[i]], dates = NA, var = globalParameters['q10'], values = c(as.double(input$input_q10)), unit = "unitless")
paramsList['q10_rh'] <<- as.double(input$input_aero)
}
if(!is.na(input$input_volc))
else
{
shinyalert::shinyalert("Input Error:", "Q10 value out of bounds. Please use (0, 10) as limits.", type = "error")
pass_check <- FALSE
}
if(!is.na(input$input_volc) && input$input_volc > 0 && input$input_volc <= 1)
{
hector::setvar(hcores[[i]], dates = NA, var = globalParameters['volc'], values = c(as.double(input$input_volc)), unit = "unitless")
paramsList['volscl'] <<- as.double(input$input_aero)
}
else
{
shinyalert::shinyalert("Input Error:", "Volcanic Forcing value out of bounds. Please use (0,1) as limits.", type = "error")
pass_check <- FALSE
}
}
if(pass_check == TRUE)
{
resetCore()
if(length(hcores) > 0)
loadGraph()
}
resetCore()
if(length(hcores) > 0)
loadGraph()
},
warning = function(war)
{
Expand Down
7 changes: 7 additions & 0 deletions paper/paper.bib
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,10 @@ @article{van2011rcp2
publisher={Springer},
doi = {10.1007/s10584-011-0152-3}
}
@Manual{,
title = {shiny: Web Application Framework for R},
author = {Winston Chang and Joe Cheng and JJ Allaire and Yihui Xie and Jonathan McPherson},
year = {2020},
note = {R package version 1.4.0.2},
url = {https://CRAN.R-project.org/package=shiny},
}

0 comments on commit 93a7382

Please sign in to comment.