Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e0f0822
synop parser - part1
bczernecki Nov 7, 2025
02ac078
add gc
bczernecki Jan 19, 2026
9e1430c
add data.table to merge
bczernecki Jan 19, 2026
cd30597
enforce data table class
bczernecki Jan 19, 2026
9147326
fix: trimws
bczernecki Jan 20, 2026
8dae43c
merging with master
bczernecki May 8, 2026
c2a060a
add parser
bczernecki May 8, 2026
09cff09
fix hydro
bczernecki May 9, 2026
137a6e4
fix vignette
bczernecki May 9, 2026
3997c92
unify assign operators
bczernecki May 9, 2026
77f9a42
fix vignette
bczernecki May 9, 2026
71683de
fix vignette
bczernecki May 9, 2026
6790e9f
fix unit tests for meteo-imgw
bczernecki May 9, 2026
ca8d294
add parser unit-tests
bczernecki May 9, 2026
65b2c7b
cleaning parser for SYNOP messages
bczernecki May 9, 2026
bb6bd8c
update README
bczernecki May 10, 2026
45ab132
SYNOP parser
bczernecki May 10, 2026
31fff95
add draft vignette of synop parser
bczernecki May 11, 2026
cbad4bd
fix: html5 check
bczernecki May 12, 2026
1a9824d
climate rc 1.4.0
bczernecki May 12, 2026
36c8024
merge functionalities into meteo_imgw and meteo_ogimet
bczernecki May 13, 2026
f0d94f3
climate rc1.4
bczernecki May 13, 2026
d6b5179
update vignette
bczernecki May 13, 2026
8af6b91
climate - add SYNOP decoder
bczernecki May 13, 2026
6396adb
updates docs with new roxygen
Nowosad Jul 3, 2026
eddb81b
fixes for shortening
bczernecki Jul 7, 2026
402e5ad
Merge branch '115-synop_parser-and-ogimet-improvements' of github.com…
bczernecki Jul 7, 2026
ef24c19
fix: imgw telemetry stations changed format
bczernecki Jul 8, 2026
a86d0f6
fix: ogimet HTML parsing
bczernecki Jul 9, 2026
b683084
fix: stations hydro imgw telemetry
bczernecki Jul 9, 2026
baa1125
fix: sounding_wyoming
bczernecki Jul 9, 2026
1c4f37b
fix: HTML5-check - part1
bczernecki Jul 9, 2026
04b56fd
fix: reduce use of XML
bczernecki Jul 9, 2026
ec76c27
coords mandatory for ogimet
bczernecki Jul 9, 2026
4e0b0ca
get rid off xml
bczernecki Jul 9, 2026
5b48b22
climate rc 1.4.0
bczernecki Jul 9, 2026
25630b5
fix: vignettes
bczernecki Jul 9, 2026
296adc2
improve ogimet parsing
bczernecki Jul 10, 2026
618acb9
rc-hotfix
bczernecki Jul 10, 2026
d651415
Merge branch 'master' into climate_rc140_hotfix
bczernecki Jul 10, 2026
d9d6767
add sf
bczernecki Jul 10, 2026
94b157f
Merge branch 'climate_rc140_hotfix' of github.com:bczernecki/climate …
bczernecki Jul 10, 2026
64420e9
update README and vignettes
bczernecki Jul 10, 2026
4cab894
climate 1.4.0
bczernecki Jul 10, 2026
c165ad5
fix: vignette
bczernecki Jul 10, 2026
a08ba08
fix: synop parser vignette
bczernecki Jul 10, 2026
73dbc00
fix: vignette usecase_ogimet
bczernecki Jul 10, 2026
8abda1b
usecase_ogimet simplified
bczernecki Jul 10, 2026
886f2a4
fix: vignette
bczernecki Jul 10, 2026
47f656b
hardcode figures
bczernecki Jul 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ coverage:
- "R/sounding_wyoming.R"
- "R/imgw_read.R"
- "R/onAttach.R"
- "R/meteo_shortening_imgw.R"
status:
patch:
default:
Expand Down
23 changes: 23 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* `meteo_imgw_daily` fix for current year data retrieval from IMGW-PIB repository
* `imgw_read` - fix for wrongly formatted input CSVs for hydrological data in the IMGW-PIB repository


# climate 1.2.4

* R version >= 4.1 is now required
Expand All @@ -58,6 +59,7 @@
* Adding `hydro_imgw_datastore()` to retrieve data for hydrological stations from IMGW-PIB repository datastore (telemetry system)
* Adding `stations_hydro_imgw_telemetry()` to retrieve coordinates metadata for hydrological telemetry stations from IMGW-PIB


# climate 1.2.3

* Fixes and modifications for `meteo_imgw_daily()` and `meteo_imgw_hourly()` due
Expand All @@ -69,6 +71,7 @@ to changes in the IMGW-PIB meteorological datasets since 2024
* Logging errors in package environment and providing summary at the end of downloading instead of instant messaging
* Minor changes in unit-tests to adjust for most recent code changes


# climate 1.2.2

* Fixes and modifications for `hydro_imgw()` set of functions due to changes in the IMGW-PIB hydrological datasets
Expand All @@ -79,23 +82,27 @@ to changes in the IMGW-PIB meteorological datasets since 2024
* Resolving date formatting for hydrological data - the Date column represents calendar date
* Corrected logic in downloading hourly OGIMET dataset


# climate 1.2.1

* Major fixes for adjusting code to stay in line with CRAN policies
* Corrected duplicated column names for IMGW-PIB stations
* Adjusted encoding changes and documentation updates in `meteo_imgw_telemetry_stations()`


# climate 1.2.0

* Corrected encoding problems for some of platforms where IMGW-PIB metadata were not parsed correctly
* Added location of IMGW-PIB telemetry stations within `meteo_imgw_telemetry_stations()`
* Minor bug fixes


# climate 1.1.1

* Fix problems with downloading `precip` dataset from IMGW-PIB repository after recent changes in metadata
* Bug fix for `ogimet_daily` if data contains more than one year


# climate 1.1.0

* A new approach for handling CRAN policy for resolving problems if network issues are detected or some of the external services are temporarily down.
Expand All @@ -112,81 +119,96 @@ to changes in the IMGW-PIB meteorological datasets since 2024
* units added to column labels for `nearest_stations_` set of functions instead of column names for easier processing (e.g. [km] are visible now only as attributes)
* new functions follow lintr settings


# climate 1.0.4

* Function `spheroid_dist` added to improve accuracy of calculations between points, but also avoid installing GIS dependencies (thanks to @kadyb)
* Function `nearest_stations_imgw()` now uses the Vincenty's formula in `spheroid_dist` to calculate the distance between points on a spheroid, not the Euclidean distance (previously results were inaccurate for some specific cases)
* minor bugs fixes and improvements


# climate 1.0.3

* Adding possibility to download BUFR vertical sounding dataset from `http://weather.uwyo.edu/upperair/sounding.html`; extra information with supporting example added to the `sounding_wyoming`'s documentation
* `hydro_imgw` supports now exception for current year which has no flow data until it is verified by the IMGW-PIB
* `ogimet_daily` automatically detects column names to be used for extraction in final data.frame; extra debugging info when temperature or precipitation columns are missing
* minor changes in documentation (e.g. updated links to NOAA website)


# climate 1.0.1

* Adding `data.table` package to read CP1250 on machines that do not support this encoding (translit used instead)


# climate 0.9.9

* Changing URL `danepubliczne.imgw.pl` to `dane.imgw.pl` where needed
* Fixing minor ogimet and IMGW bugs
* Do not stop downloading data from `ogimet.com`, instead check for all available data in given period of time


# climate 0.9.8

* Adding informative message if problems with NOAA hourly dataset occur
* Informative message if problems with downloading detected for non-IMGW dataset


# climate 0.9.7

* stop working if no internet connection detected


# climate 0.9.6

* Adding nearest_stations_noaa for NOAA hourly dataset


# climate 0.9.5

* Following CRAN policies
* Adding information if connection issues detected or URL no accessible
* RCurl dependency removal
* CO2 & Wyoming examplary data can be loaded offline


# climate 0.9.4

* New dataset:
* Hourly NOAA ISH (Integrated Surface Hourly) data - global meteorological dataset dated back up to 1900


# climate 0.9.3

* Bug fixes
* #27
* New datasets:
* CO2 concentration from Mauna Loa observatory


# climate 0.9.2

* Bug fixes
* #26


# climate 0.9.1

* climate is independent of imgw package
* Bug fixes
* #24
* restored possibility of downloading single station from Polish (IMGW) repository


# climate 0.3

* improves API


# climate 0.2

* splits imgw into two packages: imgw and climate


# imgw 0.1.1

* New datasets
Expand All @@ -201,6 +223,7 @@ to changes in the IMGW-PIB meteorological datasets since 2024
* Bug fixes
* Fixes a bug in the `hydro_daily()` that prevented from merging more than 1 dataset


# imgw 0.1.0

* Deploying the package on CRAN!
Expand Down
4 changes: 2 additions & 2 deletions R/compute_relative_humidity.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#' @param dpt2m Numeric vector. Dew-point temperature (2 m) in degrees Celsius.
#' Must be the same length as `t2m`.
#'
#' @return Numeric vector of relative humidity values in percent (0100).
#' @return Numeric vector of relative humidity values in percent (0-100).
#' Returns `NA` where either input is `NA`. Values are not clamped, so
#' rounding errors may produce results marginally outside 0100.
#' rounding errors may produce results marginally outside 0-100.
#'
#' @details
#' The August-Roche-Magnus approximation is:
Expand Down
7 changes: 4 additions & 3 deletions R/nearest_stations_ogimet.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#'

nearest_stations_ogimet = function(country = "United Kingdom",
date = Sys.Date(),
date = Sys.Date() - 1,
add_map = FALSE,
point = c(2, 50),
no_of_stations = 10,
Expand Down Expand Up @@ -113,6 +113,7 @@ nearest_stations_ogimet_bp = function(country = country,

# run only if downloaded file is valid
if (!is.na(body) & (object.size(body) > 500)) {
# nocov start
a = paste(body, sep = "", collapse = "")
b = strsplit(a, "Decoded synops since")
b1 = lapply(b, function(x) substr(iconv(x, from = 'UTF-8', to = 'ASCII//TRANSLIT'), 1, 400))
Expand Down Expand Up @@ -159,6 +160,7 @@ nearest_stations_ogimet_bp = function(country = country,
res = data.frame(wmo_id = res1[, 4], station_names = station_names,
lon = lon, lat = lat, alt = as.numeric(res1[, 3]))
result = rbind(result,res)
# nocov end
} else {
result = NULL
message(paste("Wrong name of a country. Please check countries names at
Expand All @@ -168,7 +170,7 @@ nearest_stations_ogimet_bp = function(country = country,
}

if (!is.null(result)) {

# nocov start
point = as.data.frame(t(point))
names(point) = c("lon", "lat")
distmatrix = rbind(point, result[, 3:4])
Expand All @@ -187,7 +189,6 @@ nearest_stations_ogimet_bp = function(country = country,
attr(result[["lat"]], "label") = "decimal degrees"
attr(result[["alt"]], "label") = "metres AGL"

# nocov start
if (add_map == TRUE) {
if (!requireNamespace("maps", quietly = TRUE)) {
stop("package maps required, please install it first")
Expand Down
2 changes: 1 addition & 1 deletion R/ogimet_daily.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ogimet_daily_bp = function(date = date,
"Wind_Int." = character(),
"Wind_Gust" = character(),
"Pres.s.lev" = character(),
"Precmm" = character(),
"Prec" = character(),
"SunD-1" = character(),
"SnowDep" = character(),
"TotClOct" = character(),
Expand Down
52 changes: 22 additions & 30 deletions R/sounding_wyoming.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#' Sounding data
#'
#' Downloading the measurements of the vertical profile of atmosphere (also known as sounding data). Data can be retrieved using TEMP and BUFR sounding formatting.
#' Downloading the measurements of the vertical profile of atmosphere (also known as sounding data).
#' Data can be retrieved using TEMP and BUFR sounding formatting. By default automatic detection of input format is used.
#'
#' @param wmo_id international WMO station code (World Meteorological Organization ID); For Polish stations: Leba - 12120, Legionowo - 12374, Wrocław- 12425
#' @param yy year - single number
#' @param mm month - single number denoting month
#' @param dd day - single number denoting day
#' @param hh hour - single number denoting initial hour of sounding; for most stations this measurement is done twice a day (i.e. at 12 and 00 UTC), sporadically 4 times a day
#' @param min minute - single number denoting initial minute of sounding; applies only to BUFR soundings.
#' @param source - "BUFR", "TEMP" or "DETECT". By default "DETECT" is used.
#' @param wmo_id international WMO station code (World Meteorological Organization ID); For Polish stations: Leba - 12120, Legionowo - 12374, Wrocław - 12425
#' @param yy year - calendar year
#' @param mm month - calendar month
#' @param dd day - calendar day
#' @param hh hour - hour of sounding; for most stations measurements are performed twice a day (i.e. at 12 and 00 UTC), sporadically 4 times a day
#' @param min minute - minute of sounding; Default 00; Other values applies only to BUFR soundings.
#' @param source - optional; `AUTODETECT`, `BUFR` (raw; most detailed) or `TEMP` (FM-35) input format. By default "AUTODETECT" is used which means that the function will try to detect the format automatically. If a station use only a specific format that is known you can specify it explicitly.
#' @param allow_failure logical - whether to proceed or stop on failure. By default set to TRUE (i.e. don't stop on error). For debugging purposes change to FALSE
#' @importFrom utils read.fwf
#' @return Returns two lists with values described at: weather.uwyo.edu ; The first list contains:
Expand All @@ -35,36 +36,27 @@
#'
#' @examples
#' \donttest{
#' ##############################################################################
#' # download data for Station 45004 starting 1120Z 11 Jul 2021; Kowloon, HONG KONG, CHINA
#' # using TEMP and BUFR sounding formats
#' ##############################################################################
#' TEMP = sounding_wyoming(wmo_id = 45004, yy = 2021, mm = 07, dd = 17,
#' hh = 12, min = 00, source = "TEMP")
#' head(TEMP[[1]])
#'
#' BUFR = sounding_wyoming(wmo_id = 45004, yy = 2021, mm = 07, dd = 17,
#' hh = 12, min = 00, source = "BUFR")
#' head(BUFR[[1]])
#' # using AUTODETECT, TEMP and BUFR sounding formats
#'
#' # autodect input format:
#' sounding_auto = sounding_wyoming(wmo_id = 45004,
#' yy = 2021, mm = 07, dd = 17, hh = 12)
#'
#' ##############################################################################
#' ### example with a random date to download sounding from LEBA, PL station: ###
#' ##############################################################################
#'
#' # no "source" argument is needed as the function will detect format automatically
#' profile = sounding_wyoming(wmo_id = 12120,
#' yy = sample(2000:2019,1),
#' mm = sample(1:12,1),
#' dd = sample(1:20,1),
#' hh = 0)
#' # plot(profile[[1]]$HGHT, profile[[1]]$PRES, type = 'l')
#' # temp (fm35) input format:
#' sounding_temp = sounding_wyoming(wmo_id = 45004,
#' yy = 2021, mm = 07, dd = 17, hh = 12,
#' source = "TEMP")
#' # bufr input format:
#' sounding_bufr = sounding_wyoming(wmo_id = 45004,
#' yy = 2021, mm = 07, dd = 17, hh = 12, min = 00,
#' source = "BUFR")
#' }
#'

sounding_wyoming = function(wmo_id,
yy, mm, dd, hh, min = 00,
source = "DETECT",
source = "AUTODETECT",
allow_failure = TRUE) {

if (allow_failure) {
Expand Down
2 changes: 2 additions & 0 deletions R/stations_ogimet.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ stations_ogimet_bp = function(country = country, date = date, add_map = add_map)
res = suppressWarnings(do.call("rbind", strsplit(res, " ")))
res1 = matrix(res[, c(1, 3, 5:7)], ncol = 5)

# nocov start
lat = suppressWarnings(
as.numeric(substr(res1[, 1], 1, 2)) +
(as.numeric(substr(res1[, 1], 4, 5)) / 100) * 1.6667
Expand Down Expand Up @@ -144,6 +145,7 @@ if (!is.null(res)) {
col = 'grey70', cex = 0.6)
maps::map(add = TRUE)
}
# nocov end

} # end of checking if res is NULL
return(res)
Expand Down
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The stable release of the **climate** package from the [CRAN](https://CRAN.R-pro
install.packages("climate")
```

It is highly recommended to install the most up-to-date development version of **climate** from [GitHub](https://github.com/bczernecki/climate) with:
It is also possible to install the most up-to-date development version of **climate** from [GitHub](https://github.com/bczernecki/climate) with:

``` r
library(remotes)
Expand All @@ -42,42 +42,50 @@ install_github("bczernecki/climate")

### Meteorological data

- 🌍 **meteo_ogimet()** - Downloading hourly and daily meteorological data from the SYNOP stations available in the ogimet.com collection.
- 🌍 [**meteo_ogimet**](https://bczernecki.github.io/climate/reference/meteo_ogimet.html) -
Downloading hourly and daily meteorological data from the SYNOP stations available in the ogimet.com collection.
Any meteorological (aka SYNOP) station working under the World Meteorological Organization framework after year 2000 should be accessible.
Two backends are available and selected automatically: raw **SYNOP decoding** (`source = "synop"`, default for `interval = "hourly"`) and **HTML scraping** (`source = "html"`, default for `interval = "daily"`).
Country-level bulk downloads are supported via the `country_name` argument (SYNOP backend only).

- 🌍 **meteo_noaa_hourly()** - Downloading hourly NCEI/NOAA Integrated Surface Hourly (ISH) meteorological data - Some stations have > 100 years long history of observations
- 🌍 [**meteo_noaa_hourly**](https://bczernecki.github.io/climate/reference/meteo_noaa_hourly.html) -
Downloading hourly NCEI/NOAA Integrated Surface Hourly (ISH) meteorological data - Some stations have > 100 years long history of observations

- 🌍 **meteo_noaa_co2()** - Downloading monthly CO2 measurements from Mauna Loa Observatory
- 🌍 [**meteo_noaa_co2**](https://bczernecki.github.io/climate/reference/meteo_noaa_co2.html)] -
Downloading monthly CO2 measurements from Mauna Loa Observatory

- 🌍 **sounding_wyoming()** - Downloading measurements of the vertical profile of atmosphere (aka rawinsonde data)
- 🌍 [**sounding_wyoming**](https://bczernecki.github.io/climate/reference/sounding_wyoming.html) -
Downloading measurements of the vertical profile of atmosphere (aka rawinsonde data)

- 🇵🇱 **meteo_imgw()** - Downloading hourly, daily, and monthly meteorological data from the Polish met service across
- 🇵🇱 [**meteo_imgw**](https://bczernecki.github.io/climate/reference/meteo_imgw.html) -
Downloading hourly, daily, and monthly meteorological data from the Polish met service across
all types of stations (i.e. SYNOP/CLIMATE/PRECIP ) available in the danepubliczne.imgw.pl collection.
It is a wrapper for `meteo_monthly()`, `meteo_daily()`, `meteo_hourly()` and `meteo_imgw_datastore()` which gives access from montly to even to 10-min dataset.


### (Polish) Hydrological data

- 🇵🇱 **hydro_imgw()** - Downloading hourly, daily, and monthly hydrological data from stations available in the
- 🇵🇱 [**hydro_imgw**](https://bczernecki.github.io/climate/reference/hydro_imgw.html) -
Downloading hourly, daily, and monthly hydrological data from stations available in the
danepubliczne.imgw.pl collection.
It is a wrapper for previously developed set of functions such as: `hydro_monthly()`, and `hydro_daily()`
- 🇵🇱 **hydro_imgw_datastore()** - Downloading hourly and subhourly hydrological data from the IMGW-PIB hydro telemetry stations.

- 🇵🇱 [**hydro_imgw_datastore**](https://bczernecki.github.io/climate/reference/hydro_imgw_datastore.html) -
Downloading hourly and subhourly hydrological data from the IMGW-PIB hydro telemetry stations.

### Auxiliary functions and datasets

- 🌍 **stations_ogimet()** - Downloading information about all stations available in the selected
- 🌍 **stations_ogimet** - Downloading information about all stations available in the selected
country in the Ogimet repository
- 🌍 **nearest_stations_ogimet()** - Downloading information about nearest stations to the selected point using Ogimet repository
- 🌍 **nearest_stations_noaa()** - Downloading information about nearest stations to the selected point available for the selected country in the NOAA ISH meteorological repository
- 🇵🇱 **nearest_stations_imgw()** - List of nearby meteorological or hydrological IMGW-PIB stations in Poland
- 🌍 **nearest_stations_ogimet** - Downloading information about nearest stations to the selected point using Ogimet repository
- 🌍 **nearest_stations_noaa** - Downloading information about nearest stations to the selected point available for the selected country in the NOAA ISH meteorological repository
- 🇵🇱 **nearest_stations_imgw** - List of nearby meteorological or hydrological IMGW-PIB stations in Poland
- 🇵🇱 **imgw_meteo_stations** - Built-in metadata from the IMGW-PIB repository for meteorological stations, their geographical coordinates, and ID numbers
- 🇵🇱 **imgw_hydro_stations** - Built-in metadata from the IMGW-PIB repository for hydrological stations, their geographical coordinates, and ID numbers
- 🇵🇱 **stations_meteo_imgw_telemetry** - Downloading complete and up-to-date information about coordinates for IMGW-PIB telemetry meteorological stations
- 🇵🇱 **stations_hydro_imgw_telemetry** - Downloading complete and up-to-date information about coordinates for IMGW-PIB telemetry hydrological stations

- 🌍 **parser()** - Decoding raw SYNOP meteorological messages into structured R lists or data frames. For a full walkthrough see the [SYNOP Messages vignette](https://bczernecki.github.io/climate/articles/synop_parser.html).
- 🌍 [**synop_parser**](https://bczernecki.github.io/climate/reference/synop_parse.html) - Decoding raw SYNOP meteorological messages into structured R lists or data frames. For a full walkthrough see the [SYNOP Messages vignette](https://bczernecki.github.io/climate/articles/synop_parser.html).

## Example 1
#### Download hourly dataset from NCEI/NOAA ISH meteorological repository:
Expand All @@ -101,7 +109,7 @@ head(noaa)
``` r
# find 100 nearest UK stations to longitude 1W and latitude 53N :

nearest_stations_ogimet(country = "United+Kingdom",
nearest_stations_ogimet(country = "United Kingdom",
date = Sys.Date(),
add_map = TRUE,
point = c(-1, 53),
Expand Down
Loading
Loading