nf_to_intervening | R Documentation |
nf_to_total()
converts intervening flow to total flow for the Colorado
River natural flow network, while nf_to_intervening()
converts total flow
to intervening flow. The functions only work if the objects have the
29 Colorado River natural flow sites, and that dimension's names match
nf_gage_abbrv()
. xts
, nfd
, crss_nf
, and crssi
objects
can all be converted between total and intervening flow. For
xts
objects, the flow is converted without any additional checks, i.e.,
it is assumed the user passed in intervening flow if nf_to_total()
is
called. For the other three types
of objects, they must have the required existing data already, i.e.,
intervening data must exist when calling nf_to_total()
, and total data
must exist when calling nf_to_intervening()
. If the objects have
both annual and monthly data, both will be converted.
nf_to_intervening(x, ...)
## S3 method for class 'crss_nf'
nf_to_intervening(x, keep_total = TRUE, recompute = FALSE, ...)
## S3 method for class 'nfd'
nf_to_intervening(x, keep_total = TRUE, recompute = FALSE, ...)
## S3 method for class 'xts'
nf_to_intervening(x, ...)
nf_to_total(x, ...)
## S3 method for class 'crss_nf'
nf_to_total(x, keep_intervening = TRUE, recompute = FALSE, ...)
## S3 method for class 'nfd'
nf_to_total(x, keep_intervening = TRUE, recompute = FALSE, ...)
## S3 method for class 'xts'
nf_to_total(x, ...)
x |
An object inheriting from xts::xts, nfd, crss_nf, or crssi. |
... |
Other parameters passed to subsequent methods. |
keep_total |
When |
recompute |
If |
keep_intervening |
When |
When keep_intervening
is FALSE
and x
is either a crss_nf
object or
a crssi
object, then the returned object will be an nfd
object, and a
warning will post. This is because crss_nf
and crssi
objects must have
monthly intervening natural flow stored in them.
An object of the same class as x
, except when x
is either a
crss_nf
obect or crssi
object and keep_intervening
is FALSE
. See
Details.
# start with an nfd object with intervening annual data
nf_int <- nfd(
CoRiverNF::cyAnnInt,
n_sites = 29,
flow_space = "intervening",
time_step = "annual"
)
# convert to total
nf <- nf_to_total(nf_int, keep_intervening = FALSE)
# It matches the total natural flow that exists in the CoRiverNF package
# (except it doesn't have the sheet name attribute)
all.equal(
zoo::coredata(CoRiverNF::cyAnnTot),
zoo::coredata(
nfd_get_trace(nf, 1, flow_space = "total", time_step = "annual")
)
)
# converting back will result in original data
nf2 <- nf_to_intervening(nf, keep_total = FALSE)
all.equal(nf2, nf_int)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.