Skip to content

Commit

Permalink
Improve documentation and README
Browse files Browse the repository at this point in the history
  • Loading branch information
anacv committed Jul 1, 2019
1 parent f6de6d5 commit ca692f1
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 16 deletions.
13 changes: 6 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
Package: HeatStress
Type: Package
Title: Calculate heat stress indices
Version: 1.0.6
Date: 2019-03-11
Version: 1.0.7
Date: 2019-07-01
Author: A. Casanueva
Maintainer: A.Casanueva <ana.casanueva@meteoswiss.ch>
Description: Calculate heat stress indices based on meteorological data.
License: file LICENCE
RoxygenNote: 6.0.1
Depends: R (>= 2.10.0)
License: file LICENSE
RoxygenNote: 6.1.1
Depends: R (>= 2.10.0), magrittr
Suggests: testthat, assertthat
Imports: stats
Encoding: ISO-8859-1

Encoding: UTF-8
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ export(fTg)
export(fTnwb)
export(hi)
export(humidex)
export(indexShow)
export(swbgt)
export(tashurs2vap.pres)
export(wbgt.Bernard)
export(wbgt.Liljegren)
export(wbt.Stull)
importFrom(magrittr,"%>%")
importFrom(stats,optimize)
importFrom(utils,packageDescription)
importFrom(utils,read.table)
8 changes: 7 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ Changes in version 1.0.4
* Inclusion of more heat indices.

Changes in version 1.0.5
* Arrange assert statments in wrapper function to speed up calculation of wbgt.Liljegren.
* Arrange assert statments in wrapper function to speed up calculation of wbgt.Liljegren.

Changes in version 1.0.6
* Correct bug in assertion statement.

Changes in version 1.0.7
* Update README.md
15 changes: 12 additions & 3 deletions R/HeatStress.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
#'
#' The package \code{HeatStress} provides methods to calculate heat stress indices.
#'
#' @name HeatStress
#' @docType package
#' Check the details of the indices and input variables:
#'
#' \code{library(HeatStress)}
#'
#' \code{indexShow()}
#'
#'
#'
#' @details
#'
#' The following calculation methods are implemented:
Expand All @@ -21,6 +27,9 @@
#' \item \code{discomInd}: Calculation of the discomfort index (Coccolo et al. 2016 and references therein).
#' \item \code{hi}: Calculation of the heat index (Buzan et al. 2015 and references therein).

#' }
#' }
#' @name HeatStress
#' @docType package
#'
NULL
#"_PACKAGE"
27 changes: 27 additions & 0 deletions R/indexShow.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#' @title List all available heat indices
#' @description Print a table with a summary of the available indices
#' @return Print a table on the screen with the following columns:
#' \itemize{
#' \item \strong{code}: Code of the index.
#' \item \strong{longname}: Long description of the index
#' \item \strong{index.fun}: The name of the internal function used to calculate it
#' \item \strong{tas, dewp, hurs, wind, radiation}: A logical value (0/1) indicating the input variables required for index calculation. Temperature and either dew point temperature or relative humidity need to be always provided.
#' \item \strong{units}: The units of the index.
#' }
#' @author A. Casanueva
#' @export

indexShow <- function() {
read.master()
}

#' @keywords internal
#' @importFrom magrittr %>%
#' @importFrom utils read.table

read.master <- function() {
system.file("master", package = "HeatStress") %>% read.table(header = TRUE,
sep = ";",
stringsAsFactors = FALSE,
na.strings = "")
}
32 changes: 32 additions & 0 deletions R/rhooks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#' @importFrom utils packageDescription

.onAttach <- function(...) {
pkgname <- "HeatStress"
ver <- packageDescription(pkgname)$Version
builddate <- packageDescription(pkgname)$Date
mess <- paste(pkgname, " version ", ver, " (", builddate,") is loaded", sep = "")
packageStartupMessage(mess)
url <- paste0("https://raw.githubusercontent.com/anacv/", pkgname, "/master/DESCRIPTION")
b <- tryCatch(suppressWarnings(readLines(url)), error = function(er) {
er <- NULL
return(er)
})
if (!is.null(b)) {
latest.ver <- package_version(gsub("Version: ", "", b[grep("^Version", b)]))
if (ver < latest.ver) {
ver.mess1 <- paste0("WARNING: Your current version of ", pkgname, " (v", ver, ") is not up-to-date")
ver.mess <- paste0("Get the latest stable version (", latest.ver,
") using <devtools::install_github('anacv/", pkgname, "')>")
packageStartupMessage(ver.mess1)
packageStartupMessage(ver.mess)
} else if (ver > latest.ver) {
ver.mess1 <- paste0("WARNING: Your current version of ", pkgname, " (v", ver,
") is ahead of the master branch version (", latest.ver, ")")
ver.mess <- paste0("Development version may have an unexpected behaviour")
packageStartupMessage(ver.mess1)
packageStartupMessage(ver.mess)
}
}
packageStartupMessage("Use 'indexShow()' for an overview of the available heat indices")
}
# End
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
# HeatStress
Heat Stress indices for Heat-Shield

## What is `HeatStress`?

**HeatStress** is a R package for the calculation of heat stress indices. It has been developed in the framework of the Horizon2020 [HEAT-SHIELD project](www.heat-shield.eu).

****

### Installation

The recommended procedure for installing the package is using the devtools package.

```R
devtools::install_github("anacv/HeatStress")
```

A list of all available indices and the atomic functions calculating them is printed on screen with:

```R
library(HeatStress)
indexShow()
```

### Reference and further information:

This package was used in the development of climate change scenarios of heat stress, in the following publications:
* Casanueva et al. 2019. Climate projections of a multi-variate heat stress index: the role of downscaling and bias correction, *Geoscientific Model Development*, https://www.geosci-model-dev-discuss.net/gmd-2018-294/
* Casanueva et al. 2019. Escalating environmental heat exposure – a future threat for the European workforce, *Regional Environmental Change*.
11 changes: 11 additions & 0 deletions inst/master
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
code;longname;indexfun;tas;dewp;hurs;wind;radiation;units
wbt;Wet Bulb Temperature; wbt.Stull;1;0;1;0;0;degC
wbgt_shade;Wet Bulb Globe Temperature (shade);wbgt.Bernard;1;1;0;0;0;degC
wbgt_sun;Wet Bulb Globe Temperature (sun);wbgt.Liljegren;1;1;0;1;1;degC
swbgt;simplified wet bulb globe temperature;swbgt;1;0;1;0;0;degC
apparentTemp;apparent temperature;apparentTemp;1;0;1;1;0;degC
effectiveTemp;effective temperature;effectiveTemp;1;0;1;1;0;degC
humidex;humidex;humidex;1;0;1;0;0;degC
discomInd;discomfort index;discomInd;1;0;1;0;0;degC
hi;heat index;hi;1;0;1;0;0;degF

6 changes: 6 additions & 0 deletions man/HeatStress.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/fTnwb.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/indexShow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/wbgt.Bernard.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/wbgt.Liljegren.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ca692f1

Please sign in to comment.