Skip to content

Commit

Permalink
Update master to current devel version
Browse files Browse the repository at this point in the history
  • Loading branch information
retostauffer committed Aug 8, 2019
1 parent 713e18b commit 8f78dcb
Show file tree
Hide file tree
Showing 151 changed files with 2,426 additions and 72,326 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@


# Raw data folder
^data-raw$

# Ignore git, travis, and pkgdown
^\.git$
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ src/*.o
src/*.so
src/*.gcda
src/*.gcno

# Ignore packed files (usethis::use_data)
data/ellboegen.rda
data/sattelberg.rda
data/viejas.rda
data/luckyfive.rda
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ before_install:


r:
- oldrel
- release
#- devel
- devel

r_packages:
- devtools
Expand Down
17 changes: 17 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,26 @@
* There is one import ":::" (cgaussian family) in one of the
examples -> illegal!
* A separate `windrose` vignette might be nice.
* ... started a separate vignette for `tsplot`, implement separate
vignettes for `windrose` and `image`.
* Allow to add a wind sector when using `windrose.default`,
Similar for `foehnix` models given the user-defined `dd`, `ff`
names.
* Added second demo data set "Viejas and Lucky Five Ranch (CA, USA)";
modified the `demodata(...)` function to be able to handle both
(multiple) demo data sets.
* Data sets (`ellboegen`, `sattelberg`, `viejas`, `luckyfive`) now stored
as binary time series objects (`.rda`; `zoo`).

# foehnix 0.1-2 (August 2019; development stage)

* Additional functionality added to `image.foehnix` (custom `xlim` and `ylim`,
allow for custom `style` files).
* Revamped/simplified internal structure of `image.foehnix`.
* Updated the demo data sets (Ellboegen and Sattelberg); quality-controlled
updated extended data set (by Deborah Detka). Moved from csv to rda
using `usethis`; reduces package size; added data/scripts in `data-raw`.
* Moved generic `image` function (`image.foehnix`) to `R/image.R`.

# foehnix 0.1-2 (August 2019)

Expand Down
109 changes: 97 additions & 12 deletions R/datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' Meteorological Observation Data, Station Ellboegen
#'
#' The \code{\link{foehnix}} package comes with two data sets of meteorological
#' observations for two sites in Tyrol, Austria. One station is located nearby
#' observations for two sites in Tyrol, Austria. One station is located near
#' Ellboegen, a small town close to Innsbruck, the second station (Sattelberg)
#' is located south of Ellboegen close to the border between Austria and Italy
#' on top of a mountain close to the crest of the European Alps and is used as
Expand All @@ -22,30 +22,31 @@
#' \item Altitude: 1080 meters above mean sea level
#' }
#'
#' Variable description (columns):
#' \code{zoo} time series object with an hourly temporal resolution (time zone: UTC)
#' including the following variables:
#' \itemize{
#' \item \code{timestamp}: UNIX time stamp, seconds since 1970-01-01 00:00:00
#' \item \code{dd}: wind direction in degrees, meteorological format
#' (0/360 correspond to 'wind from north', 90 to 'wind from east',
#' 180 'wind from south', and 270 'wind from west'
#' 180 'wind from south', and 270 'wind from west')
#' \item \code{ff}: wind speed in meters per second
#' \item \code{p}: station pressure in hectopascal
#' \item \code{rh}: relative humidity in percent
#' \item \code{t}: dry air temperature in degrees Celsius
#' }
#'
#' @seealso \code{\link{sattelberg}}, \code{\link{demodata}}.
#' @seealso \code{\link{sattelberg}}, \code{\link{demodata}},
#' \code{\link{viejas}}, \code{\link{luckyfive}}.
#'
#' @name ellboegen
#' @docType data
#' @keywords data ellboegen
#' @author Reto Stauffer
#' @author Reto Stauffer, Deborah Detka
NULL

#' Meteorological Observation Data, Station Sattelberg
#'
#' The \code{\link{foehnix}} package comes with two data sets of meteorological
#' observations for two sites in Tyrol, Austria. One station is located nearby
#' observations for two sites in Tyrol, Austria. One station is located near
#' Ellboegen (see \code{\link{ellboegen}}), a small town close to Innsbruck,
#' the second station (Sattelberg) is located south of Ellboegen close to the
#' border between Austria and Italy on top of a mountain close to the crest of
Expand All @@ -65,23 +66,107 @@ NULL
#' \item Altitude: 2107 meters above mean sea level
#' }
#'
#' Variable description (columns):
#' \code{zoo} time series object with an hourly temporal resolution (time zone: UTC)
#' including the following variables:
#' \itemize{
#' \item \code{timestamp}: UNIX time stamp, seconds since 1970-01-01 00:00:00
#' \item \code{dd}: wind direction in degrees, meteorological format
#' (0/360 correspond to 'wind from north', 90 to 'wind from east',
#' 180 'wind from south', and 270 'wind from west'
#' 180 'wind from south', and 270 'wind from west')
#' \item \code{ff}: wind speed in meters per second
#' \item \code{p}: station pressure in hectopascal
#' \item \code{rh}: relative humidity in percent
#' \item \code{t}: dry air temperature in degrees Celsius
#' }
#'
#' @seealso \code{\link{ellboegen}}, \code{\link{demodata}}.
#' @seealso \code{\link{sattelberg}}, \code{\link{demodata}},
#' \code{\link{viejas}}, \code{\link{luckyfive}}.
#'
#' @name sattelberg
#' @docType data
#' @keywords data sattelberg
#' @author Reto Stauffer
#' @author Reto Stauffer, Deborah Detka
NULL

#' Meteorological Observation Data, Station Viejas
#'
#' The \code{\link{foehnix}} package comes with two data sets of meteorological
#' observations for two sites in south California, USA. One station is located
#' next to the Viejas Casino and Resort located in Alpine, CA (valley station),
#' the second station called 'Lucky Five Ranch' is located 22km (14mi)
#' northwest of the Viejas Casino close to the main ridge of the Sierra Nevada
#' mountain range and is used as the crest station.
#'
#' @usage data("viejas")
#'
#' @source Station operated by San Diego Gas and Electric and made freely
#' publicly available through Synoptic PBC at \url{https://synopticdata.com/}.
#'
#' @details
#' Viejas Casino and Resort:
#' \itemize{
#' \item Location: -116.70437 E/32.84559 N
#' \item Altitude: 715 meters above mean sea level
#' }
#'
#' \code{zoo} time series object with an hourly temporal resolution (time zone: UTC)
#' including the following variables:
#' \itemize{
#' \item \code{air_temp}: dry air temperature in degrees Celsius
#' \item \code{relative_humidity}: relative humidity in percent
#' \item \code{wind_speed}: wind speed in meters per second
#' \item \code{wind_direction}: wind direction in degrees, meteorological format
#' (0/360 correspond to 'wind from north', 90 to 'wind from east',
#' 180 'wind from south', and 270 'wind from west')
#' \item \code{wind_gust}: wind gust speed in meters per second
#' }
#'
#' @seealso \code{\link{sattelberg}}, \code{\link{demodata}},
#' \code{\link{viejas}}, \code{\link{luckyfive}}.
#'
#' @name viejas
#' @docType data
#' @keywords data viejas
#' @author Reto Stauffer, Georg J. Mayr


#' Meteorological Observation Data, Lucky Five Ranch
#'
#' The \code{\link{foehnix}} package comes with two data sets of meteorological
#' observations for two sites in south California, USA. One station is located
#' next to the Viejas Casino and Resort located in Alpine, CA (valley station),
#' the second station called 'Lucky Five Ranch' is located 22km (14mi)
#' northwest of the Viejas Casino close to the main ridge of the Sierra Nevada
#' mountain range and is used as the crest station.
#'
#' @usage data("luckyfive")
#'
#' @source Station operated by San Diego Gas and Electric and made freely
#' publicly available through Synoptic PBC at \url{https://synopticdata.com/}.
#'
#' @details
#' Lucky Five Ranch:
#' \itemize{
#' \item Location: -116.528 E/32.9331 N
#' \item Altitude: 1445 meters above mean sea level
#' }
#'
#' \code{zoo} time series object with an hourly temporal resolution (time zone: UTC)
#' including the following variables:
#' \itemize{
#' \item \code{air_temp}: dry air temperature in degrees Celsius
#' \item \code{relative_humidity}: relative humidity in percent
#' \item \code{wind_speed}: wind speed in meters per second
#' \item \code{wind_direction}: wind direction in degrees, meteorological format
#' (0/360 correspond to 'wind from north', 90 to 'wind from east',
#' 180 'wind from south', and 270 'wind from west')
#' \item \code{wind_gust}: wind gust speed in meters per second
#' }
#'
#' @seealso \code{\link{sattelberg}}, \code{\link{demodata}},
#' \code{\link{viejas}}, \code{\link{luckyfive}}.
#'
#' @name luckyfive
#' @docType data
#' @keywords data luckyfive
#' @author Reto Stauffer, Georg J. Mayr
NULL
120 changes: 74 additions & 46 deletions R/demodata.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# -------------------------------------------------------------------
# - NAME: demodata.R
# - AUTHOR: Reto Stauffer
# - DATE: 2019-01-16
# -------------------------------------------------------------------
# - DESCRIPTION: A small function which returns the demo data set.
# -------------------------------------------------------------------
# - EDITORIAL: 2019-01-16, RS: Created file on thinkreto.
# -------------------------------------------------------------------
# - L@ST MODIFIED: 2019-01-24 12:26 on marvin
# -------------------------------------------------------------------


#' foehnix Demo Data Set
#'
Expand All @@ -24,63 +12,103 @@
#' crest station as concomitant variables and for custom wind
#' filters (\code{\link{foehnix_filter}}).
#'
#' @param which either \code{"combined"} (returns a combined data set),
#' \code{"sattelberg"} (only observations from station Sattelberg),
#' or \code{"ellboegen"} (only observations rom station Ellboegen).
#' @param which the \code{foehnix} package comes with two demo data sets.
#' Each consists of meteorological observations of two stations (one
#' in the valley; target station) and one near the crest upstream of
#' typical foehn direction (crest station).
#' \code{which = "tyrol"} returns the tyrolean data set (A),
#' \code{which = "california"} the californian data set (USA), a time series
#' object which contains measurements from both stations (valley/crest).
#' The function can also be used to get the demo data sets for specific sites
#' (see 'Examples').
#'
#' @source Station operated by the Department of Atmospheric and Cryospheric
#' @source
#' Ellboegen and Sattelberg:
#' Operated by the Department of Atmospheric and Cryospheric
#' Sciences (\url{http://acinn.uibk.ac.at}) of the University of Innsbruck.
#' The data is available under the
#' \href{https://creativecommons.org/licenses/by-sa/4.0/}{CC BY-SA 4.0 license}.
#'
#' Viejas and the Lucky Five Ranch:
#' Operated by #TODO add correct source (GM).
#'
#' @examples
#' # Loading the combined demo data set. Variables starting with
#' # "crest_" are observations from station Sattelberg.
#' x <- demodata()
#' # Loading the combined demo data set for "Tyrol (A)".
#' # Stations: Ellboegen (valley station) and Sattelberg (crest station).
#' # Variables starting with "crest_" are observations from station Sattelberg,
#' x <- demodata("tyrol") # Default
#' print(head(x))
#'
#' # Loading the combined demo data set for "California (USA)".
#' # Stations: Viejas (valley station) and 'Lucky Five Ranch' (crest station).
#' # Variables starting with "crest_" are observations from station 'Lucky Five Ranch'.
#' x <- demodata("california")
#' print(head(x))
#'
#' # Sattelberg only
#' x <- demodata("sattelberg")
#' print(head(x))
#'
#' # Ellboegen only
#' # Solely Ellboegen
#' x <- demodata("ellboegen")
#' print(head(x))
#'
#' @seealso \code{\link{ellboegen}}, \code{\link{sattelberg}}
#' # Viejas
#' x <- demodata("viejas")
#' print(head(x))
#'
#' # Lucky Five Ranch
#' x <- demodata("luckyfive")
#' print(head(x))
#'
#' @seealso \code{\link{ellboegen}}, \code{\link{sattelberg}},
#' \code{\link{viejas}}, \code{\link{luckyfive}}
#'
#' @author Reto Stauffer
#' @export
demodata <- function(which = "combined") {
demodata <- function(which = c("tyrol", "ellboegen", "sattelberg",
"california", "viejas", "luckyfive")) {

# Match arg
which <- match.arg(which)

which <- match.arg(tolower(which), c("combined", "ellboegen", "sattelberg"))
# Loading observations (data.frame) from two CSV files
# which come with the foehnix package.
if ( any(c("ellboegen", "combined") %in% which) ) {
data("ellboegen", package = "foehnix")
ellboegen <- zoo::zoo(ellboegen[,-1], as.POSIXct(ellboegen[,1], origin = "1970-01-01"))
# For combined stations
if (which == "tyrol") {
stations <- list(valley = "ellboegen", crest = "sattelberg")
} else if (which == "california") {
stations <- list(valley = "viejas", crest = "luckyfive")
} else {
stations <- which # keep it as character
}
if ( any(c("sattelberg", "combined") %in% which) ) {
data("sattelberg", package = "foehnix")
sattelberg <- zoo::zoo(sattelberg[,-1], as.POSIXct(sattelberg[,1], origin = "1970-01-01"))

# Single station?
if (is.character(stations)) {
obj <- do.call(data, list(stations, package = "foehnix"))
return(eval(parse(text = obj[1L])))
}

# Convert the data.frames into time series objects.
if ( which == "ellboegen" ) return(ellboegen)
if ( which == "sattelberg" ) return(sattelberg)

# Else combine both data sets
# Else load both stations, rename, and combine.
stopifnot(identical(sort(names(stations)), c("crest", "valley")))

# Modify sattelberg variable names (crest_ identifies Sattelberg
# observations, our crest station) and combine both data sets.
names(sattelberg) <- paste0("crest_", names(sattelberg))
data <- merge(ellboegen, sattelberg)

# Dry adiabatic temperature difference between
# Sattelberg (data$crest_t) and Ellboegen (data$t) corrected by
# 1027/10 degrees.
data$diff_t <- data$crest_t + 10.27 - data$t
# Load data sets
obj <- data(list = stations, package = "foehnix")
data <- lapply(obj, function(x) return(eval(parse(text = x))))

return(data)
# Rename crest station variables
names(data$crest) <- sprintf("crest_%s", names(data$crest))
data <- do.call(merge, c(data, list(all = TRUE)))

# Dry adiabatic temperature difference between ...
if (which == "tyrol") {
# Sattelberg (data$crest_t) and Ellboegen (data$t) corrected by
# 1027 / 100 degrees K (1027 meters of difference in altitude).
data$diff_t <- data$crest_t + 10.27 - data$t
} else if (which == "california") {
# Lucky Five Ranch (data$crest_air_temp) and Viejas (data$air_temp) corrected by
# 730 / 100 degrees K (730 meters of difference in altitude)
data$diff_temp <- data$crest_air_temp + 7.30 - data$air_temp
}

return(data)
}

3 changes: 1 addition & 2 deletions R/foehnix.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# -------------------------------------------------------------------
# - EDITORIAL: 2018-11-28, RS: Created file on thinkreto.
# -------------------------------------------------------------------
# - L@ST MODIFIED: 2019-04-18 17:11 on marvin
# - L@ST MODIFIED: 2019-08-07 16:39 on marvin
# -------------------------------------------------------------------


Expand Down Expand Up @@ -774,7 +774,6 @@ foehnix <- function(formula, data, switch = FALSE, filter = NULL,
# statistical models.
filter_obj <- foehnix_filter(data, filter)


# Take all elements which are not NA and where the
# foehnix_filter routine returned an index on "good" (not
# removed due to filter rules OR due to missing values).
Expand Down
2 changes: 1 addition & 1 deletion R/foehnix_filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# -------------------------------------------------------------------
# - EDITORIAL: 2018-12-19, RS: Created file on thinkreto.
# -------------------------------------------------------------------
# - L@ST MODIFIED: 2019-04-15 17:43 on marvin
# - L@ST MODIFIED: 2019-08-07 16:31 on marvin
# -------------------------------------------------------------------


Expand Down
Loading

0 comments on commit 8f78dcb

Please sign in to comment.