nfd_time_helpers: Helper Functions for Natural Flow Data Time Series

has_overlapping_tsR Documentation

Helper Functions for Natural Flow Data Time Series

Description

The objects that store natural flow data (nfd, crss_nf, or crssi) all include multiple time series, which are internally stored as xts objects. These functions help modify or query the time step component of these objects.

Usage

has_overlapping_ts(x, exact = TRUE)

nfd_trim_ts(x, ...)

## S3 method for class 'xts'
nfd_trim_ts(x, ..., year = "cy")

reindex(x, start_year, master_ts = "monthly")

## S3 method for class 'crssi'
reindex(x, start_year, master_ts = "monthly")

## S3 method for class 'nfd'
reindex(x, start_year, master_ts = "monthly")

## S3 method for class 'xts'
reindex(x, start_year, ...)

Arguments

x

An object inheriting from nfd, crss_nf, or crssi.

exact

Boolean. Do the annual and monthly data have to overlap "exactly". See Details.

...

Other parameters passed to function. Ignored if x is an xts object.

year

"cy" or "wy" to specify calendar or water year, respectively.

start_year

The new starting year as a string or numeric.

master_ts

Ignored unless x has annual and monthly data. If x does contain both, the time step specified here is the "master" time step, i.e., it is the time step the start_year is applied to. Then, the other time step's start year is computed based on keeping the relative difference in the start year's the same.

Details

has_overlapping_ts() determines whether the the annual and monthly data within the object are overlapping. If exact is TRUE, the start and end time step for the monthly and annual data must match "exactly". This means for an object storing calendar year data that the monthly data will start in January, year1 and end in December, year2 while the annual data must start in December, year1 and end in December, year2. The analogous is true for water year data, except the start and end months are October and September, respectively.

If the object contains only monthly, or only annual data, has_overlapping_ts() will always return TRUE.

nfd_trim_ts() trims the object so that it only contains an "exact" overlapping set of monthly data, that is it starts and ends in January and December for calendar year data or October and September for water year data. Additionally, if object contains annual and monthly data, those data are trimmed to only include data for the same years. If the object only includes annual data, no trimming is performed.

reindex() changes the time steps, i.e., indeces, of natural flow data as stored in nfd, crss_nf, or crssi objects. The time steps are changed to start in the specified start_year. This change applies to all time series data stored in the object, i.e., monthly and annual data and the Sacramento year type.


BoulderCodeHub/CRSSIO documentation built on July 2, 2023, 5:15 p.m.