R/meteo_ogimet_synop.R
meteo_ogimet_synop.RdDownloads raw SYNOP messages from the Ogimet getsynop endpoint and decodes
them into a tidy data.frame using the synop_parser() function. Two retrieval
modes are supported:
Numeric or character vector of WMO station IDs. Optional when
country_name is provided; required otherwise.
Character or Date vector of length 2 giving the start and end of
the requested period, e.g. c("2009-12-01", "2009-12-04"). Defaults to
the last 30 days.
Optional; passed to synop_parser() for country-specific
precipitation indicator decoding (e.g. "RU"). Single string or NULL
(default). This is distinct from country_name.
Optional character string naming the country whose
stations should be downloaded, as recognised by Ogimet (e.g.
"Poland", "Germany", "France"). When provided, the state= Ogimet
parameter is used and station is ignored. The full date range is
fetched in a single request.
Logical. When TRUE (default) returns a compact data.frame with
20 standardised columns (see Value below). When FALSE the
full parser output is returned.
Logical. When TRUE (default) network errors are caught
and a message is emitted; when FALSE errors propagate to the caller.
By default (simplified = TRUE), a compact data.frame with one
row per decoded SYNOP observation. Columns:
date — Observation date-time (POSIXct, UTC).
station — WMO station identifier (character).
t2m — Air temperature at 2 m (°C).
dpt2m — Dew-point temperature at 2 m (°C).
rel_hum — Relative humidity (%), derived via compute_relative_humidity().
tmax — Daily maximum temperature from Section 3 (°C).
tmin — Daily minimum temperature from Section 3 (°C).
wd — Wind direction (degrees).
ws — Wind speed (m/s or knots, per wind_unit).
gust — Highest gust speed from Section 3, same unit as ws.
press — Station-level pressure (hPa).
slp — Sea-level pressure (hPa).
press_tend — 3-hour pressure change (hPa).
precip — Precipitation amount (mm).
Nt — Total cloud cover (oktas, 0–8) from the Nddff group.
Nh — Cover of low clouds (genera Sc, St, Cu, Cb) in oktas (0–8),
from Section 1 group 8NhCLCMCH; NA when not reported.
N_base — Height of base of lowest observed cloud (m).
insol — Daily sunshine duration (hours).
visibility — Horizontal visibility (m).
snow — Total snow depth (cm); 0 for trace amounts.
When simplified = FALSE, a data.frame with the first two columns
station_id (WMO identifier, character) and Date (POSIXct, UTC),
followed by all columns produced by synop_parser() with as_data_frame = TRUE:
station_type, region, obs_day, obs_hour, wind_unit,
wind_estimated, visibility, cloud_cover, wind_direction,
wind_speed, air_temperature, dewpoint_temperature,
station_pressure, sea_level_pressure, pressure_tendency,
pressure_change, precipitation_amount, precipitation_time,
cloud_base_min, cloud_base_max, low_cloud_type, middle_cloud_type,
high_cloud_type, low_cloud_amount, maximum_temperature,
minimum_temperature, gust, sunshine_duration,
snow_depth, snow_depth_state, source.
Returns NULL invisibly when the download fails and allow_failure = TRUE.
Station mode (station provided): fetches messages for one or more
WMO station IDs.
URL form: http://www.ogimet.com/cgi-bin/getsynop?block=<id>&begin=<YYYYMMDDhhmm>&end=<YYYYMMDDhhmm>
Country mode (country_name provided): fetches messages for all
Ogimet stations in a country in a single request.
URL form: http://www.ogimet.com/cgi-bin/getsynop?begin=<YYYYMMDDhhmm>&end=<YYYYMMDDhhmm>&state=<country_name>
When both station and country_name are supplied, country_name takes
precedence and a warning is issued.
Each line of the response is a comma-separated record:
station_id,year,month,day,hour,minute,<SYNOP message>.
The SYNOP message is decoded via synop_parser() with as_data_frame = TRUE.
# \donttest{
# Station mode: Poznan-Lawica (Poland)
poznan = meteo_ogimet_synop(station = 12330,
date = c("2009-12-01", "2009-12-04"))
#> Warning: 'meteo_ogimet_synop()' is deprecated. Use 'meteo_ogimet(source = "synop")' instead.
#> station: 12330
#> http://www.ogimet.com/cgi-bin/getsynop?block=12330&begin=200912010000&end=200912042359
#> Downloaded 32 SYNOP messages for: 12330
head(poznan)
#> date station t2m dpt2m rel_hum tmax tmin wd ws gust press
#> 1 2009-12-01 00:00:00 12330 4.3 3.7 95.9 NA NA NA 0 NA 989.4
#> 2 2009-12-01 03:00:00 12330 5.2 4.0 92.0 NA NA 10 1 NA 989.3
#> 3 2009-12-01 06:00:00 12330 5.4 4.5 93.9 5.8 2.9 10 2 NA 989.7
#> 4 2009-12-01 09:00:00 12330 6.3 4.9 90.8 NA NA 40 3 NA 990.9
#> 5 2009-12-01 12:00:00 12330 6.2 4.8 90.7 NA NA 10 3 NA 992.0
#> 6 2009-12-01 15:00:00 12330 6.0 5.1 94.0 NA NA 340 3 NA 993.7
#> slp press_tend precip Nt Nh N_base insol visibility snow
#> 1 1000.2 0.8 0 7 7 1500 NA 3500 NA
#> 2 1000.1 -0.1 NA 7 3 1500 NA 10000 NA
#> 3 1000.4 0.4 0 8 8 100 3.1 8000 NA
#> 4 1001.6 1.2 NA 8 8 100 NA 2500 NA
#> 5 1002.7 1.1 0 8 8 100 NA 2400 NA
#> 6 1004.5 1.7 NA 8 8 100 NA 2200 NA
# Station mode: multiple stations
two_stations = meteo_ogimet_synop(station = c(12330, 12375),
date = c("2019-06-01", "2019-06-03"))
#> Warning: 'meteo_ogimet_synop()' is deprecated. Use 'meteo_ogimet(source = "synop")' instead.
#> station: 12330
#> http://www.ogimet.com/cgi-bin/getsynop?block=12330&begin=201906010000&end=201906032359
#> Could not retrieve data for: 12330
#> No SYNOP data returned for: 12330
#> station: 12375
#> http://www.ogimet.com/cgi-bin/getsynop?block=12375&begin=201906010000&end=201906032359
#> Downloaded 72 SYNOP messages for: 12375
head(two_stations)
#> date station t2m dpt2m rel_hum tmax tmin wd ws gust press
#> 1 2019-06-01 00:00:00 12375 16.7 13.3 80.4 NA NA 260 2 NA 1008.8
#> 2 2019-06-01 01:00:00 12375 15.7 13.1 84.5 NA NA 250 2 NA 1009.0
#> 3 2019-06-01 02:00:00 12375 15.0 13.3 89.6 NA NA 260 2 NA 1009.0
#> 4 2019-06-01 03:00:00 12375 14.1 13.1 93.7 NA NA 290 2 NA 1009.2
#> 5 2019-06-01 04:00:00 12375 15.1 14.4 95.6 NA NA 300 2 NA 1009.8
#> 6 2019-06-01 05:00:00 12375 16.2 15.0 92.6 NA NA 290 2 NA 1009.9
#> slp press_tend precip Nt Nh N_base insol visibility snow
#> 1 1021.6 0.0 0 1 NA NA NA 35000 NA
#> 2 1021.8 0.2 NA 1 NA NA NA 35000 NA
#> 3 1021.9 0.1 NA 1 NA NA NA 30000 NA
#> 4 1022.1 0.4 NA 2 NA NA NA 17000 NA
#> 5 1022.7 0.8 NA 7 7 600 NA 12000 NA
#> 6 1022.7 0.9 NA 6 6 600 NA 16000 NA
# Country mode: all Polish stations for one day
poland = meteo_ogimet_synop(country_name = "Poland",
date = c("2009-12-15", "2009-12-15"))
#> Warning: 'meteo_ogimet_synop()' is deprecated. Use 'meteo_ogimet(source = "synop")' instead.
#> Downloading country: Poland
#> http://www.ogimet.com/cgi-bin/getsynop?begin=200912150000&end=200912152359&state=Poland
#> Could not retrieve data for: Poland
#> No SYNOP data returned for: Poland
head(poland)
#> NULL
# Simplified view
poznan_simple = meteo_ogimet_synop(station = 12330,
date = c("2009-12-01", "2009-12-04"),
simplified = TRUE)
#> Warning: 'meteo_ogimet_synop()' is deprecated. Use 'meteo_ogimet(source = "synop")' instead.
#> station: 12330
#> http://www.ogimet.com/cgi-bin/getsynop?block=12330&begin=200912010000&end=200912042359
#> Could not retrieve data for: 12330
#> No SYNOP data returned for: 12330
head(poznan_simple)
#> NULL
# }