Export forcing data and discharge observation files from R.
WriteObs(
x,
filename,
dt.format = "%Y-%m-%d",
round = NULL,
signif = NULL,
obsid = NULL,
append = FALSE,
comment = NULL
)WritePTQobs(
x,
filename,
dt.format = "%Y-%m-%d",
round = NULL,
signif = NULL,
obsid = NULL,
append = FALSE,
comment = NULL
)
No return value, called for export to text files.
The object to be written, a dataframe containing observation date-times in first and observations in SUBIDs or OBSIDs in
remaining columns. If argument obsid is not provided, x must have an additional attribute obsid containing
observation IDs/SUBIDs in column order.
Path to and file name of the file to import. Windows users: Note that Paths are separated by '/', not '\'.
Date-time format string as in strptime.
Integer, number of decimal places and number of significant digits to export, respectively. See round and signif. Applied in
sequence (round first and signif second). If NULL (default), the data to export is not touched.
Integer vector containing observation IDs/SUBIDs in same order as columns in x. To be exported as header
in the obs file. Must contain the same number of IDs as observation series in x. If NULL, an attribute obsid
in x is mandatory. An existing obsid argument takes precedence over a obsid attribute.
Logical, if TRUE, then table will be joined to the data in existing file and the output will be sorted by DATE (Rows will be added for any missing dates).
A character string to be exported as first row comment in the Obs file. Comments are only exported if append is FALSE.
WriteObs is a convenience wrapper function of fwrite to export a HYPE-compliant observation file.
Headers are generated from attribute obsid on export (see attr on how to create and access it).
Observation IDs are SUBIDs or IDs connected to SUBIDs with a ForcKey.txt file.
If the first column in x contains dates of class POSIXt, then they will be formatted according to dt.format before writing the output file.
If round is specified, then WriteObs() will use round to round the observation values to a specified number of decimal places.
Alternatively, signif can be used to round the observation values to a specified number of significant digits using signif.
Finally, if both round and signif are specified, then the observation values will be first rounded to the number of decimal places specified
with round and then rounded to the number of significant digits specified with signif.
ReadObs
WriteXobs
te <- ReadObs(filename = system.file("demo_model", "Tobs.txt", package = "HYPEtools"))
WriteObs(x = te, filename = tempfile())
Run the code above in your browser using DataLab