ReadObs {HYPEtools} | R Documentation |
Read HYPE observation data files
Description
Import single-variable HYPE observation files into R.
Usage
ReadObs(
filename,
variable = "",
dt.format = NULL,
nrows = -1,
type = c("df", "dt"),
select = NULL,
obsid = NULL
)
ReadPTQobs(
filename,
variable = "",
dt.format = NULL,
nrows = -1,
type = c("df", "dt"),
select = NULL,
obsid = NULL
)
Arguments
filename |
Path to and file name of the file to import. Windows users: Note that Paths are separated by '/', not '\'. |
variable |
Character string, HYPE variable ID of file contents. If |
dt.format |
Optional date-time |
nrows |
Number of rows to import. A value of |
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. |
obsid |
Integer vector, HYPE OBSIDs to import. Alternative to argument |
Details
ReadObs
is a convenience wrapper function of fread
from package
data.table
,
with conversion of date-time strings to POSIX time representations. Observation IDs (SUBIDs or IDs connected to SUBIDs with a
ForcKey.txt file) are returned as integer
attribute obsid
(directly accessible through obsid
).
Observation file types with automatic (dummy) variable
attribute assignment:
File | HYPE variable ID |
(*: dummy ID) | |
Pobs.txt | prec |
Tobs.txt | temp |
Qobs.txt | rout |
TMINobs.txt | tmin* |
TMAXobs.txt | tmax* |
VWobs.txt | vwnd* |
UWobs.txt | uwnd* |
SFobs.txt | snff* |
SWobs.txt | swrd* |
RHobs.txt | rhum* |
Uobs.txt | wind* |
Value
ReadObs
returns a data frame or data table with additional attributes: obsid
with observation IDs, timestep
with a time step string, either "day"
or "nhour"
(only daily or n-hourly time steps supported), and variable
with a HYPE variable ID string.
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 e.g. converting to string representations during the process).
See Also
WriteObs
ReadXobs
for multi-variable HYPE observation files
Examples
te <- ReadObs(filename = system.file("demo_model", "Tobs.txt", package = "HYPEtools"))
head(te)