Skip to content

Commit

Permalink
docs: updated for version 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathancallahan committed Mar 8, 2024
1 parent 3f313f1 commit 0627bdc
Show file tree
Hide file tree
Showing 96 changed files with 281 additions and 215 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Type: Package
Package: MazamaTimeSeries
Version: 0.2.16
Version: 0.3.0
Title: Core Functionality for Environmental Time Series
Authors@R: c(
person("Jonathan", "Callahan", email="[email protected]", role=c("aut","cre")),
Expand All @@ -18,7 +18,8 @@ Description: Utility functions for working with environmental time series data f
Ephemerides calculations are based on code originally found in NOAA's
"Solar Calculator" <https://gml.noaa.gov/grad/solcalc/>.
License: GPL-3
URL: https://github.com/MazamaScience/MazamaTimeSeries
URL: https://github.com/MazamaScience/MazamaTimeSeries,
https://mazamascience.github.io/MazamaTimeSeries/
BugReports: https://github.com/MazamaScience/MazamaTimeSeries/issues
Depends:
R (>= 4.0.0)
Expand All @@ -28,7 +29,7 @@ Imports:
lubridate,
magrittr,
methods,
MazamaCoreUtils (>= 0.4.15),
MazamaCoreUtils (>= 0.5.2),
MazamaRollUtils (>= 0.1.3),
rlang,
stringr
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# MazamaTimeSeries 0.2.17

Updated dependencies:

* MazamaCoreUtils 0.4.15 => 0.5.2

* All `mts_~()` functions that return an _mts_ object now return an empty _mts_
when an empty _mts_ is used as input. This prevents breaks in the middle of
pipelines so that "emptiness" only needs to be checked at the end.
* All `sts_~()` functions that return an _sts_ object now return an empty _sts_
when an empty _sts_ is used as input.

# MazamaTimeSeries 0.2.16

* Added `mts_pull()` to get columns of data from `mts$meta` or `mts$data`.
Expand Down
4 changes: 2 additions & 2 deletions R/MazamaTimeSeries.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ NULL
#' \code{requiredMetaNames} and include:
#'
#' \itemize{
#' \item{\code{deviceDeploymentID} -- unique identifier (see \pkg{MazmaLocationUtils})}
#' \item{\code{deviceDeploymentID} -- unique identifier (see \href{https://mazamascience.github.io/MazamaLocationUtils/}{MazmaLocationUtils})}
#' \item{\code{deviceID} -- device identifier}
#' \item{\code{locationID} -- location identifier (see \pkg{MazmaLocationUtils})}
#' \item{\code{locationID} -- location identifier (see \href{https://mazamascience.github.io/MazamaLocationUtils/}{MazmaLocationUtils})}
#' \item{\code{locationName} -- English language name}
#' \item{\code{longitude} -- decimal degrees E}
#' \item{\code{latitude} -- decimal degrees N}
Expand Down
1 change: 1 addition & 0 deletions R/mts_arrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ mts_arrange <- function(
}
}

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
return(mts)

Expand Down
3 changes: 2 additions & 1 deletion R/mts_collapse.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ mts_collapse <- function(
longitude <- latitude <- NULL
}

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
stop("'mts' has no data")
return(mts)

# ----- Generate meta --------------------------------------------------------

Expand Down
5 changes: 2 additions & 3 deletions R/mts_filterData.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#' @return A subset of the incoming \emph{mts} time series object.
#' (A list with \code{meta} and \code{data} dataframes.)
#'
#' @seealso \link{mts_filterDate}
#' @seealso \link{mts_filterDatetime}
#' @seealso \link{mts_filterMeta}
#'
#' @examples
Expand Down Expand Up @@ -57,8 +55,9 @@ mts_filterData <- function(
}
}

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
stop("'mts' has no data")
return(mts)

# Remove any duplicate data records
mts <- mts_distinct(mts)
Expand Down
9 changes: 4 additions & 5 deletions R/mts_filterDate.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#'
#' @description Subsets an \emph{mts} object by date. This function
#' always filters to day-boundaries. For sub-day filtering, use
#' \code{mts_filterDatetime()}.
#' \code{mts_setTimeAxis()}.
#'
#' Dates can be anything that is understood by \code{MazamaCoreUtils::parseDatetime()}
#' including either of the following recommended formats:
Expand Down Expand Up @@ -45,9 +45,7 @@
#' @return A subset of the incoming \emph{mts} time series object.
#' (A list with \code{meta} and \code{data} dataframes.)
#'
#' @seealso \link{mts_filterData}
#' @seealso \link{mts_filterDatetime}
#' @seealso \link{mts_filterMeta}
#' @seealso \link{mts_setTimeAxis}
#'
#' @examples
#' library(MazamaTimeSeries)
Expand Down Expand Up @@ -88,8 +86,9 @@ mts_filterDate <- function(
}
}

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
stop("'mts' has no data")
return(mts)

# Remove any duplicate data records
mts <- mts_distinct(mts)
Expand Down
5 changes: 3 additions & 2 deletions R/mts_filterDatetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#' \item{get timezone from \code{mts}}
#' }
#'
#' @note This function is deprecated as of \pkg{MazamaTimeSeris 0.2.15}.
#' @note This function is deprecated as of \strong{MazamaTimeSeries 0.2.15}.
#' Please use \link{mts_setTimeAxis} to shorten or lengthen the time axis
#' of an \emph{mts} object.
#'
Expand Down Expand Up @@ -87,8 +87,9 @@ mts_filterDatetime <- function(
if ( !mts_isValid(mts) )
stop("'mts' is not a valid 'mts' object")

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
stop("'mts' has no data")
return(mts)

# Remove any duplicate data records
mts <- mts_distinct(mts)
Expand Down
9 changes: 4 additions & 5 deletions R/mts_filterMeta.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#' @description A generalized metadata filter for \emph{mts} objects to
#' choose rows/cases where conditions are true. Multiple conditions are
#' combined with \code{&} or separated by a comma. Only rows where the condition
#' evaluates to TRUE are kept. Rows where the condition evaluates to \code{NA}
#' are dropped.
#' evaluates to TRUE are kept. Rows where the condition evaluates to FALSE or
#' \code{NA} are dropped.
#'
#' If an empty \emph{mts} object is passed in, it is immediately returned,
#' allowing for multiple filtering steps to be piped together and only checking
Expand All @@ -22,10 +22,8 @@
#' @return A subset of the incoming \emph{mts} time series object.
#' (A list with \code{meta} and \code{data} dataframes.)
#'
#'
#' @seealso \link{mts_filterData}
#' @seealso \link{mts_filterDate}
#' @seealso \link{mts_filterDatetime}
#'
#' @examples
#' library(MazamaTimeSeries)
#'
Expand Down Expand Up @@ -60,6 +58,7 @@ mts_filterMeta <- function(
}
}

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
return(mts)

Expand Down
2 changes: 1 addition & 1 deletion R/mts_getDistance.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @param measure One of "geodesic", "haversine", "vincenty" or "cheap"
#'
#' @description
#' This function uses the \pkg{geodist} package to return the distances (meters)
#' This function uses the [geodist] package to return the distances (meters)
#' between \code{mts} locations
#' and a location of interest. These distances can be used to create a
#' mask identifying monitors within a certain radius of the location of interest.
Expand Down
2 changes: 1 addition & 1 deletion R/mts_pull.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' dataframe of the incoming \emph{mts} time series object.
#'
#' @description
#' This function acts similarly to \code{\link[dplyr]{pull}} working on
#' This function acts similarly to \code{dplyr::pull()} working on
#' \code{mts$meta} or \code{mts$data}. Data are returned as a simple array.
#' Data are pulled from whichever dataframe contains \code{var}.
#'
Expand Down
3 changes: 2 additions & 1 deletion R/mts_sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#' encouraged to experiment with these two parameters along with
#' \code{sampleSize} and review the results visually.
#'
#' See \code{\link[MazamaRollUtils]{findOutliers}}.
#' See \code{MazamaRollUtils::findOutliers()}.
#'

mts_sample <- function(
Expand All @@ -64,6 +64,7 @@ mts_sample <- function(

MazamaCoreUtils::stopIfNull(mts)

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
return(mts)

Expand Down
6 changes: 4 additions & 2 deletions R/mts_select.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#' time series identified by \code{deviceDeploymentID} in the order specified.
#'
#' This can be used the specify a preferred order and is helpful when using
#' faceted plot functions based on \pkg{ggplot}
#' such as those found in the \pkg{AirMonitorPlots} package.
#' faceted plot functions based on
#' \href{https://ggplot2.tidyverse.org}{ggplot}
#' such as those found in the
#' \href{https://mazamascience.github.io/AirMonitorPlots/}{AirMonitorPlots} package.
#'
#' @return A reordered (subset) of the incoming \emph{mts} time series object.
#' (A list with \code{meta} and \code{data} dataframes.)
Expand Down
3 changes: 2 additions & 1 deletion R/mts_selectWhere.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ mts_selectWhere <- function(
# Remove any duplicate data records
mts <- mts_distinct(mts)

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
stop("Parameter 'mts' has no data.")
return(mts)

if ( !is.function(FUN) )
stop("'FUN' is not a function.")
Expand Down
24 changes: 18 additions & 6 deletions R/mts_setTimeAxis.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,28 @@
#' steps with missing values. The resulting time axis is guaranteed to be
#' a regular, hourly axis with no gaps using the same timezone as the incoming
#' \emph{mts} object. This is useful when you want to place separate \emph{mts}
#' objects on the same time axis for platting.
#' objects on the same time axis for plotting.
#'
#' Dates can be anything that is understood by \code{MazamaCoreUtils::parseDatetime()}
#' including either of the following recommended formats:
#'
#' \itemize{
#' \item{\code{"YYYYmmdd"}}
#' \item{\code{"YYYY-mm-dd"}}
#' }
#'
#' Timezone determination precedence assumes that if you are passing in
#' \code{POSIXct} values then you know what you are doing:
#'
#' \enumerate{
#' \item{get timezone from \code{startdate} if it is \code{POSIXct}}
#' \item{use passed in \code{timezone}}
#' \item{get timezone from \code{mts}}
#' }
#'
#' If either \code{startdate} or \code{enddate} is missing, the start or end of
#' the timeseries in \code{mts} will be used.
#'
#' @note If \code{startdate} or \code{enddate} is a \code{POSIXct} value, then
#' \code{timezone} will be set to the timezone associated with \code{startdate}
#' or \code{enddate}.
#' In this common case, you don't need to specify \code{timezone} explicitly.
#'
#' If neither \code{startdate} nor \code{enddate} is a \code{POSIXct} value
#' AND no \code{timezone} is supplied, the timezone will be inferred from
#' the most common timezone found in \code{mts}.
Expand Down
1 change: 1 addition & 0 deletions R/mts_slice.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ mts_slice_head <- function(
}
}

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
return(mts)

Expand Down
3 changes: 2 additions & 1 deletion R/mts_summarize.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ mts_summarize <- function(
MazamaCoreUtils::stopIfNull(FUN)
MazamaCoreUtils::stopIfNull(minCount)

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
stop("'mts' has no data")
return(mts)

if ( length(unique(mts$meta$timezone)) > 1 )
stop("'mts' has muliple timezones")
Expand Down
3 changes: 2 additions & 1 deletion R/mts_trim.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ mts_trim <- function(
if ( !mts_isValid(mts) )
stop("Parameter 'mts' is not a valid 'mts' object.")

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
stop("Parameter 'mts' has no data.")
return(mts)

# Remove any duplicate data records
mts <- mts_distinct(mts)
Expand Down
3 changes: 2 additions & 1 deletion R/mts_trimDate.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ mts_trimDate <- function(
if ( !mts_isValid(mts) )
stop("Parameter 'mts' is not a valid 'mts' object.")

# Return the mts if it is empty so pipelines don't break
if ( mts_isEmpty(mts) )
stop("Parameter 'mts' has no data.")
return(mts)

# Remove any duplicate data records
mts <- mts_distinct(mts)
Expand Down
1 change: 1 addition & 0 deletions R/sts_filter.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ sts_filter <- function(
}
}

# Return the sts if it is empty so pipelines don't break
if ( sts_isEmpty(sts) )
return(sts)

Expand Down
3 changes: 2 additions & 1 deletion R/sts_filterDate.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ sts_filterDate <- function(
if ( !sts_isValid(sts) )
stop("Parameter 'sts' is not a valid 'sts' object.")

# Return the sts if it is empty so pipelines don't break
if ( sts_isEmpty(sts) )
stop("Parameter 'sts' has no data.")
return(sts)

# Remove any duplicate data records
sts <- sts_distinct(sts)
Expand Down
3 changes: 2 additions & 1 deletion R/sts_filterDatetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ sts_filterDatetime <- function(
if ( !sts_isValid(sts) )
stop("Parameter 'sts' is not a valid 'sts' object.")

# Return the sts if it is empty so pipelines don't break
if ( sts_isEmpty(sts) )
stop("Parameter 'sts' has no data.")
return(sts)

# Remove any duplicate data records
sts <- sts_distinct(sts)
Expand Down
5 changes: 3 additions & 2 deletions R/sts_summarize.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ sts_summarize <- function(
MazamaCoreUtils::stopIfNull(FUN)
MazamaCoreUtils::stopIfNull(minCount)

if ( MazamaTimeSeries::sts_isEmpty(sts) )
stop("'sts' has no data")
# Return the sts if it is empty so pipelines don't break
if ( sts_isEmpty(sts) )
return(sts)

if ( length(unique(sts$meta$timezone)) > 1 )
stop("'sts' has muliple timezones")
Expand Down
3 changes: 2 additions & 1 deletion R/sts_trimDate.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ sts_trimDate <- function(
if ( !sts_isValid(sts) )
stop("'sts' is not a valid 'sts' object")

# Return the sts if it is empty so pipelines don't break
if ( sts_isEmpty(sts) )
stop("'sts' has no data")
return(sts)

# Remove any duplicate data records
sts <- sts_distinct(sts)
Expand Down
8 changes: 4 additions & 4 deletions R/timeInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#'
#' @section Attribution:
#' Internal functions used for ephemerides calculations were copied verbatim
#' from the now deprecated \pkg{maptools} package source
#' from the now deprecated \strong{maptools} package source
#' code in an effort to reduce the number of package dependencies.
#'
#' @section Warning:
Expand All @@ -70,9 +70,9 @@
#' \url{https://ecology.wa.gov/Research-Data/Data-resources/Models-spreadsheets/Modeling-the-environment/Models-tools-for-TMDLs}), who in turn
#' translated it from original Javascript code by NOAA (see Details).
#' Roger Bivand \email{[email protected]} adapted the code to work with
#' \pkg{sp} classes. Jonathan Callahan \email{[email protected]}
#' adapted the source code from the \pkg{maptools} package to work with
#' \pkg{MazamaTimeSeries} classes.
#' \strong{sp} classes. Jonathan Callahan \email{[email protected]}
#' adapted the source code from the \strong{maptools} package to work with
#' \href{https://mazamascience.github.io/MazamaTimeSeries/}{MazmaTimeSeries} classes.
#'
#' @section References:
#' Meeus, J. (1991) Astronomical Algorithms. Willmann-Bell, Inc.
Expand Down
4 changes: 2 additions & 2 deletions R/utils-mts.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ mts_check <- function(mts) {
#' Core \code{meta} columns include:
#'
#' \itemize{
#' \item{\code{deviceDeploymentID} -- unique identifier (see \pkg{MazmaLocationUtils})}
#' \item{\code{deviceDeploymentID} -- unique identifier (see \href{https://mazamascience.github.io/MazamaLocationUtils/}{MazmaLocationUtils})}
#' \item{\code{deviceID} -- device identifier}
#' \item{\code{locationID} -- location identifier (see \pkg{MazmaLocationUtils})}
#' \item{\code{locationID} -- location identifier (see \href{https://mazamascience.github.io/MazamaLocationUtils/}{MazmaLocationUtils})}
#' \item{\code{locationName} -- English language name}
#' \item{\code{longitude} -- decimal degrees E}
#' \item{\code{latitude} -- decimal degrees N}
Expand Down
Loading

0 comments on commit 0627bdc

Please sign in to comment.