get_files_available: Check Available Forecast Files and Check if Action Required

Description Usage Arguments Details Value Author(s) Examples

Description

Part of the automation process. This function checks the opendata server for available files and checks whether this specific forecast has alreday been processed (checking for existing ASCII files on the local disc; uses the naming rules of write_ascii!).

Usage

1
get_files_available(type = "L", stn = NULL, outdir = "DWDMOS")

Arguments

type

either L or S (see 'Details' section).

stn

NULL or name of the station. Must match the station naming of the DWD if specified (see get_station_information). See 'Details' section for more information.

outdir

name of the output directory where the already-processed forecasts are stored (see write_ascii).

Details

The DWD provides two sets of MOSMIX forecasts labeled as L and S. L-forecasts are available four times a day and XML files for individual stations are available on the opendata server. S-forecasts become available 24 times a day and only one XML file is avialable on the opendata server containing the forecasts for all stations (few thousand stations).

TODO: requires more detailed description.

Value

Returns a data.frame with initialization times (IssueTime), name of the XML file plus the full URL, local file name, and a check whether or not a file has been processed already.

Author(s)

Reto Stauffer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Latest L-type DWD MOSMIX forecast file for Innsbruck Airport
url <- "https://opendata.dwd.de/weather/local_forecasts/mos/MOSMIX_L/single_stations/11120/kml/MOSMIX_L_LATEST_11120.kmz"

# Download and extract file
kmz   <- tempfile("mosmix_demo_", fileext = ".kmz")
check <- download.file(url, kmz)
if ( inherits(check, "try-error") ) stop("Problems downloading the file!")
kml   <- unzip(kmz)

# Parsing the unzipped kml file (XML format)
# And extract required datetime and meta information.
doc <- XML::xmlParse(kml)
datetime <- get_datetime(doc)
meta     <- get_meta_info(doc)
stations <- get_station_information(doc)

# Extracting forecasts now
fcst <- get_forecasts("11120", doc, datetime, meta)
write_ascii(fcst, dir = ".")
write_ascii(fcst, file = "foo.dat", dir = ".")

# Remove kmz and kml file
file.remove(kmz, kml)

retostauffer/Rmosmix documentation built on May 22, 2019, 2:45 p.m.