Learn R Programming

rdwd (version 1.1.0)

selectDWD: Select data from the DWD CDC FTP Server

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 2, you can explicitly set res="",var="",per="" to avoid the default interactive selection. 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 dwdbase: "<" 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 | res=annual
var=
| | kl < | kl < | kl <
| | more_precip < | more_precip < | more_precip <
air_temperature << | air_temperature < | | |
extreme_temperature << | | | |
extreme_wind << | | | |
| cloudiness < | | |
| cloud_type < | | |
| dew_point < | | |
precipitation << | precipitation < | | |
| pressure < | | |
| soil_temperature < | soil_temperature < | |
solar << | solar - | solar - | |
| sun < | | |
| visibility < | | |
| | water_equiv < | |
wind << | wind < | | |
| wind_synop < | | |

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 - |
| | air_temperature <
| | cloudiness <
| | moisture <
| | pressure <
| | soil <
| | standard_format -
| | visibility <
| | wind <

Usage

selectDWD(name = "", res = NA, var = NA, per = NA,
  exactmatch = TRUE, mindex = metaIndex, id = findID(name, exactmatch
  = exactmatch, mindex = mindex), base = dwdbase, findex = fileIndex,
  current = FALSE, meta = FALSE, meta_txt_only = TRUE,
  outvec = any(per %in% c("rh", "hr")), ...)

Arguments

name

Char: station name(s) passed to findID, along with exactmatch and mindex. All 3 arguments are ignored if id is given. DEFAULT: ""

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: NA for interactive selection

var

Char: weather variable of interest, like e.g. "air_temperature", "cloudiness", "precipitation", "soil_temperature", "solar", "kl", "more_precip" See above and in View(rdwd:::fileIndex). DEFAULT: NA for interactive selection

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: NA for interactive selection

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, exaxtmatch, mindex)

base

Single char: main directory of DWD ftp server. Must be the same base used to create findex. DEFAULT: dwdbase

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) and case 3 for res="multi_annual". See metaIndex for a compilation of all metaData files. DEFAULT: FALSE

meta_txt_only

Logical: if meta, only return .txt files, not the pdf and html files? DEFAULT: TRUE

outvec

Single logical: if path or ID length > 1, instead of a list, return a vector? (via unlist). DEFAULT: per %in% c("rh","hr")

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"

See Also

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

Examples

Run this code
# NOT RUN {
# Give weather station name (must be existing in metaIndex):
selectDWD("Potsdam", res="daily", var="kl", per="historical")

# all files for all stations matching "Koeln":
selectDWD("Koeln", res="", var="", per="", exactmatch=FALSE)
findID("Koeln", FALSE)

# }
# NOT RUN {
 # Excluded from CRAN checks to save time

# selectDWD("Potsdam") # interactive selection of res/var/per

# directly give station ID, can also be id="00386" :
selectDWD(id=386, res="daily", var="kl", per="historical")

# period can be abbreviated:
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="rh") # list if outvec=F
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), res="",var="",per="")
# all zip files in a given path (if ID is empty):
head(  selectDWD(id="", res="daily", var="kl", per="recent")   )

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab