ReadTimeOutput {HYPEtools} | R Documentation |
Read a Time Output File
Description
Import a time output file 'time<HYPE_output_variable>.txt' or a converted time output file in netCDF format into R.
Usage
ReadTimeOutput(
filename,
dt.format = "%Y-%m-%d",
hype.var = NULL,
out.reg = NULL,
type = c("df", "dt", "hsv"),
select = NULL,
id = NULL,
nrows = -1L,
skip = 0L,
warn.nan = FALSE,
verbose = TRUE
)
Arguments
filename |
Path to and file name of the time output file to import. Acceptable file choices are |
dt.format |
Date-time |
hype.var |
Character, HYPE variable ID in |
out.reg |
Logical, specify if file contents are sub-basin or output region results (i.e. SUBIDs or OUTREGIDs as columns).
|
type |
Character, keyword for data type to return. |
select |
Integer vector, column numbers to import. Note: first column with dates must be imported and will be added if missing. |
id |
Integer vector, HYPE SUBIDs/OUTREGIDs to import. Alternative to argument |
nrows |
Integer, number of rows to import, see documentation in |
skip |
Integer, number of data rows to skip on import. Time output header lines are always skipped. |
warn.nan |
Logical, check if imported results contain any |
verbose |
Logical, print information during import. |
Details
ReadTimeOutput
imports from text or netCDF files. netCDF import is experimental and not feature-complete (e.g. attributes are
not yet fully digested).
Text file import uses fread
from package
data.table
, netCDF import extracts data and attributes using functions from package ncdf4
.
Date-time representations in data files are converted to POSIX time representations. Monthly and annual time steps are returned as
first day of the time step period.
Import from netCDF files requires an id
dimension in the netCDF data. Gridded data with remapped HYPE results in spatial x/y
dimensions as defined in the HYPE netCDF formatting standard
are currently not supported.
Value
ReadTimeOutput
returns a data.frame
, data.table
, or a HypeSingleVar
array.
Data frames and data tables contain additional attributes
: variable
, giving the HYPE variable ID,
subid
and outregid
, the HYPE SUBIDs/OUTREGIDs (corresponding to columns from column two onward) to which the time
series belong (both attributes always created and assigned NA
if not applicable to data contents), timestep
with a
time step attribute, and comment
with first row comment of imported text file as character string or global attributes of imported
netCDF file as character string of collated key-value pairs. An additional attribute id.nan
might be returned, see argument
warn.nan
.
Note
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 '****************'. ReadTimeOutput
will convert those cases to 'NA' entries.
Current versions of HYPE allow for defining significant instead of fixed number of digits, which should prevent this
issue from arising.
Examples
te <- ReadTimeOutput(filename = system.file("demo_model",
"results", "timeCOUT.txt", package = "HYPEtools"), dt.format = "%Y-%m")
te