R/pull_stations.R

Defines functions pull_stations.harp_fcst pull_stations.default pull_stations

Documented in pull_stations

#' Pull station IDs from forecast or observations
#'
#' @param .fcst A harp_fcst object or data frame
#'
#' @return A vector of station IDs
#' @export
pull_stations <- function(.fcst) {
  UseMethod("pull_stations")
}

#' @export
pull_stations.default <- function(.fcst) {
  if (!is.element("SID", colnames(.fcst))) {
    return(integer())
  }
  unique(.fcst[["SID"]])
}

#' @export
pull_stations.harp_fcst <- function(.fcst) {
  sort(unique(unlist(lapply(.fcst, pull_stations))))
}
andrew-MET/harpPoint documentation built on Feb. 23, 2023, 1:06 a.m.