Skip to content

Commit

Permalink
Merge pull request #51 from JGCRI/dev
Browse files Browse the repository at this point in the history
HectorUI v2.0
  • Loading branch information
stephpenn1 authored Apr 16, 2022
2 parents 4670acb + 0df944c commit 74a6fea
Show file tree
Hide file tree
Showing 16 changed files with 347 additions and 303 deletions.
20 changes: 20 additions & 0 deletions .github/templates/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## HectorUI `[version]`

### Type of Change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

### Highlights ✨

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

-

### Bug Fixes 👾
-

### New Features 💡
-
18 changes: 5 additions & 13 deletions .github/workflows/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,14 @@ jobs:

- uses: r-lib/actions/setup-pandoc@v1

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
- name: Install libcurl
run: brew install openssl curl

- name: Install dependencies
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
install.packages("remotes")
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown", type = "binary")
shell: Rscript {0}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/rcmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ jobs:
RSPM: ${{ matrix.config.rspm }}

steps:
- uses: r-lib/actions/setup-pandoc@master
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@master

- name: Install dependencies
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
install.packages(c("remotes", "rcmdcheck"), repos = "https://cloud.r-project.org")
remotes::install_deps(dependencies = TRUE)
Expand Down
43 changes: 29 additions & 14 deletions .github/workflows/test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,41 @@ on: [push, pull_request]
name: build

jobs:

build:
runs-on: macOS-latest

runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
r: ['3.6']
config:
- {os: macos-latest, r: '3.6.1'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}

steps:
- uses: actions/checkout@v1
- uses: r-lib/actions/setup-r@master
with:
r-version: ${{ matrix.r }}

- uses: r-lib/actions/setup-pandoc@master
- uses: r-lib/actions/setup-tinytex@master
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@master

- name: Install dependencies
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
run: Rscript -e "install.packages(c('remotes', 'rcmdcheck', 'covr'))" -e "remotes::install_deps(dependencies = TRUE)"
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
install.packages(c("remotes", "rcmdcheck", "covr"), repos = "https://cloud.r-project.org")
remotes::install_deps(dependencies = TRUE)
shell: Rscript {0}

- name: Check
run: Rscript -e "rcmdcheck::rcmdcheck(error_on = 'error')"
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
shell: Rscript {0}

- name: Test coverage
if: matrix.r == '3.6'
run: |
Rscript -e 'remotes::install_github("r-lib/covr@gh-actions")'
Rscript -e 'covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")'
run: covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")
shell: Rscript {0}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ rsconnect
inst/shinyApp/temp.ini
inst/shinyApp/test.ini
packrat/lib*/
inst/shinyApp/lhs.R
26 changes: 26 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: HectorUI
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- family-names: Pennington
given-names: Stephanie
email: [email protected]
affiliation: Pacific Northwest National Laboratory
orcid: 'https://orcid.org/0000-0003-2685-1092'
- given-names: Chris R
family-names: Vernon
email: [email protected]
affiliation: Pacific Northwest National Laboratory
orcid: 'https://orcid.org/0000-0002-3406-6214'
identifiers:
- type: doi
value: 10.5281/zenodo.3603215
license: GPL-3.0
version: '2.0'
date-released: '2022-04-01'
14 changes: 6 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Package: hectorui
Type: Package
Title: A web-based interactive scenario builder and visualization application for the Hector climate model
Version: 1.1.4
Version: 2.0
Authors@R: c(person("Stephanie", "Pennington", email = "[email protected]", role = c("aut", "cre")),
person("Chris", "Vernon", email = "[email protected]", role = "aut"),
person("Stephanie", "Waldhoff", email = "[email protected]", role = "aut"),
person("Abigail", "Snyder", email = "[email protected]", role = "aut"),
person("Jason", "Evanoff", email = "[email protected]", role = "aut"),
person("Corinne", "Hartin", email = "[email protected]", role = "aut"))
Maintainer: Stephanie Pennington <[email protected]>
Description: Provides a simple visual, interactive web interface for the simple climate model Hector from JGCRI.
Description: Provides a simple visual, interactive web interface for the simple climate model Hector from JGCRI.
License: GPL-3
Encoding: UTF-8
LazyData: true
Imports:
Imports:
maps,
remotes,
shiny,
Expand All @@ -32,16 +32,14 @@ Imports:
Depends:
R (>= 3.6.0),
hector,
fldgen,
ggthemr
fldgen
Suggests:
testthat (>= 2.1.0),
knitr,
rmarkdown,
pkgdown
Remotes:
github::JGCRI/[email protected],
github::JGCRI/[email protected],
github::cttobin/[email protected]
github::JGCRI/hector,
github::JGCRI/[email protected]
RoxygenNote: 7.1.1
VignetteBuilder: knitr
9 changes: 3 additions & 6 deletions R/set_globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ get_globalVars <- function() {
get_globalColorScales <- function() {

globalColorScales <- vector()
globalColorScales <- c("RCP 2.6"="#db735c", "RCP 4.5"="#EFA86E", "RCP 6.0"="#9A8A76", "RCP 8.5"="#7A6752")
globalColorScales <- c("RCP 2.6" = "#5DBFDE", "RCP 4.5" = "#5CB95C", "RCP 6.0" = "#FBAB33", "RCP 8.5" ="#D7534E")


return(globalColorScales)
}
Expand Down Expand Up @@ -50,7 +51,7 @@ get_globalScenarios <- function() {
#' @export
get_globalScenarioColors <- function() {

return(c("RCP 2.6" = "#99cc33", "RCP 4.5" = "#FFFF00", "RCP 6.0" = "#ff9900", "RCP 8.5" = "#ff3333"))
return(c("RCP 2.6" = "#5DBFDE", "RCP 4.5" = "#5CB95C", "RCP 6.0" = "#FBAB33", "RCP 8.5" = "#D7534E"))
}


Expand Down Expand Up @@ -623,10 +624,6 @@ get_globalCapabilities <- function() {
globalCapabilities[['so2_a']] <- hector::EMISSIONS_SO2()
attr(globalCapabilities[['so2_a']], 'longName') <- "Anthropogenic SO2"

# "Natural CH4 Emissions"
globalCapabilities[['so2_n_ch4']] <- hector::EMISSIONS_CH4()
attr(globalCapabilities[['so2_n_ch4']], 'longName') <- "Natural CH4 Emissions"

# "Volcanic SO2"
globalCapabilities[['so2_v']] <- hector::VOLCANIC_SO2()
attr(globalCapabilities[['so2_v']], 'longName') <- "Volcanic SO2"
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ To navigate directly to the `hectorui` app **CLICK the following image**:

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")
```R
library(devtools)
devtools::install_github("JGCRI/hectorui")
```

## Developing Locally
How you launch the app after installation depends on your R environment. See the following.
Expand All @@ -38,7 +40,9 @@ Users familiar with R Shiny can add new features by working directly in the `hec

## 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: [`hector-ui` GitHub Repository](https://github.com/JGCRI/hectorui)
We welcome contributions to `hectorui` from the development community. Join in
on the conversation at the [`hector-ui` GitHub Discussions page](https://github.com/JGCRI/hectorui/discussions) or contact us if you want to
collaborate!

For more information about contributing, please contact Stephanie Pennington at [email protected] or Chris Vernon at [email protected]

Expand Down
16 changes: 0 additions & 16 deletions inst/shinyApp/observers.r
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,6 @@ openPage <- function(url) {

}


#' Change visual theme
#'
#' This function changes the RColorBrewer theme for the output components (graphs, maps) based on the input dropdown
#'
#' @return
#' @export
#'
#' @examples
changeTheme <- function()
{
ggthemr::ggthemr(stringr::str_to_lower(input$set_theme), type = "outer")
loadGraph()
}


#' Update selected index of the downscaled map's available cores
#'
#' @return
Expand Down
26 changes: 14 additions & 12 deletions inst/shinyApp/output.r
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ loadGraph <- function()

}
# Get the units for graph axis

x <- dplyr::distinct(hdata, units)
ggplotGraph <- ggplot2::ggplot(data=df_total, ggplot2::aes(x=Year, y=Value, group=variable, color=Scenario)) +
ggplotGraph <- ggplot2::ggplot(data=df_total, ggplot2::aes(x=Year, y=Value, group=Scenario, color=Scenario)) +
ggplot2::geom_line() +
ggplot2::labs(y=Hmisc::capitalize(x[[1]]), title = attr(outputVariables[[i]], 'longName')) +
ggplot2::scale_color_manual(values = globalColorScales)
Expand Down Expand Up @@ -183,13 +184,15 @@ loadMap <- function()
{
mapFill <- "\u0394 Temperature \u00B0C"
mapVar <- "deltaTemp"
mapPalette <- c("#fff7ec", "#fdbb84", "#fc8d59", "#ef6548", "#d7301f", "#b30000", "#7f0000")
}
else
{
mapFill <- "Temperature \u00B0C"
mapVar <- "Temp"
mapPalette <- c( "#4575b4", "#74add1", "#abd9e9","#e0f3f8", "#ffffbf", "#fee090", "#fdae61", "#d73027")
}
mapPalette <- "RdYlBu"

mapDirection <- -1
combined_data <- dplyr::mutate(coordinates, Temp = round(hector_annual_gridded_t[, as.numeric(input$mapYear)-1899], 2),
deltaTemp = round(hector_annual_gridded_t[, as.numeric(input$mapYear)-1899] - hector_annual_gridded_t[, 1], 2),
Expand All @@ -200,18 +203,19 @@ loadMap <- function()
# Build aesthetics based on if the compare to 1900 was checked
if(input$input_map_compare)
{
mapFill <- "\u0394 Precip. - g/m2/s"
mapFill <- "\u0394 Precip. - mm/day"
mapVar <- "deltaPrecip"
mapPalette <- c("#bf812d", "#dfc27d", "white", "#80cdc1", "#35978f", "#01665e", "#003c30")
}
else
{
mapFill <- "Precip. - g/m2/s"
mapFill <- "Precip. - mm/day"
mapVar <- "Precip"
mapPalette <- c("#fff7fb", "#67a9cf","#3690c0", "#02818a", "#016c59", "#014636")
}
mapDirection <- 1
mapPalette <- "Purples"
combined_data <- dplyr::mutate(coordinates, Precip = round(1000*hector_annual_gridded_t[, as.numeric(input$mapYear)-1899], 4),
deltaPrecip = round(1000*(hector_annual_gridded_t[, as.numeric(input$mapYear)-1899] - hector_annual_gridded_t[, 1]), 4),
combined_data <- dplyr::mutate(coordinates, Precip = round(86400*hector_annual_gridded_t[, as.numeric(input$mapYear)-1899], 4),
deltaPrecip = round(((hector_annual_gridded_t[, as.numeric(input$mapYear)-1899] - hector_annual_gridded_t[, 1]) / hector_annual_gridded_t[, 1]) * 100 , 2),
Lon=round(lon, 2), Lat=round(lat,2), Neg = ifelse(deltaPrecip < 0, TRUE, FALSE))
}

Expand Down Expand Up @@ -246,15 +250,13 @@ loadMap <- function()
}

# Create world map borders
mapWorld <- ggplot2::borders("world", fill = NA)

mapWorld <- ggplot2::borders("world")
# Construct ggplot map object
ggplotMap <- ggplot2::ggplot() +
mapWorld +
ggplot2::geom_raster(data = combined_data, ggplot2::aes_string(x="Lon", y = "Lat", fill=mapVar),interpolate = TRUE ) +
ggplot2::coord_fixed() +
ggplot2::scale_fill_distiller(palette = mapPalette,type = "div", direction = mapDirection, na.value = "Gray") + #, limits = c(-1,1)*max(abs(combined_data[[mapVar]]))) +
ggplot2::labs(x="\u00B0Longitude", y="\u00B0Latitude", title = paste0(input$mapCore, " - ", input$mapYear), fill = mapFill) +
ggplot2::scale_fill_gradientn(colors = mapPalette) + #, limits = c(-1,1)*max(abs(combined_data[[mapVar]]))) +
ggplot2::labs(x="\u00B0 Longitude", y="\u00B0 Latitude", title = paste0(input$mapCore, " - ", input$mapYear), fill = mapFill) +
ggplot2::scale_y_continuous(limits=c(lat_min, lat_max), expand = c(0, 0), breaks=seq(-90,90,30))+
ggplot2::scale_x_continuous(limits=c(lon_min, lon_max), expand = c(0, 0), breaks=seq(-180,180,30))

Expand Down
Loading

0 comments on commit 74a6fea

Please sign in to comment.