build_hydroMet {hydroToolkit}R Documentation

Automatically load native data files

Description

This method is the recommended one for loading your data-sets (as provided by the agency).

Usage

build_hydroMet(
  obj,
  slot_list,
  path = NULL,
  col_names = NULL,
  start_date = NULL,
  end_date = NULL
)

## S4 method for signature 'hydroMet_BDHI'
build_hydroMet(obj, slot_list, path = NULL)

## S4 method for signature 'hydroMet_CR2'
build_hydroMet(obj, slot_list, path = NULL)

## S4 method for signature 'hydroMet_DGI'
build_hydroMet(obj, slot_list, path = NULL)

## S4 method for signature 'hydroMet_IANIGLA'
build_hydroMet(obj, slot_list, path = NULL)

## S4 method for signature 'hydroMet_compact'
build_hydroMet(
  obj,
  slot_list,
  col_names = NULL,
  start_date = NULL,
  end_date = NULL
)

Arguments

obj

an hydroMet_XXX class object (see create_hydroMet).

slot_list

a list containing (in each element) a vector string with the slot names. The name of the list elements are the native file names (e.g.: Qmd_Guido_BDHI.txt). NOTE: when the obj argument is of class hydroMet_compact, slot_list allows to build from multiple objects. So, in this case you have to provide a list of list: the top list contains as names the objects names (as you read them from Global Environment); then every object (top level) contains another list with slot names as names and the column(s) number(s) to extract as numeric value. E.g.: list(bdhi_obj = list(Qmd = 2, Qmm = c(2, 5)), cr2_obj = list(precip = 4) ).

path

string with the files directory. If not provided, the method will use the current working directory. NOTE: this argument is harmless for an object of class hydroMet_compact.

col_names

it just make sense if 'obj' argument is of hydroMet_compact class. String vector with the names of the column output. Default value (NULL) will return expressive column names.

start_date

it just make sense if 'obj' argument is of hydroMet_compact class. String or POSIXct with the starting date to extract. You can use start_date without end_date. In this case you will subset your data from start_date till the end.

end_date

it just make sense if 'obj' argument is of hydroMet_compact class. String or POSIXct with the last date to extract. You can use end_date without start_date. In this case you will subset your data from the beginning till end_date.

Value

An S4 object of class hydroMet_XXX with the data loaded in each slot.

Functions

Examples

# Path to file
dgi_path  <- system.file('extdata', package = "hydroToolkit")
file_name <- list.files(path = dgi_path, pattern = 'Toscas')

# Read Toscas
var_nom <- list(slotNames(x = 'hydroMet_DGI')[2:7])
names(var_nom) <- file_name

# Load Toscas meteo station data
toscas_dgi <- create_hydroMet(class_name = 'DGI')
toscas_dgi <- build_hydroMet(obj = toscas_dgi, slot_list = var_nom,
                 path = dgi_path)


[Package hydroToolkit version 0.1.0 Index]