agg_hydroMet {hydroToolkit}R Documentation

Aggregate slot data

Description

This method provides common functions to aggregate the data inside a slot.

Usage

agg_hydroMet(
  obj,
  slot_name,
  col_name,
  fun,
  period,
  out_name = NULL,
  start_month = NULL,
  end_month = NULL,
  allow_NA = NULL
)

## S4 method for signature 'hydroMet_BDHI'
agg_hydroMet(
  obj,
  slot_name,
  col_name,
  fun,
  period,
  out_name = NULL,
  start_month = NULL,
  end_month = NULL,
  allow_NA = NULL
)

## S4 method for signature 'hydroMet_DGI'
agg_hydroMet(
  obj,
  slot_name,
  col_name,
  fun,
  period,
  out_name = NULL,
  start_month = NULL,
  end_month = NULL,
  allow_NA = NULL
)

## S4 method for signature 'hydroMet_CR2'
agg_hydroMet(
  obj,
  slot_name,
  col_name,
  fun,
  period,
  out_name = NULL,
  start_month = NULL,
  end_month = NULL,
  allow_NA = NULL
)

## S4 method for signature 'hydroMet_IANIGLA'
agg_hydroMet(
  obj,
  slot_name,
  col_name,
  fun,
  period,
  out_name = NULL,
  start_month = NULL,
  end_month = NULL,
  allow_NA = NULL
)

Arguments

obj

an hydroMet_XXX class object. This method is not allowed for hydroMet_compact class. This is because this class was thought as ready to use, so when building this class you should have already aggregated your data.

slot_name

a single or vector string containing the slot(s) to aggregate.

col_name

a single or vector string with the name of the column to aggregate in slot_name.

fun

a single or vector string containing one of the following functions: mean, min, max or sum.

period

a single or vector string with the period of aggregation: hourly, daily, monthly, annual or climatic. NOTE_1: the 'climatic' option returns the all series annual statistics ('fun'). NOTE_2: if the object is of class hydroMet_IANIGLA you must provide a single period value.

out_name

optional. Single or vector string with the output column name of the variable to aggregate.

start_month

optional. Numeric (or numeric vector) value of the first month. It only makes sense if the period is annual. NOTE: as an example, in case you have just two slots (out of five) that you want to aggregate annually you must provide a vector of length two. Default value is January. NOTE*: if the object is of class hydroMet_IANIGLA you must provide a single start_month value.

end_month

optional. Numeric (or numeric vector) value of the last month. It only makes sense if the period is annual. NOTE: as an example, in case you have just two slots (out of five) that you want to aggregate annually you must provide a vector of length two. Default value es December. NOTE*: if the object is of class hydroMet_IANIGLA you must provide a single end_month value.

allow_NA

optional. Numeric (or numeric vector) value with the maximum allowed number of NA_real_ values. By default the function will not tolerate any NA_real_ in an aggregation period (and will return NA_real_ instead).

Value

An hydroMet_XXX class object with the required slot(s) aggregated.

Functions

Examples

# Create BDHI hydro-met station
guido <- create_hydroMet(class_name = 'BDHI')

# List with meteorological variables (slots in BDHI's object)
cargar <- list('precip', 'Qmd', 'Qmm')

# Assign as names the files
hydro_files   <- list.files( system.file('extdata', package = "hydroToolkit"), pattern = 'Guido' )
names(cargar) <- hydro_files

# Build the object with the met records
guido <- build_hydroMet(obj = guido, slot_list = cargar, 
               path = system.file('extdata', package = "hydroToolkit") )

# Aggregrate precipitation serie
guido <- agg_hydroMet(obj = guido, slot_name = 'precip', col_name = 'precip', fun = 'sum',
       period = 'monthly', out_name = 'P_month', allow_NA = 3)
               

[Package hydroToolkit version 0.1.0 Index]