Import single-variable HYPE observation files into R.
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
)
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.
Path to and file name of the file to import. Windows users: Note that Paths are separated by '/', not '\'.
Character string, HYPE variable ID of file contents. If "" (default), the ID is extracted
from filename, which only works with HYPE input data file names or file names including those names
(e.g. 'Pobs_old.txt', 'testSFobs.txt'). Some of the observation data files have no corresponding HYPE variable ID.
In these cases, a dummy ID is used, see table in Details. If automatic extraction fails, attribute variable is set
to "other". Alternatively, any other variable name can be provided.
Optional date-time format string as in strptime. If NULL, then HYPEtools will try to identify
the format automatically.
Number of rows to import. A value of -1 indicates all rows, a positive integer gives the number of rows
to import.
Character, keyword for data type to return. "df" to return a standard data frame or "dt" to
return a data.table object.
Integer vector, column numbers to import. Note: first column with dates must be imported and will be added if missing.
Integer vector, HYPE OBSIDs to import. Alternative to argument select, takes precedence if both are provided.
ReadObs is a convenience wrapper function of fread from package
data.table::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* |
WriteObs
ReadXobs for multi-variable HYPE observation files
te <- ReadObs(filename = system.file("demo_model", "Tobs.txt", package = "HYPEtools"))
head(te)
Run the code above in your browser using DataLab