View source: R/functioncollection_import.R
ReadBasinOutput | R Documentation |
This is a convenience wrapper function to import a basin output file as data frame or matrix into R.
ReadBasinOutput(
filename,
dt.format = "%Y-%m-%d",
type = c("df", "dt", "hmv"),
id = NULL,
warn.nan = FALSE
)
filename |
Path to and file name of the basin output file to import. Windows users: Note that Paths are separated by '/', not '\'. |
dt.format |
Date-time |
type |
Character, keyword for data type to return. |
id |
Integer, SUBID or OUTREGID of the imported sub-basin or outregion results. If |
warn.nan |
Logical, check if imported results contain any |
ReadBasinOutput
is a convenience wrapper function of fread
from package
data.table::data.table, with conversion of date-time strings to
POSIX time representations. Monthly and annual time steps are returned as first day of the time step period.
HYPE basin output files can contain results for a single sub-basin or for a user-defined output region. ReadBasinOutput
checks HYPE
variable names (column headers in imported file) for an "RG"-prefix. If it is found, the ID read from either file name or argument
id
is saved to attribute outregid
, otherwise to attribute subid
.
ReadBasinOutput
returns a data.frame
, data.table::data.table, or a HypeMultiVar
array.
Data frames and data tables contain additional attributes
: hypeunit
, a vector of HYPE variable units,
subid
and outregid
, the HYPE SUBID/OUTREGID to which the time series belong (both attributes always created and assigned NA
if not applicable to data contents), timestep
with a time step keyword attribute, and comment
with contents of an optional
first-row comment (NA
otherwise). An additional attribute subid.nan
might be returned, see argument warn.nan
.
For the conversion of date/time strings, time zone "UTC" is assumed. This is done to avoid potential daylight saving time side effects when working with the imported data (and possibly converting to string representations during the process).
HYPE results are printed to files using a user-specified accuracy. This accuracy is specified in 'info.txt' as a number of
decimals to print. If large numbers are printed, this can result in a total number of digits which is too large to print.
Results will then contain values of '****************'. ReadBasinOutput
will convert those cases to 'NA' entries.
Current versions of HYPE allow for defining significant numbers of digits instead of fixed ones, which should prevent this issue from arising.
te <- ReadBasinOutput(filename = system.file("demo_model",
"results", "0003587.txt", package = "HYPEtools"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.