readFilesBafu: Read files from the BAFU

Description Usage Arguments Details Value Warning Author(s) References Examples

View source: R/readFilesBafu.R

Description

Summarise or read the content of files from the BAFU (Bundesamt fuer Umwelt Schweiz).

Usage

1
readFilesBafu(dir = NULL, files, time.res, series = FALSE, merge)

Arguments

dir

string. the directory which contains the files from the BAFU.

files

character vector. The file names.

time.res

string. The measurement frequency, must be either 'year', 'month', 'day', 'hour', 'min', or 'irregular', see 'Details'.

series

logical. Return the series instead of a summary? In case of several files, this can take some time.

merge

character vector. If not missing, the series get merged according to the attributes defined in merge, see 'Details'.

Details

Either dir or files can be specified, but not both; dir takes precedence.

time.res determines how the function deals with the time information. The approach is to first constrain the time stamps to the format 'YYYY-MM-DD HH:MM' and second to truncate this string to the desired resolution. E.g. for time.res='month' we end up with 'YYYY-MM' and for time.res='hour' we get 'YYYY-MM-DD HH'. In case of time.res='min' and time.res='irregular' the last digit is ignored, so the highest frequency amounts to 10 minute intervals (i.e. 'YYYY-MM-DD HH:M').

time.res is in particular important if series=TRUE since it forces the observations to a common time interval. If more than one observation is present in a particular time interval, only the last observation is used.

The ordering of files in dir or files determines how series get merged: If the attributes specified in merge are consistent, then missing values in the first series are replaced by corresponding non-missing values in the second series and so on. Possible attributes are restricted to column names of the data frame returned if series=FALSE. Series for which an attribute is missing are excluded from the merging procedure.

Value

If series=FALSE a data frame with columns 'file' (file name) 'id' (station id), 'name' (watercourse), 'site' (site name), 'unit' (measurement unit), 'type' (peak versus mean values), 'start' (date of the first non-missing value), 'end' (date of the last non-missing value), 'comment' (remaining annotations as found in the header), 'hydropro' (file exported out of the Hydropro software?), 'sep' (field separator), and 'skip' (number of header lines).

If series=TRUE a matrix with row names corresponding to the argument time.res. In case of mean values, clock time refers to the starting time of the underlying period, e.g. for hourly values 01 corresponds to 01:00 - 01:59. The column names contain the id (if present) of the station as last number.

Warning

Author(s)

Simon S

References

BAFU

Examples

1
2
3
4
5
6
7
8
## Not run: 
d <- '/path/to/dir/'
readFilesBafu(dir=d)
m <- readFilesBafu(dir=d,series=TRUE)

f <- c('/the/first/Bafu/file1.asc','/the/second/Bafu/file2.asc')
m <- readFilesBafu(files=f,series=T)
## End(Not run)

hydro-giub/hydroBE documentation built on Sept. 20, 2019, 9:27 a.m.