readDWD.stand: read subdaily/standard_format dwd data

Description Usage Arguments Value Author(s) See Also Examples

View source: R/readDWD.R

Description

read subdaily/standard_format dwd data. Intended to be called via readDWD().
All other observational data at dwdbase can be read with readDWD.data(), except for the multi_annual and subdaily/standard_format data.

Usage

1
2
3
4
5
6
7
8
readDWD.stand(
  file,
  fast = TRUE,
  fileEncoding = "latin1",
  formIndex = formatIndex,
  quiet = rdwdquiet(),
  ...
)

Arguments

file

Name of file on harddrive, like e.g. DWDdata/subdaily_standard_format_kl_10381_00_akt.txt or DWDdata/subdaily_standard_format_kl_10381_bis_1999.txt.gz

fast

Logical: use readr::read_fwf() instead of read.fwf()? Takes 0.1 instead of 20 seconds but requires package to be installed. if fast=TRUE, fileEncoding is ignored. DEFAULT: TRUE

fileEncoding

read.table() file encoding. DEFAULT: "latin1" (potentially needed on Linux, optional but not hurting on windows)

formIndex

Single object: Index used to select column widts and NA values. To use a current / custom index, see the source code of updateIndexes() at https://github.com/brry/rdwd/blob/master/R/updateIndexes.R. DEFAULT: formatIndex

quiet

Ignored. DEFAULT: FALSE through rdwdquiet()

...

Further arguments passed to read.fwf() or readr::read_fwf()

Value

data.frame with column names as per formatIndex. "Q"-columns have "_parameter" appended to their name. A "Date" column has been added. NA-indicators have been processed into NAs.

Author(s)

Berry Boessenkool, berry-b@gmx.de, Oct 2019

See Also

readDWD()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run:  # Excluded from CRAN checks, but run in localtests

link <- selectDWD(id=10381, res="subdaily", var="standard_format", per="r")
file <- dataDWD(link, dir=localtestdir(), read=FALSE)
sf <- readDWD(file)

sf2 <- readDWD(file, fast=FALSE) # 20 secs!
stopifnot(all.equal(sf, sf2))

plot(sf$Date, sf$SHK, type="l")

# Plot all columns:
if(FALSE){ # not run in any automated testing
tmp <- tempfile(fileext=".pdf")
char2fact <- function(x)
 {
 if(all(is.na(x))) return(rep(-9, len=length(x)))
 if(!is.numeric(x)) as.factor(x) else x
 }
pdf(tmp, width=9)
par(mfrow=c(2,1),mar=c(2,3,2,0.1), mgp=c(3,0.7,0), las=1)
for(i in 3:ncol(sf)-1) plot(sf$Date, char2fact(sf[,i]), type="l", main=colnames(sf)[i], ylab="")
dev.off()
berryFunctions::openFile(tmp)
}

## End(Not run)

rdwd documentation built on April 9, 2021, 1:06 a.m.