Title: | Hydrological Tools for Handling Hydro-Meteorological Data from Argentina and Chile |
---|---|
Description: | Read, plot, manipulate and process hydro-meteorological data from Argentina and Chile. |
Authors: | Ezequiel Toum <[email protected]> |
Maintainer: | Ezequiel Toum <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.0 |
Built: | 2025-02-13 05:44:36 UTC |
Source: | https://github.com/cran/hydroToolkit |
This method provides common functions to aggregate the data inside a slot.
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 )
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 )
obj |
an |
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 |
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 |
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 |
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 |
allow_NA |
optional. Numeric (or numeric vector) value with the maximum allowed number of |
An hydroMet_XXX
class object with the required slot(s) aggregated.
agg_hydroMet,hydroMet_BDHI-method
: aggregation method for BDHI data
agg_hydroMet,hydroMet_DGI-method
: aggregation method for DGI data
agg_hydroMet,hydroMet_CR2-method
: aggregation method for CR2 data
agg_hydroMet,hydroMet_IANIGLA-method
: aggregation method for IANIGLA data
# 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)
# 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)
This is a useful function to easily aggregate your data.
agg_serie( df, fun, period, out_name, start_month = NULL, end_month = NULL, allow_NA = NULL )
agg_serie( df, fun, period, out_name, start_month = NULL, end_month = NULL, allow_NA = NULL )
df |
data frame with class |
fun |
string containing one of the following functions: mean, min, max or sum. |
period |
string with the period of aggregation: hourly, daily, monthly, annual or climatic. NOTE: the 'climatic' option returns the all series annual statistics ('fun'). |
out_name |
string with the output column name of the variable to aggregate. |
start_month |
optional. Numeric value of the first month. It only makes sense if the period is annual. |
end_month |
optional. Numeric value of the last month. It only makes sense if the period is annual. |
allow_NA |
optional. Numeric value with the maximum allowed number of |
A data frame with to columns: the date and the aggregated variable.
# Path to file dgi_path <- system.file('extdata', package = "hydroToolkit") toscas <- read_DGI(file = 'Toscas.xlsx', sheet = 'tmean', path = dgi_path) # Monthly mean temperature m_toscas <- agg_serie(df = toscas, fun = 'mean', period = 'monthly', out_name = 'T_month')
# Path to file dgi_path <- system.file('extdata', package = "hydroToolkit") toscas <- read_DGI(file = 'Toscas.xlsx', sheet = 'tmean', path = dgi_path) # Monthly mean temperature m_toscas <- agg_serie(df = toscas, fun = 'mean', period = 'monthly', out_name = 'T_month')
This method is the recommended one for loading your data-sets (as provided by the agency).
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 )
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 )
obj |
an |
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 |
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 |
col_names |
it just make sense if |
start_date |
it just make sense if |
end_date |
it just make sense if |
An S4 object of class hydroMet_XXX
with the data loaded in each slot.
build_hydroMet,hydroMet_BDHI-method
: build up method for BDHI class
build_hydroMet,hydroMet_CR2-method
: build up method for CR2 class
build_hydroMet,hydroMet_DGI-method
: build up method for DGI class
build_hydroMet,hydroMet_IANIGLA-method
: build up method for IANIGLA class
build_hydroMet,hydroMet_compact-method
: build up method for compact
class
# 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)
# 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)
This function is the constructor of hydroMet
class and its subclasses.
create_hydroMet(class_name = "hydroMet")
create_hydroMet(class_name = "hydroMet")
class_name |
string with the name of the class. Valid arguments are: |
an S4 object of class hydroMet
# Create class 'hydroMet' met_station <- create_hydroMet(class_name = 'hydroMet') # Subclass 'BDHI' bdhi_station <- create_hydroMet(class_name = 'BDHI') # Subclass 'DGI' dgi_station <- create_hydroMet(class_name = 'DGI') # Subclass 'CR2' cr2_station <- create_hydroMet(class_name = 'CR2') # Subclass 'IANIGLA' ianigla_station <- create_hydroMet(class_name = 'IANIGLA')
# Create class 'hydroMet' met_station <- create_hydroMet(class_name = 'hydroMet') # Subclass 'BDHI' bdhi_station <- create_hydroMet(class_name = 'BDHI') # Subclass 'DGI' dgi_station <- create_hydroMet(class_name = 'DGI') # Subclass 'CR2' cr2_station <- create_hydroMet(class_name = 'CR2') # Subclass 'IANIGLA' ianigla_station <- create_hydroMet(class_name = 'IANIGLA')
NA_real_
This function complete non-reported dates and assign NA_real_
as their value.
fill_serie(df, colName, timeStep)
fill_serie(df, colName, timeStep)
df |
data frame with date and numeric vector as first and second column respectively. |
colName |
output colname of the numeric variable, e.g.: 'Qmd(m3/s)'. |
timeStep |
character with a valid time step: 'day', 'month', '4h', 'day/3', 'hour'. |
A data frame with missing time steps filled with NA's.
# Create a data frame dates <- seq.Date(from = as.Date('1990-01-01'), to = as.Date('1990-12-01'), by = 'm') met_var <- runif(n = 12, 0, 10) met_serie <- data.frame(dates, met_var) # Fill serie met_fill <- fill_serie(df = met_serie, colName = 'Temp', timeStep = 'day')
# Create a data frame dates <- seq.Date(from = as.Date('1990-01-01'), to = as.Date('1990-12-01'), by = 'm') met_var <- runif(n = 12, 0, 10) met_serie <- data.frame(dates, met_var) # Fill serie met_fill <- fill_serie(df = met_serie, colName = 'Temp', timeStep = 'day')
Assign specific values to a time interval.
fill_value(df, col, value, from, to)
fill_value(df, col, value, from, to)
df |
data frame with the first column being the date and the others numeric variables. |
col |
numeric vector with column(s) number(s) to be filled. |
value |
numeric or |
from |
character, Date or POSIXct with the first date to be filled. |
to |
character, Date or POSIXct with the last date to be filled. |
A data frame filled with the value in the specified time period.
# Create a data frame dates <- seq.Date(from = as.Date('1990-01-01'), to = as.Date('1990-12-01'), by = 'm') met_var <- runif(n = 12, 0, 10) met_serie <- data.frame(dates, met_var) # Fill serie met_fill <- fill_serie(df = met_serie, colName = 'Temp', timeStep = 'day') # Now fill value met_fill <- fill_value(df = met_fill, col = 2, value = 10, from = '1990-02-01', to = '1990-02-15')
# Create a data frame dates <- seq.Date(from = as.Date('1990-01-01'), to = as.Date('1990-12-01'), by = 'm') met_var <- runif(n = 12, 0, 10) met_serie <- data.frame(dates, met_var) # Fill serie met_fill <- fill_serie(df = met_serie, colName = 'Temp', timeStep = 'day') # Now fill value met_fill <- fill_value(df = met_fill, col = 2, value = 10, from = '1990-02-01', to = '1990-02-15')
Extract the slots that you want from an hydroMet
or hydroMet_XXX
class.
get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_BDHI' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_DGI' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_IANIGLA' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_CR2' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_compact' get_hydroMet(obj, name = NA_character_)
get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_BDHI' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_DGI' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_IANIGLA' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_CR2' get_hydroMet(obj, name = NA_character_) ## S4 method for signature 'hydroMet_compact' get_hydroMet(obj, name = NA_character_)
obj |
an |
name |
a valid single string or vector string with the required slot name(s). |
A list with the slot's data.
get_hydroMet,hydroMet-method
: get method for generic hydroMet object
get_hydroMet,hydroMet_BDHI-method
: get method for BDHI class
get_hydroMet,hydroMet_DGI-method
: get method for DGI class
get_hydroMet,hydroMet_IANIGLA-method
: get method for IANIGLA class
get_hydroMet,hydroMet_CR2-method
: get method for CR2 class
get_hydroMet,hydroMet_compact-method
: get method for compact
class
# Create an IANIGLA object cuevas <- create_hydroMet(class_name = 'IANIGLA') # Extract one of its slots tair <- get_hydroMet(obj = cuevas, name = 'tair')
# Create an IANIGLA object cuevas <- create_hydroMet(class_name = 'IANIGLA') # Extract one of its slots tair <- get_hydroMet(obj = cuevas, name = 'tair')
This function allows you to get the hydrological year. The criteria is consistent with the one of Departamento General de Irrigacion (Mendoza - Argentina).
hydro_year_DGI(df)
hydro_year_DGI(df)
df |
a data frame with total annual volumes discharges created with agg_serie function. |
A data frame containing the hydrological classification for each year.
# 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') # Now 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") ) # Now get mean monthly discharge Qmm <- get_hydroMet(obj = guido, name = 'Qmm')[[1]] # Get the monthly water volume Qmm_vol <- Qmm_to_Dm(df = Qmm) # Aggregate data frame to get total annual discharges AD <- agg_serie(df = Qmm_vol, fun = 'sum', period = 'annual', out_name = 'Ann_vol', start_month = 7, end_month = 6, allow_NA = 2) # Get hydrological year classification AD_class <- hydro_year_DGI(df = AD)
# 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') # Now 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") ) # Now get mean monthly discharge Qmm <- get_hydroMet(obj = guido, name = 'Qmm')[[1]] # Get the monthly water volume Qmm_vol <- Qmm_to_Dm(df = Qmm) # Aggregate data frame to get total annual discharges AD <- agg_serie(df = Qmm_vol, fun = 'sum', period = 'annual', out_name = 'Ann_vol', start_month = 7, end_month = 6, allow_NA = 2) # Get hydrological year classification AD_class <- hydro_year_DGI(df = AD)
hydroMet
subclass for BDHI (Base de Datos Hidrologica Integrada) dataAn suitable object for store hydro-meteorological data from BDHI.
A hydroMet_BDHI class object.
Qmd
data.frame from read_BDHI containing daily mean river discharge [m3/s].
Qmm
data.frame from read_BDHI containing monthly mean river discharge [m3/s].
precip
data.frame from read_BDHI containing daily liquid precipitation [mm].
tdb
data.frame from read_BDHI containing subdaily dry bulb temperature [ºC].
tmax
data.frame from read_BDHI containing daily maximum air temperature [ºC].
tmin
data.frame from read_BDHI containing daily minimum air temperature [ºC].
swe
data.frame from read_BDHI containing daily snow water equivalent [mm].
hr
data.frame from read_BDHI containing subdaily relative humidity [%].
wspd
data.frame from read_BDHI containing subdaily wind speed [km/hr].
wdir
data.frame from read_BDHI containing subdaily wind direction [º].
evap
data.frame from read_BDHI containing daily pan-evaporation [mm].
anem
data.frame from read_BDHI containing daily wind speed above the evap tank [km/hr].
patm
data.frame from read_BDHI containing subdaily atmospheric pressure [mbar].
hydroMet
subclass for compact dataThis subclass is useful for storing in a single data frame ready to use hydro-meteorological series or many variables of the same kind (e.g. lets say precipitacion series).
A hydroMet_compact class object.
compact
data.frame with Date as first column (class 'Date' or 'POSIXct'). All other columns are the numeric hydro-meteorological variables (double). This subclass was though to join in a single table ready to use data (e.g. in modelling). You can also use it to put together variables of the same kind (e.g. precipitation records) to make some regional analysis.
hydroMet
subclass for CR2 (Explorador Climático) dataA suitable object for store hydro-meteorological data from CR2.
A hydroMet_CR2 class object.
precip
data.frame from read_CR2 containing daily precipitation [mm].
tmean
data.frame from read_CR2 containing daily mean air temperature [ºC].
tmax
data.frame from read_CR2 containing daily maximum air temperature [ºC].
tmin
data.frame from read_CR2 containing daily minimum air temperature [ºC].
hydroMet
subclass for DGI (Departamento General de Irrigación) dataA suitable object for store hydro-meteorological data from DGI.
A hydroMet_DGI class object.
hsnow
data.frame from read_DGI containing daily snow height [m].
swe
data.frame from read_DGI containing daily snow water equivalent [mm].
tmean
data.frame from read_DGI containing daily mean air temperature [ºC].
tmax
data.frame from read_DGI containing daily max. air temperature [ºC].
tmin
data.frame from read_DGI containing daily min. air temperature [ºC].
hr
data.frame from read_DGI containing daily mean relative humidity [%].
patm
data.frame from read_DGI containing daily mean atmospheric pressure [hPa].
hydroMet
subclass for IANIGLA (Instituto Argentino de Nivología, Glaciología y Ciencias Ambientales) dataA suitable object for store hydro-meteorological data provided by IANIGLA.
A hydroMet_IANIGLA class object.
date
time serie of dates (class POSIXct
or Date
).
tair
numeric matrix with air temperature.
hr
numeric matrix with relative humidity.
patm
numeric matrix with atmospheric pressure.
precip
numeric matrix with precipitacion.
wspd
numeric matrix with wind speed.
wdir
numeric matrix with wind direction.
kin
numeric matrix with incoming short-wave radiation.
hsnow
numeric matrix with snow height.
tsoil
numeric matrix with soil temperature.
hwat
numeric matrix with stream water level.
hydroMet
superclass objectA suitable object for store basic information about an hydro-meteorological station.
A basic hydroMet class object.
id
numeric. This is the ID assigned by the agency.
agency
character. The name of the agency (or institution) that provides the data of the station.
station
character. The name of the (hydro)-meteorological station.
lat
numeric. Latitude of the station.
long
numeric. Longitude of the station
alt
numeric. Altitude of the station.
country
character. Country where the station is located. Argentina is set as default value.
province
character. Name of the province where the station is located. Mendoza is set as default value.
river
character. Basin river's name.
active
logical. It indicates whether or not the station is currently operated. Default value is TRUE
.
This functions applies interpolation to fill in missing (or non-recorded) values.
interpolate(df, miss_table, threshold, method = "linear")
interpolate(df, miss_table, threshold, method = "linear")
df |
data frame with two columns: 'Date' or 'POSIXct' class in the first column and a numeric variable in the second one. |
miss_table |
data frame with three columns: first and last date of interpolation (first and second column respectively). The last and third column, is a numeric with the number of steps to interpolate. See report_miss_data. |
threshold |
numeric variable with the maximum number of dates in which to apply the interpolation. |
method |
string with the interpolation method. In this version only 'linear' method is allowed. |
A data frame with date and the interpolated numeric variable.
# 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') # Now 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") ) # Get mean daily discharge and report miss data Qmd <- get_hydroMet(obj = guido, name = 'Qmd')[[1]] miss <- report_miss_data(df = Qmd) # Now interpolate miss values Qmd_fill <- interpolate(df = Qmd, miss_table = miss, threshold = 5, method = "linear")
# 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') # Now 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") ) # Get mean daily discharge and report miss data Qmd <- get_hydroMet(obj = guido, name = 'Qmd')[[1]] miss <- report_miss_data(df = Qmd) # Now interpolate miss values Qmd_fill <- interpolate(df = Qmd, miss_table = miss, threshold = 5, method = "linear")
Apply a pre-defined (e.g.: movAvg, fill_value or Qmm_to_Dm) or user defined function to an existing series inside a slot.
modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 2, FUN = NULL, ... ) ## S4 method for signature 'hydroMet_BDHI' modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 2, FUN = NULL, ... ) ## S4 method for signature 'hydroMet_CR2' modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 2, FUN = NULL, ... ) ## S4 method for signature 'hydroMet_DGI' modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 2, FUN = NULL, ... ) ## S4 method for signature 'hydroMet_IANIGLA' modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 1, FUN = NULL, ... )
modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 2, FUN = NULL, ... ) ## S4 method for signature 'hydroMet_BDHI' modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 2, FUN = NULL, ... ) ## S4 method for signature 'hydroMet_CR2' modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 2, FUN = NULL, ... ) ## S4 method for signature 'hydroMet_DGI' modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 2, FUN = NULL, ... ) ## S4 method for signature 'hydroMet_IANIGLA' modify_hydroMet( obj, name = NA_character_, colName = NA_character_, colNum = 1, FUN = NULL, ... )
obj |
hydroMet_XXX subclass object. See hydroMet_BDHI, hydroMet_DGI, hydroMet_IANIGLA or hydroMet_CR2. |
name |
string with the slot name of the data frame. |
colName |
string with the new column name (from |
colNum |
numeric value with the data frame column where to apply |
FUN |
the function name. |
... |
|
The same hydroMet subclass provided in obj
with an extra column.
modify_hydroMet,hydroMet_BDHI-method
: modify method for BDHI class
modify_hydroMet,hydroMet_CR2-method
: modify method for CR2 class
modify_hydroMet,hydroMet_DGI-method
: modify method for DGI class
modify_hydroMet,hydroMet_IANIGLA-method
: modify method for IANIGLA class
# 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') # Now 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") )
# 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') # Now 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") )
Smooth a numeric serie with a moving average windows
movAvg(df, k, pos)
movAvg(df, k, pos)
df |
data frame with the serie that you want to smooth. By default, t he function uses column 2. |
k |
numeric value with windows size., e.g.: 5 |
pos |
string with the position of the window:
|
data frame with the smooth serie.
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function cuevas <- read_IANIGLA(file = 'Cuevas.csv', path = full_path) # Get air temperature cuevas_tair <- cuevas[ , 1:2] # Create a moving average serie of Tair Tair_mov <- movAvg(df = cuevas_tair, k = 10, pos = 'izq')
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function cuevas <- read_IANIGLA(file = 'Cuevas.csv', path = full_path) # Get air temperature cuevas_tair <- cuevas[ , 1:2] # Create a moving average serie of Tair Tair_mov <- movAvg(df = cuevas_tair, k = 10, pos = 'izq')
ggplot2
or plotly
(interactive)This method allows you to make plots (using simple and expressive arguments) of the variables contained inside an hydroMet_XXX
object. The plot outputs can be static (ggplot2
) or interactive (plotly
).
plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL, scatter = NULL ) ## S4 method for signature 'hydroMet_BDHI' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL ) ## S4 method for signature 'hydroMet_CR2' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL ) ## S4 method for signature 'hydroMet_DGI' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL ) ## S4 method for signature 'hydroMet_IANIGLA' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL ) ## S4 method for signature 'hydroMet_compact' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "x", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL, scatter = NULL )
plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL, scatter = NULL ) ## S4 method for signature 'hydroMet_BDHI' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL ) ## S4 method for signature 'hydroMet_CR2' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL ) ## S4 method for signature 'hydroMet_DGI' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL ) ## S4 method for signature 'hydroMet_IANIGLA' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "Date", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL ) ## S4 method for signature 'hydroMet_compact' plot_hydroMet( obj, slot_name, col_number, interactive = FALSE, line_type = NULL, line_color = "dodgerblue", x_lab = "x", y_lab = "y", title_lab = NULL, legend_lab = NULL, double_yaxis = NULL, list_extra = NULL, from = NULL, to = NULL, scatter = NULL )
obj |
a valid |
slot_name |
string(s) with the name of the slot(s) to use in plotting. |
col_number |
numeric (vector) with the column's variable to plot. In case you decide to merge slots you must provide a list in which each element contains the column numbers of the variable to plot. |
interactive |
logical. Default value, |
line_type |
string with line dash type ( |
line_color |
string with a valid |
x_lab |
string with |
y_lab |
string with |
title_lab |
string with the title of the plot. Default is a plot without title. |
legend_lab |
string with plot label(s) name(s). NOTE: |
double_yaxis |
numeric vector with either |
list_extra |
list with the |
from |
string (or |
to |
string (or |
scatter |
numeric vector of length two with the column number to plot as scatter. The first variable (column number) will be the |
A ggplot2
or plotly
objects to analyze your data.
plot_hydroMet,hydroMet_BDHI-method
: plot method for BDHI class
plot_hydroMet,hydroMet_CR2-method
: plot method for CR2 class
plot_hydroMet,hydroMet_DGI-method
: plot method for DGI class
plot_hydroMet,hydroMet_IANIGLA-method
: plot method for IANIGLA class
plot_hydroMet,hydroMet_compact-method
: plot method for compact
class
# 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) # Plot mean air temperature plot_hydroMet(obj = toscas_dgi, col_number = 2, slot_name = 'tmean', legend_lab = 'Tmean(ºC)' ) # Now let's plot an interactive graph plot_hydroMet(obj = toscas_dgi, col_number = 2, slot_name = 'tmean', interactive = TRUE, y_lab = 'Tmean(ºC)' )
# 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) # Plot mean air temperature plot_hydroMet(obj = toscas_dgi, col_number = 2, slot_name = 'tmean', legend_lab = 'Tmean(ºC)' ) # Now let's plot an interactive graph plot_hydroMet(obj = toscas_dgi, col_number = 2, slot_name = 'tmean', interactive = TRUE, y_lab = 'Tmean(ºC)' )
Returns a data frame with two columns: the date and the cumulative sum of the chosen col_number
. This function can deal with NA_real_
.
precip_cumsum(df, col_number = 2, out_name = NULL)
precip_cumsum(df, col_number = 2, out_name = NULL)
df |
data frame with |
col_number |
numeric. The column number of the series where to apply the cumulative sum. |
out_name |
optional. String value with the column output name. Default is 'cumsum_' plus the original name. |
A data frame with two columns: date and the cumulative sum of the series.
# Load daily precipitation data-set from BDHI load( paste0(system.file('extdata', package = "hydroToolkit"), '/bdhi_p.rda') ) # Get compact slot p_bdhi <- get_hydroMet(obj = bdhi_p, name = 'compact')[[1]] # Apply cumulative precipitation function p_cum <- precip_cumsum(df = p_bdhi, col_number = 2, out_name = 'cum_guido')
# Load daily precipitation data-set from BDHI load( paste0(system.file('extdata', package = "hydroToolkit"), '/bdhi_p.rda') ) # Get compact slot p_bdhi <- get_hydroMet(obj = bdhi_p, name = 'compact')[[1]] # Apply cumulative precipitation function p_cum <- precip_cumsum(df = p_bdhi, col_number = 2, out_name = 'cum_guido')
This method can do both: test homogeneity in precipitation series or fill data gaps using regional analysis.
precip_hydroMet( obj, col_target = 2, fill = FALSE, method = "spearman", min_value = 0.2 ) ## S4 method for signature 'hydroMet_compact' precip_hydroMet( obj, col_target = 2, fill = FALSE, method = "spearman", min_value = 0.2 )
precip_hydroMet( obj, col_target = 2, fill = FALSE, method = "spearman", min_value = 0.2 ) ## S4 method for signature 'hydroMet_compact' precip_hydroMet( obj, col_target = 2, fill = FALSE, method = "spearman", min_value = 0.2 )
obj |
an |
col_target |
numeric. The column number of the target series (either to test homogeneity or to fill gaps) in |
fill |
logical. By default value ( |
method |
string (default is |
min_value |
numeric. Series with a correlation value less than |
If fill = FALSE
the method will return a list with three elements: a data frame with all necessary values to correct your target serie, a plot with p-values
and the correlation matrix. When fill = TRUE
the list will contain: the data frame with the target series gaps filled and the correlation matrix.
precip_hydroMet,hydroMet_compact-method
: homogeneity test applied to precipitation data stored in compact
class.
# Load daily precipitation data-set from BDHI load( paste0(system.file('extdata', package = "hydroToolkit"), '/bdhi_p.rda') ) # Fill gaps in Tupungato station relleno <- precip_hydroMet(obj = bdhi_p, col_target = 5, fill = TRUE)
# Load daily precipitation data-set from BDHI load( paste0(system.file('extdata', package = "hydroToolkit"), '/bdhi_p.rda') ) # Fill gaps in Tupungato station relleno <- precip_hydroMet(obj = bdhi_p, col_target = 5, fill = TRUE)
Converts mean monthly river discharge [m3/s] to total volume discharge [hm3].
Qmm_to_Dm(df)
Qmm_to_Dm(df)
df |
data frame with class Date in the first column. By default the function converts the second column only. If you have daily or hourly data see agg_serie. |
A data frame with two columns: Date and total volume discharge.
# 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') # Now 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") ) # Now get mean monthly discharge Qmm <- get_hydroMet(obj = guido, name = 'Qmm')[[1]] # Get the monthly water volume Qmm_vol <- Qmm_to_Dm(df = Qmm)
# 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') # Now 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") ) # Now get mean monthly discharge Qmm <- get_hydroMet(obj = guido, name = 'Qmm')[[1]] # Get the monthly water volume Qmm_vol <- Qmm_to_Dm(df = Qmm)
Reads files downloaded from the Base de Datos Hidrológica Integrada (BDHI) as a data frame.
read_BDHI(file, colName, timeStep, is.Wdir = FALSE)
read_BDHI(file, colName, timeStep, is.Wdir = FALSE)
file |
string with the name (including extension) of the file. |
colName |
string with variable name. E.g.: Qmd(m3/s) |
timeStep |
string with time step: 'month', 'day', 'day/3', '4h' or 'hour'.
|
is.Wdir |
a logical value indicating if the variable is wind direction. Default value is set to FALSE. |
A data frame with two columns: date and variable. Gaps between dates are filled with NA_real_
and duplicated rows are eliminated automatically.
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function guido_Qmd <- read_BDHI(file = paste0(full_path, '/Qmd_Mendoza_Guido'), colName = 'Q(m3/s)', timeStep = 'day')
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function guido_Qmd <- read_BDHI(file = paste0(full_path, '/Qmd_Mendoza_Guido'), colName = 'Q(m3/s)', timeStep = 'day')
Reads data downloaded from Explorador Climatico de Chile (CR2) as a data frame.
read_CR2(file, colName, path = NULL)
read_CR2(file, colName, path = NULL)
file |
string with the file name (include extension). The only accepted format is '.csv'. |
colName |
string with the name of the variable. |
path |
string with the files directory. If not provided, the function will use the current working directory. |
A two column data frame with date and variable. Gaps between dates are filled with NA_real_
and duplicated rows are eliminated automatically.
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function yeso_tmed <- read_CR2(file = 'Tmed_Yeso_Embalse.csv', colName = 'T(ºC)', path = full_path)
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function yeso_tmed <- read_CR2(file = 'Tmed_Yeso_Embalse.csv', colName = 'T(ºC)', path = full_path)
Reads the Departamento General de Irrigacion(Mendoza - Argentina) excel sheet.
read_DGI(file, sheet = NULL, colName = NULL, range = NULL, path = NULL)
read_DGI(file, sheet = NULL, colName = NULL, range = NULL, path = NULL)
file |
string with the file name ('xlsx' excel files). |
sheet |
sheet to read. Either a string (the name of a sheet), or an integer (the position of the sheet). Default value is sheet one. |
colName |
string with the name of the second column (as default first column is Date). If ignored first row excel names are used. |
range |
string providing cell range to read. E.g.: 'A1:B75'. |
path |
string with the files directory. If not provided, the function will use the current working directory. |
A data frame with two columns: date and variable. Gaps between dates are filled with NA_real_
and duplicated rows are eliminated automatically.
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function toscas_hr <- read_DGI(file = 'Toscas.xlsx', sheet = 'hr', colName = 'RH(%)', path = full_path)
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function toscas_hr <- read_DGI(file = 'Toscas.xlsx', sheet = 'hr', colName = 'RH(%)', path = full_path)
Reads the data provided by IANIGLA (Instituto Argentino de Nivologia, Glaciologia y Ciencias Ambientales).
read_IANIGLA(file, all = FALSE, path = NULL)
read_IANIGLA(file, all = FALSE, path = NULL)
file |
string with the name of the '.csv' file downloaded from the meteo-stations web page. |
all |
logical value indicating whether the returned data frame contain all the original columns or just the date and data. |
path |
string with the files directory. If not provided, the function will use the current working directory. |
A data frame containing the hourly data measured by the automatic weather stations. Gaps between dates are filled with NA_real_ and duplicated rows are eliminated automatically.
In this package version we only provide functionality for a specific data-set generated in the institute.
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function cuevas <- read_IANIGLA(file = 'Cuevas.csv', path = full_path)
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Apply function cuevas <- read_IANIGLA(file = 'Cuevas.csv', path = full_path)
This method returns a list with two elements: the first one is a data frame
with miss data (see also report_miss_data) and the second one is also a data frame
with the mean
, sd
, max
and min
values.
report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" ) ## S4 method for signature 'hydroMet_BDHI' report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" ) ## S4 method for signature 'hydroMet_CR2' report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" ) ## S4 method for signature 'hydroMet_DGI' report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" ) ## S4 method for signature 'hydroMet_IANIGLA' report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" )
report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" ) ## S4 method for signature 'hydroMet_BDHI' report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" ) ## S4 method for signature 'hydroMet_CR2' report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" ) ## S4 method for signature 'hydroMet_DGI' report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" ) ## S4 method for signature 'hydroMet_IANIGLA' report_hydroMet( obj, slot_name, col_name, start_date = NULL, end_date = NULL, Lang = "spanish" )
obj |
an |
slot_name |
a single or vector string containing the slot(s) to report. |
col_name |
a single or vector string with the name of the column to report in |
start_date |
optional (default is the first |
end_date |
optional (default is the last |
Lang |
optional (default value is |
A list containing two data frames
: the first one with miss data and the second with the mean
, sd
, max
and min
values of the series.
report_hydroMet,hydroMet_BDHI-method
: report method for BDHI class
report_hydroMet,hydroMet_CR2-method
: report method for CR2 class
report_hydroMet,hydroMet_DGI-method
: report method for DGI class
report_hydroMet,hydroMet_IANIGLA-method
: report method for IANIGLA class
# Create IANIGLA class cuevas <- create_hydroMet(class_name = 'IANIGLA') # List with meteorological variables (slots in BDHI's object) cargar <- list( slotNames(x = 'hydroMet_IANIGLA')[2:11] ) # Assign as names the files hydro_files <- list.files( system.file('extdata', package = "hydroToolkit"), pattern = 'Cuevas' ) names(cargar) <- hydro_files # Build met-station cuevas <- build_hydroMet(obj = cuevas, slot_list = cargar, path = system.file('extdata', package = "hydroToolkit") ) # Get report report_hydroMet(obj = cuevas, slot_name = 'kin', col_name = 'kin_1')
# Create IANIGLA class cuevas <- create_hydroMet(class_name = 'IANIGLA') # List with meteorological variables (slots in BDHI's object) cargar <- list( slotNames(x = 'hydroMet_IANIGLA')[2:11] ) # Assign as names the files hydro_files <- list.files( system.file('extdata', package = "hydroToolkit"), pattern = 'Cuevas' ) names(cargar) <- hydro_files # Build met-station cuevas <- build_hydroMet(obj = cuevas, slot_list = cargar, path = system.file('extdata', package = "hydroToolkit") ) # Get report report_hydroMet(obj = cuevas, slot_name = 'kin', col_name = 'kin_1')
NA_real_
valuesCreates a data frame with reported dates and number of times-step of missing or not recorded data.
report_miss_data(df, Lang = "spanish")
report_miss_data(df, Lang = "spanish")
df |
data frame with hydro-meteo data. First column is date and the second the numeric vector to be reported. |
Lang |
string with output column name language: 'spanish' (default) or 'english'. |
A data frame with three columns: start-date, end-date and number of missing time steps.
# 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') # Now 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") ) # Get mean daily discharge and report miss data Qmd <- get_hydroMet(obj = guido, name = 'Qmd')[[1]] miss <- report_miss_data(df = Qmd)
# 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') # Now 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") ) # Get mean daily discharge and report miss data Qmd <- get_hydroMet(obj = guido, name = 'Qmd')[[1]] miss <- report_miss_data(df = Qmd)
Removes spikes, and sets their value to NA_real_
.
rm_spikes(df, tolerance)
rm_spikes(df, tolerance)
df |
data frame with date and numeric variable in the first and second column respectively (from |
tolerance |
numeric with maximum tolerance between a number and its successor. |
The same data frame but without peaks.
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Read IANIGLA file cuevas <- read_IANIGLA(file = 'Cuevas.csv', path = full_path) # Remove spikes from air temperature series tair_rm_spikes <- rm_spikes(df = cuevas, tolerance = 10)
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Read IANIGLA file cuevas <- read_IANIGLA(file = 'Cuevas.csv', path = full_path) # Remove spikes from air temperature series tair_rm_spikes <- rm_spikes(df = cuevas, tolerance = 10)
hydroMet
object or its subclassesWith this method you can set (or change) an specific slot value.
set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, ... ) ## S4 method for signature 'hydroMet' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL ) ## S4 method for signature 'hydroMet_BDHI' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, Qmd = NULL, Qmm = NULL, precip = NULL, tdb = NULL, tmax = NULL, tmin = NULL, swe = NULL, hr = NULL, wspd = NULL, wdir = NULL, evap = NULL, anem = NULL, patm = NULL ) ## S4 method for signature 'hydroMet_DGI' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, swe = NULL, tmean = NULL, tmax = NULL, tmin = NULL, hr = NULL, patm = NULL, hsnow = NULL ) ## S4 method for signature 'hydroMet_IANIGLA' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, date = NULL, tair = NULL, hr = NULL, patm = NULL, precip = NULL, wspd = NULL, wdir = NULL, kin = NULL, hsnow = NULL, tsoil = NULL, hwat = NULL ) ## S4 method for signature 'hydroMet_CR2' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, precip = NULL, tmean = NULL, tmax = NULL, tmin = NULL ) ## S4 method for signature 'hydroMet_compact' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, compact = NULL )
set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, ... ) ## S4 method for signature 'hydroMet' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL ) ## S4 method for signature 'hydroMet_BDHI' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, Qmd = NULL, Qmm = NULL, precip = NULL, tdb = NULL, tmax = NULL, tmin = NULL, swe = NULL, hr = NULL, wspd = NULL, wdir = NULL, evap = NULL, anem = NULL, patm = NULL ) ## S4 method for signature 'hydroMet_DGI' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, swe = NULL, tmean = NULL, tmax = NULL, tmin = NULL, hr = NULL, patm = NULL, hsnow = NULL ) ## S4 method for signature 'hydroMet_IANIGLA' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, date = NULL, tair = NULL, hr = NULL, patm = NULL, precip = NULL, wspd = NULL, wdir = NULL, kin = NULL, hsnow = NULL, tsoil = NULL, hwat = NULL ) ## S4 method for signature 'hydroMet_CR2' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, precip = NULL, tmean = NULL, tmax = NULL, tmin = NULL ) ## S4 method for signature 'hydroMet_compact' set_hydroMet( obj = NULL, id = NULL, agency = NULL, station = NULL, lat = NULL, long = NULL, alt = NULL, country = NULL, province = NULL, river = NULL, active = NULL, compact = NULL )
obj |
an |
id |
numeric. This is the ID assigned by the agency. |
agency |
character. The name of the agency (or institution) that provides the data of the station. |
station |
character. The name of the (hydro)-meteorological station. |
lat |
numeric. Latitude of the station. |
long |
numeric. Longitude of the station |
alt |
numeric. Altitute of the station. |
country |
character. Country where the station is located. Argentina is set as default value. |
province |
character. Name of the province where the station is located. Mendoza is set as default value. |
river |
character. Basin river's name. |
active |
logical. It indicates whether or not the station is currently operated. Default value is |
... |
arguments to be passed to methods. They rely on the slots of the |
Qmd |
daily mean river discharge. |
Qmm |
monthly mean river discharge. |
precip |
precipitation. |
tdb |
dry bulb temperature. |
tmax |
daily maximum air temperature. |
tmin |
daily minimum air temperature. |
swe |
snow water equivalent. |
hr |
relative humidity. |
wspd |
wind speed. |
wdir |
wind direction. |
evap |
evaporation. |
anem |
wind speed above the pan-evaporation. |
patm |
atmospheric pressure. |
tmean |
daily mean air temperature. |
hsnow |
snow height. |
date |
time serie with dates. |
tair |
air temperature. |
kin |
incoming shortwave radiation. |
tsoil |
soil temperature. |
hwat |
stream water level. |
compact |
data frame with Date as first column. All other columns are hydro-meteorological variables. |
The hydroMet object with the slots setted.
set_hydroMet,hydroMet-method
: set method for generic object
set_hydroMet,hydroMet_BDHI-method
: set method for BDHI object
set_hydroMet,hydroMet_DGI-method
: set method for DGI object
set_hydroMet,hydroMet_IANIGLA-method
: set method for IANIGLA object
set_hydroMet,hydroMet_CR2-method
: set method for CR2 object
set_hydroMet,hydroMet_compact-method
: set method for compact
object
# Create BDHI hydro-met station guido <- create_hydroMet(class_name = 'BDHI') # Assign altitude guido <- set_hydroMet(obj = guido, alt = 2480)
# Create BDHI hydro-met station guido <- create_hydroMet(class_name = 'BDHI') # Assign altitude guido <- set_hydroMet(obj = guido, alt = 2480)
Set tolerable extreme values (maximum or minimum). Records greater or equal than ('>=') or lesser or equal than ('<=') 'threshold' argument are set to NA_real_
.
set_threshold(x, threshold, case = ">=")
set_threshold(x, threshold, case = ">=")
x |
numeric vector or data frame with a numeric series in the second column. |
threshold |
numeric value with threshold. |
case |
string with either '>=' (greater or equal than) or '<=' (lesser or equal than) symbol. |
Numeric vector or data frame with values greater (or lesser) or equal than 'threshold' set as NA_real_
.
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Read IANIGLA file cuevas <- read_IANIGLA(file = 'Cuevas.csv', path = full_path) # Set threshold from air temperature series tair_thres <- set_threshold(x = cuevas, threshold = 40)
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Read IANIGLA file cuevas <- read_IANIGLA(file = 'Cuevas.csv', path = full_path) # Set threshold from air temperature series tair_thres <- set_threshold(x = cuevas, threshold = 40)
This method allows you to easily cut the data stored in an hydroMet_XXX
class object by dates.
subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_BDHI' subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_DGI' subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_CR2' subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_IANIGLA' subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_compact' subset_hydroMet(obj, slot_name, from = NULL, to = NULL)
subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_BDHI' subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_DGI' subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_CR2' subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_IANIGLA' subset_hydroMet(obj, slot_name, from = NULL, to = NULL) ## S4 method for signature 'hydroMet_compact' subset_hydroMet(obj, slot_name, from = NULL, to = NULL)
obj |
an |
slot_name |
string vector with the slot(s) name(s) to subset. NOTE: in case you want to subset a |
from |
string (or |
to |
string (or |
The same hydroMet_XXX
class provided in obj
but subsetted.
subset_hydroMet,hydroMet_BDHI-method
: subset method for BDHI data
subset_hydroMet,hydroMet_DGI-method
: subset method for DGI data
subset_hydroMet,hydroMet_CR2-method
: subset method for CR2 data
subset_hydroMet,hydroMet_IANIGLA-method
: subset method for IANIGLA data
subset_hydroMet,hydroMet_compact-method
: subset method for compact
data
# 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") ) # Subset daily mean discharge guido <- subset_hydroMet(obj = guido, slot_name = 'Qmd', from = '2005-01-01', to = '2010-12-31')
# 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") ) # Subset daily mean discharge guido <- subset_hydroMet(obj = guido, slot_name = 'Qmd', from = '2005-01-01', to = '2010-12-31')
Converts a snow water equivalent series (from snow pillow) into a melt series.
swe_to_melt(df)
swe_to_melt(df)
df |
data frame with 'swe' serie in the second column. See |
Data frame containing the numeric vector with melted snow.
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Read swe sheet toscas_swe <- read_DGI(file = 'Toscas.xlsx', sheet = 'swe', colName = 'swe(mm)', path = full_path) # swe to melt toscas_melt <- swe_to_melt(df = toscas_swe)
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Read swe sheet toscas_swe <- read_DGI(file = 'Toscas.xlsx', sheet = 'swe', colName = 'swe(mm)', path = full_path) # swe to melt toscas_melt <- swe_to_melt(df = toscas_swe)
Converts a snow water equivalent series (from snow pillow) to a snowfall series.
swe_to_precip(df)
swe_to_precip(df)
df |
data frame with 'swe' series in the second column. See |
Data frame containing the numeric vector with inferred snowfall.
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Read swe sheet toscas_swe <- read_DGI(file = 'Toscas.xlsx', sheet = 'swe', colName = 'swe(mm)', path = full_path) # swe to snowfall toscas_snfall <- swe_to_precip(df = toscas_swe)
# Relative path to raw data full_path <- system.file('extdata', package = "hydroToolkit") # Read swe sheet toscas_swe <- read_DGI(file = 'Toscas.xlsx', sheet = 'swe', colName = 'swe(mm)', path = full_path) # swe to snowfall toscas_snfall <- swe_to_precip(df = toscas_swe)