selectDWD: Select data from the DWD CDC FTP Server

Description Usage Arguments Value Author(s) See Also Examples

View source: R/selectDWD.R

Description

Select files for downloading with dataDWD. All arguments (except for mindex, findex and base) can be a vector and will be recycled to the maximum length of all arguments. If that length > 1, the output is a list of filenames (or vector if outvec=TRUE).
If station name is given, but id is empty (""), id is inferred via mindex. If res/var/per are given and valid (existing in findex), they are pasted together to form a path. Here is an overview of the behavior in each case of availability:

case | id | path | output
1 | "" | "" | base (and some warnings)
2 | "xx" | "" | All file names (across paths) for station id
3 | "" | "xx" | The zip file names at path
4 | "xx" | "xx" | Regular single data file name

For case 3 and 4 (path given), you can set meta=TRUE. Then selectDWD will return the name of the station description file at path. This is why case 3 with meta=FALSE only returns the data file names (ending in .zip).


The following folders in res/var/per notation (resolution/variable/period) are available at ftp://ftp-cdc.dwd.de/pub/CDC/observations_germany/climate/
"<" signifies a split into the folders per = "recent" and "historical".
"<<" signifies a split into the folders per = "now", recent", "historical" and "meta_data".
"-" signifies that there are no further sub-folders.
Please note that both "solar" (-/<<) and "sun" (<) are available!

res=10_minutes | res=hourly | res=daily | res=monthly
var=
| | kl < | kl <
| | more_precip < | more_precip <
air_temperature << | air_temperature < | |
extreme_temperature << | | |
extreme_wind << | | |
| cloudiness < | |
| cloud_type < | |
precipitation << | precipitation < | |
| pressure < | |
| soil_temperature < | soil_temperature < |
solar << | solar - | solar - |
| sun < | |
| visibility < | |
| | water_equiv < |
wind << | wind < | |

Please note that 1_minute/precipitation/historical has subfolders for each year.

res=1_minute | res=multi_annual | res=subdaily
var=
precipitation << | |
| mean_61-90 - |
| mean_71-00 - |
| mean_81-10 - |
| | standard_format -

Usage

1
2
3
4
5
selectDWD(name = "", exactmatch = TRUE, mindex = metaIndex,
  id = findID(name, exactmatch = exactmatch, mindex = mindex),
  base = "ftp://ftp-cdc.dwd.de/pub/CDC/observations_germany/climate",
  res = "", var = "", per = "", findex = fileIndex,
  current = FALSE, meta = FALSE, outvec = FALSE, ...)

Arguments

name

Char: station name(s) passed to findID, along with the next two arguments. All ignored if id is given. DEFAULT: ""

exactmatch

Logical passed to findID: match name with ==)? Else with grepl. DEFAULT: TRUE

mindex

Single object: Index with metadata passed to findID. DEFAULT: rdwd:::metaIndex

id

Char/Number: station ID with or without leading zeros, e.g. "00614" or 614. Is internally converted to an integer, because some DWD meta data files also contain no leading zeros. DEFAULT: findID(name)

base

Single char: main directory of DWD ftp server, defaulting to observed climatic records. Must be the same base used to create findex. DEFAULT: ftp://ftp-cdc.dwd.de/pub/CDC/observations_germany/climate

res

Char: temporal resolution available at base, usually one of c("hourly","daily","monthly"), see section 'Description' above. res/var/per together form the path. DEFAULT: ""

var

Char: weather variable of interest. Usually one of c("air_temperature", "cloudiness", "precipitation", "pressure", "sun", "wind") (only in hourly), c("soil_temperature", "solar") (in hourly and daily), or c("kl", "more_precip") (in daily and monthly). See more in View(rdwd:::fileIndex). DEFAULT: ""

per

Char: desired time period. One of "recent" (data from the last year, up to date usually within a few days) or "historical" (long time series). Can be abbreviated (if the first letter is "r" or "h", full names are used). To get both datasets, use per="hr" or per="rh" (and outvec=TRUE). per is set to "" if var=="solar". DEFAULT: ""

findex

Single object: Index used to select filename, as returned by createIndex.To use a current / custom index, use myIndex <- createIndex(indexFTP("/daily/solar")) (with desired path, of course). DEFAULT: rdwd:::fileIndex

current

Single logical for case 3/4 with given path: instead of findex, use a list of the currently available files at base/res/var/per? This will call indexFTP, thus requires availability of the RCurl package. DEFAULT: FALSE

meta

Logical: return metadata txt file name instead of climate data zip file? Relevant only in case 4 (path and id given). See metaIndex for a compilation of all metaData files. DEFAULT: FALSE

outvec

Single logical: if path or ID length > 1, instead of a list, return a vector? (via unlist). DEFAULT: FALSE

...

Further arguments passed to indexFTP if current=TRUE, like dir, quiet

Value

Character string with file path and name(s) in the format "base/res/var/per/filename.zip"

Author(s)

Berry Boessenkool, [email protected], Oct 2016

See Also

dataDWD, metaIndex, ../doc/mapDWD.html, vignette("mapDWD", package="rdwd")

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Give weather station name (must be existing in metaIndex):
findID("Potsdam", exactmatch=FALSE)
selectDWD("Potsdam", res="daily", var="kl", per="historical")
# all files for all stations matching "Koeln":
selectDWD("Koeln", exactmatch=FALSE)
findID("Koeln", FALSE)

## Not run:  # Excluded from CRAN checks to save time
# or directly give station ID:
selectDWD(id="00386", res="daily", var="kl", per="historical")
selectDWD(id=386, res="daily", var="kl", per="historical")
# period abbreviatable:
selectDWD(id="00386", res="daily", var="kl", per="h")
selectDWD(id="00386", res="daily", var="kl", per="h", meta=TRUE)

# vectorizable:
selectDWD(id="01050", res="daily", var="kl", per=c("r","h"))
selectDWD(id="01050", res="daily", var="kl", per="rh", outvec=TRUE)
selectDWD(id="01050", res=c("daily","monthly"), var="kl", per="r")
# vectorization gives not the outer product, but elementwise comparison:
selectDWD(id="01050", res=c("daily","monthly"), var="kl", per="hr")

# all zip files in all paths matching id:
selectDWD(id=c(1050, 386))
# all zip files in a given path (if ID is empty):
head(  selectDWD(id="", res="daily", var="kl", per="recent")   )

# See if warnings come as expected and are informative:
selectDWD()
selectDWD(7777)
selectDWD(id=7777)
selectDWD(id="", res="dummy", var="dummy")
selectDWD(res="dummy")
selectDWD(res="daily", per="r")
selectDWD(res="daily", var="kl")
selectDWD(id="01050", res=c("daily","monthly"), var="kl") # needs 'per'
selectDWD(id="00386", meta=TRUE)

selectDWD("Potsdam", res="daily", var="solar")
# should be an error:
berryFunctions::is.error(  selectDWD(id="Potsdam", res="daily", var="solar"), TRUE)
berryFunctions::is.error(  selectDWD(id="", current=TRUE) , tell=TRUE, force=TRUE)

## End(Not run)

brry/rdwd documentation built on Aug. 19, 2018, 7:24 p.m.