R/tarpan-data.R

#' @include tarpan2-data.R
NULL

#' tarpan_geography_variables
#'
#' List all available Morrigu/IOP analysis variables for the selected geography
#'
#' @inheritParams tarpan2_geography_variables
#'
#' @return a list of available analysis variables for the specified geography
#' @export
tarpan_geography_variables <- tarpan2_geography_variables

#' tarpan_index_read
#'
#' List all available GP index calculation results for a given geography,
#' hazard, index class and index variable.
#'
#' @inheritParams tarpan2_index_read
#'
#' @return A list all available GP index calculation results
#' @export
tarpan_index_read <- tarpan2_index_read

#' tarpan_index_write
#'
#' Write to a Tarpan index
#'
#' @inheritParams tarpan2_index_write
#'
#' @export
tarpan_index_write <- function(hazard = c("tc", "drought"),
                               index_var, index_data, dbname = NULL) {
  hazard <- match.arg(hazard)

  if (hazard == "tc") hazard <- "tropical_cyclone"
  tarpan2_index_write(hazard = hazard, index_var = index_var,
                      index_data = index_data, dbname = dbname)
}

#' tarpan_index_delete
#'
#' Delete an index from Tarpan
#'
#' @inheritParams tarpan2_index_delete
#'
#' @export
tarpan_index_delete <- function(hazard = c("tc", "drought"),
                                index_var, dbname = NULL) {
  hazard <- match.arg(hazard)

  if (hazard == "tc") hazard <- "tropical_cyclone"
  tarpan2_index_delete(hazard = hazard, index_var = index_var,
  		       dbname = dbname)
}

#' tarpan_variable_models
#'
#' List all models, though not necessarily available for the selected variable.
#'
#' @inheritParams tarpan2_variable_models
#'
#' @return List of all models for a particular variable and geography
#' @export
tarpan_variable_models <- tarpan2_variable_models

#' tarpan_model_data
#'
#' Retrieves model data from the API
#'
#' @param geography A geography code, found in \code{tarpan1_geographies}
#' @param dbname A project database, found in \code{tarpan2_show_databases}
#' @param variable Which variable to use when querying data
#' @param model Which model to use when querying data
#' @param start Starting date to query data
#' @param end Ending date to query data
#' @param specified_variables Any specific variables to request from API.
#' Helpful for large queries.
#' @param group_by Any `specified_variables` to group results by, typically
#' grouped by a time or location variable
#' @param weight_by Name of column from `project_tbl` that is to be used to
#' group the weights, typically a spatial grouping, such as "sub_iso".
#' @param weight Name of column the `project_tbl` that is to be used to weight the
#' results, typically "branch_book". Must be used in combination with `group_by`
#' @param bc_method For model = "cfs2_hindcast", one of "resmap" or "revbc"
#' results, typically "branch_book". Must be used in combination with `group_by`
#'
#' @return Tarpan model data frame
#' @export
tarpan_model_data <- tarpan2_model_data
GlobalParametrics/taRpan_readonly documentation built on May 13, 2019, 11:23 a.m.