From 40c357c6eb6c21629d34340029059e315cabb9cd Mon Sep 17 00:00:00 2001 From: bczernecki Date: Tue, 15 Sep 2026 14:30:15 +0200 Subject: [PATCH] fix: broken col_names and attributes for IMGW data --- .Rbuildignore | 1 + .github/copilot-instructions.md | 2 +- .gitignore | 1 + CLAUDE.md | 2 +- DESCRIPTION | 2 +- NEWS.md | 8 +++ R/hydro_imgw.R | 15 +++-- R/hydro_imgw_daily.R | 2 + R/hydro_imgw_monthly.R | 2 + R/hydro_shortening_imgw.R | 60 ++++++++++---------- R/meteo_imgw.R | 13 ++--- R/meteo_imgw_daily.R | 12 +--- R/meteo_imgw_hourly.R | 15 ++--- R/meteo_imgw_monthly.R | 15 +---- R/meteo_shortening_imgw.R | 52 +++++++++-------- R/utils.R | 7 ++- README.md | 9 ++- data-raw/hydro_parametry_skroty.csv | 1 + data-raw/parametry_skrot.csv | 32 +++++++++++ data/imgw_hydro_abbrev.rda | Bin 1010 -> 1123 bytes data/imgw_meteo_abbrev.rda | Bin 5237 -> 5230 bytes man/hydro_imgw.Rd | 1 + man/hydro_shortening_imgw.Rd | 17 ++---- man/meteo_imgw.Rd | 5 +- man/meteo_imgw_daily.Rd | 6 -- man/meteo_imgw_hourly.Rd | 5 -- man/meteo_imgw_monthly.Rd | 11 ---- man/meteo_shortening_imgw.Rd | 12 ++-- tests/testthat/test-hydro_imgw.R | 5 +- tests/testthat/test-hydro_shortening_imgw.R | 36 ++++++++++-- tests/testthat/test-imgw_meteo_abbrev.R | 2 +- tests/testthat/test-meteo_imgw.R | 4 +- tests/testthat/test-meteo_imgw_daily.R | 40 +++++++++++++ vignettes/articles/pl.Rmd | 20 +++---- vignettes/getstarted.Rmd | 6 ++ 35 files changed, 250 insertions(+), 171 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 7c282feb..eb2bd1ed 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -21,3 +21,4 @@ vignettes/articles/usecase.Rmd ^\.positai$ ^\.claude$ CLAUDE.md$ +^\.posit/assistant$ diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index b21f957b..a3ff330a 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -28,7 +28,7 @@ Run commands from the package root. - **OGIMET**: HTML is scraped with `XML::readHTMLTable`; station identity is based on WMO IDs. Hourly precipitation post-processing is handled by `precip_split()`. - **NOAA / Wyoming**: direct file or page downloads for ISH hourly data, Mauna Loa CO2, and Wyoming soundings. -- IMGW column renaming is a distinct normalization layer. Most IMGW functions accept `col_names = "short" | "full" | "polish"` and pass results through `meteo_shortening_imgw()` or `hydro_shortening_imgw()`. The mapping tables live in built-in datasets backed by `data-raw/`. +- IMGW column renaming is a distinct normalization layer. IMGW functions return short English names and attach the original full parameter label as a per-column `label` attribute through `meteo_shortening_imgw()` or `hydro_shortening_imgw()`. The mapping tables live in built-in datasets backed by `data-raw/`. - Package data and docs follow standard R package patterns: - exported code in `R/` diff --git a/.gitignore b/.gitignore index 17050e89..287ea2d0 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ pkgdown test-out.txt .positai .aider* +.posit/assistant diff --git a/CLAUDE.md b/CLAUDE.md index 7379afe7..66180ce8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -29,7 +29,7 @@ Run from the package root in R: - **OGIMET**: HTML scraping via `XML::readHTMLTable` from `ogimet.com`. Stations are identified by WMO ID. `precip_split` / `R/precip_split.R` handles 6/12/24h precipitation disaggregation for hourly data. - **NOAA / Wyoming**: direct file downloads (ISH gzipped fixed-width, CO2 text, sounding HTML). -**Column-name shortening layer.** Most IMGW download functions accept `col_names = "short" | "full" | "polish"` and pass the raw frame through `meteo_shortening_imgw()` / `hydro_shortening_imgw()` (in `R/*_shortening_imgw.R`). Full and short names are looked up against `imgw_meteo_abbrev` / `imgw_hydro_abbrev` (built-in data). When you add a new IMGW column, update both the abbrev table (`data-raw/`) and the shortener. +**Column-name shortening layer.** IMGW download functions return short English names and attach the original full IMGW parameter label as a per-column `label` attribute. Names are looked up against `imgw_meteo_abbrev` / `imgw_hydro_abbrev` (built-in data). When you add a new IMGW column, update both the abbrev table (`data-raw/`) and the shortener. **Graceful network failure** is required for CRAN. Use `test_url()` (`R/test_url.R`) to gate downloads, and follow the existing `allow_failure = TRUE` pattern: wrap the real worker (`*_bp` "best practice" inner function) in `tryCatch` so user-facing functions return `NULL`/`invisible()` with a `message()` instead of erroring. Tests follow the same convention — every network test starts with `if (!curl::has_internet()) return(invisible(NULL))`. Don't add tests that fail when offline. diff --git a/DESCRIPTION b/DESCRIPTION index 023fb520..4a5974d0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: climate Title: Interface to Download Meteorological (and Hydrological) Datasets -Version: 1.4.0 +Version: 1.4.1 Authors@R: c(person(given = "Bartosz", family = "Czernecki", role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 3fd7bc66..e78a2215 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# climate 1.4.1 + +* fixed IMGW meteorological and hydrological parameter mappings for current metadata labels +* removed the `col_names` choice between short, full, and Polish column names to simplify usage +* original full IMGW parameter names are available through each column's `label` attribute +* updated documentation, README, and vignettes to describe the simplified naming scheme + + # climate 1.4.0 * adding the `synop_parser()` function for reading raw SYNOP messages diff --git a/R/hydro_imgw.R b/R/hydro_imgw.R index 551b29ce..3225f903 100644 --- a/R/hydro_imgw.R +++ b/R/hydro_imgw.R @@ -16,6 +16,7 @@ #' @return A data.frame with columns describing the hydrological parameters #' (e.g. flow, water level) where each row represent a measurement, #' depending on the interval, at a given hour, month or year. +#' IMGW parameter columns carry a `label` attribute with the original metadata label. #' If `coords = TRUE` additional two columns with geographic coordinates are added. #' @examples #' \donttest{ @@ -30,12 +31,18 @@ hydro_imgw = function(interval, if (interval == "daily") { # dobowe - calosc = hydro_imgw_daily(year = year, station = station, ...) + calosc = hydro_imgw_daily( + year = year, + station = station, + ... + ) } else if (interval == "monthly") { # miesieczne - calosc = hydro_imgw_monthly(year = year, - station = station, - ...) + calosc = hydro_imgw_monthly( + year = year, + station = station, + ... + ) } else{ stop("Wrong `interval` value. It should be either 'daily' or 'monthly'", call. = FALSE) } diff --git a/R/hydro_imgw_daily.R b/R/hydro_imgw_daily.R index 0a8a1bf2..c68c301e 100644 --- a/R/hydro_imgw_daily.R +++ b/R/hydro_imgw_daily.R @@ -174,6 +174,8 @@ hydro_imgw_daily_bp = function(year, attr(all_data[[cols]], "label") = meta$label[ind] } } + all_data = imgw_rename_params_to_labels(all_data, meta) + all_data = hydro_shortening_imgw(all_data, ...) return(all_data) } \ No newline at end of file diff --git a/R/hydro_imgw_monthly.R b/R/hydro_imgw_monthly.R index c3009e2a..39da0803 100644 --- a/R/hydro_imgw_monthly.R +++ b/R/hydro_imgw_monthly.R @@ -127,6 +127,8 @@ hydro_imgw_monthly_bp = function(year, attr(all_data[[cols]], "label") = meta$label[ind] } } + all_data = imgw_rename_params_to_labels(all_data, meta) + all_data = hydro_shortening_imgw(all_data, ...) return(all_data) } diff --git a/R/hydro_shortening_imgw.R b/R/hydro_shortening_imgw.R index 7f58ebbc..80ab175e 100644 --- a/R/hydro_shortening_imgw.R +++ b/R/hydro_shortening_imgw.R @@ -3,58 +3,58 @@ #' Shortening column names of hydrological parameters to improve the readability of downloaded dataset from #' the danepubliczne.imgw.pl collection and removing duplicated column names #' @param data downloaded dataset with original column names -#' @param col_names three types of column names possible: "short" - default, -#' values with shorten names, -#' "full" - full English description, -#' "polish" - original names in the dataset #' @param remove_duplicates whether to remove duplicated column names #' (default TRUE - i.e., columns with duplicated names are deleted) #' @export -#' @returns data.frame with shorten names of hydrological parameters +#' @returns data.frame with short English names of hydrological parameters. +#' Existing column attributes, including the original IMGW `label` metadata, +#' are preserved. #' @examples #' \donttest{ -#' monthly = data = hydro_imgw("monthly", year = 1969, col_names = "polish") +#' monthly = data = hydro_imgw("monthly", year = 1969) #' #' if (is.data.frame(monthly)) { -#' abbr = hydro_shortening_imgw(data = monthly, -#' col_names = "full", -#' remove_duplicates = TRUE) +#' abbr = hydro_shortening_imgw(data = monthly, remove_duplicates = TRUE) #' head(abbr) #' } #' } #' hydro_shortening_imgw = function(data, - col_names = "short", remove_duplicates = TRUE) { - if (col_names != "polish") { - abbrev = climate::imgw_hydro_abbrev - # additional workarounds for mac os but not only... - abbrev$fullname = gsub(x = abbrev$fullname, pattern = "'", replacement = "") - abbrev$fullname = gsub(x = abbrev$fullname, pattern = "\\^", replacement = "") - # end of workaround - orig_columns = trimws(gsub("\\s+", " ", colnames(data))) # remove double spaces + data = as.data.frame(data) + column_attributes = lapply(data, attributes) - matches = match(orig_columns, abbrev$fullname) - matches = matches[!is.na(matches)] + abbrev = climate::imgw_hydro_abbrev + # additional workarounds for mac os but not only... + abbrev$fullname = gsub(x = abbrev$fullname, pattern = "'", replacement = "") + abbrev$fullname = gsub(x = abbrev$fullname, pattern = "\\^", replacement = "") + abbrev$fullname = stringi::stri_trans_general(abbrev$fullname, "LATIN-ASCII") + # end of workaround + orig_columns = trimws(gsub("\\s+", " ", colnames(data))) # remove double spaces + orig_columns = gsub(x = orig_columns, pattern = "'", replacement = "") + orig_columns = gsub(x = orig_columns, pattern = "\\^", replacement = "") + orig_columns = stringi::stri_trans_general(orig_columns, "LATIN-ASCII") + # `Data` is created by the package and is not an IMGW parameter. + orig_columns[orig_columns == "Data"] = NA_character_ - if (col_names == "short") { - # abbrev english - colnames(data)[orig_columns %in% abbrev$fullname] = abbrev$abbr_eng[matches] - } - - if (col_names == "full") { - # full english names: - colnames(data)[orig_columns %in% abbrev$fullname] = abbrev$fullname_eng[matches] - } - } + matches = match(orig_columns, abbrev$fullname) + matches = matches[!is.na(matches)] + colnames(data)[orig_columns %in% abbrev$fullname] = abbrev$abbr_eng[matches] # removing duplicated column names: (e.g. station's name) if (remove_duplicates == TRUE) { - data = data[, !duplicated(colnames(data))] + keep = !duplicated(colnames(data)) + data = data[, keep, drop = FALSE] + column_attributes = column_attributes[keep] } data = unique(data) + for (ind in seq_along(column_attributes)) { + if (!is.null(column_attributes[[ind]])) { + attributes(data[[ind]]) = column_attributes[[ind]] + } + } rownames(data) = NULL return(data) } diff --git a/R/meteo_imgw.R b/R/meteo_imgw.R index f53fe598..9b801e4d 100644 --- a/R/meteo_imgw.R +++ b/R/meteo_imgw.R @@ -15,8 +15,6 @@ #' (default `FALSE` — status columns are deleted). Not used when `rank = "telemetry"`. #' @param coords add coordinates of the station (logical value `TRUE` or `FALSE`). #' Default `FALSE`. -#' @param col_names column name style: `"short"` (default), `"full"` (English descriptions), -#' or `"polish"` (original dataset names). Not used when `rank = "telemetry"`. #' @param station name of meteorological station(s). #' For ranks `"synop"`, `"climate"`, `"precip"`: station name(s) in CAPITAL LETTERS. #' Please note that station names may change over time — sometimes two names are required, @@ -33,6 +31,7 @@ #' @return A data.frame with meteorological parameters where each row is a measurement. #' For ranks `"synop"`, `"climate"`, `"precip"`: measurements at a given hour, day, or month, #' depending on `interval`. If `coords = TRUE` two additional coordinate columns are appended. +#' IMGW parameter columns also carry a `label` attribute with the original Polish metadata label. #' For `rank = "telemetry"`: a data.table with 10-minute interval observations (not #' expert-validated). If `coords = TRUE` columns `name`, `lon`, `lat`, and `alt` are appended. #' @examples @@ -52,7 +51,6 @@ meteo_imgw = function(interval = NULL, status = FALSE, coords = FALSE, station = NULL, - col_names = "short", parameters = NULL, ...) { if (rank == "telemetry") { @@ -70,22 +68,19 @@ meteo_imgw = function(interval = NULL, year = year, status = status, coords = coords, - station = station, - col_names = col_names, ...) + station = station, ...) } else if (interval == "monthly") { result = meteo_imgw_monthly(rank = rank, year = year, status = status, coords = coords, - station = station, - col_names = col_names, ...) + station = station, ...) } else if (interval == "hourly") { result = meteo_imgw_hourly(rank = rank, year = year, status = status, coords = coords, - station = station, - col_names = col_names, ...) + station = station, ...) } else { stop("Wrong `interval` value. It should be either 'hourly', 'daily', or 'monthly'.") } diff --git a/R/meteo_imgw_daily.R b/R/meteo_imgw_daily.R index 0a41cc79..e22b089d 100644 --- a/R/meteo_imgw_daily.R +++ b/R/meteo_imgw_daily.R @@ -14,10 +14,6 @@ #' database and thus providing both names is needed #' (e.g. `station = c("POZNAŃ", "POZNAŃ-ŁAWICA", "WARSZAWA", "WARSZAWA-OKĘCIE")`). #' Stations' IDs (numeric) are no longer valid -#' @param col_names three types of column names possible: -#' "short" - default, values with shorten names, -#' "full" - full English description, -#' "polish" - original names in the dataset #' @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 #' @param ... other parameters that may be passed to the 'shortening' function that #' shortens column names @@ -35,7 +31,6 @@ meteo_imgw_daily = function(rank = "synop", status = FALSE, coords = FALSE, station = NULL, - col_names = "short", allow_failure = TRUE, ...) { if (allow_failure) { @@ -45,8 +40,7 @@ meteo_imgw_daily = function(rank = "synop", year, status, coords, - station, - col_names + station ), error = function(e) { message(paste( @@ -63,7 +57,6 @@ meteo_imgw_daily = function(rank = "synop", status, coords, station, - col_names, ... ) } @@ -74,7 +67,6 @@ meteo_imgw_daily_bp = function(rank, status, coords, station, - col_names, ...) { translit = check_locale() base_url = "https://danepubliczne.imgw.pl/data/dane_pomiarowo_obserwacyjne/" @@ -399,7 +391,7 @@ meteo_imgw_daily_bp = function(rank, } all_data = imgw_rename_params_to_labels(all_data, meta) - all_data = meteo_shortening_imgw(all_data, col_names = col_names, remove_duplicates = TRUE) + all_data = meteo_shortening_imgw(all_data, remove_duplicates = TRUE) # check if there any messages gathered in env$logs and if it is not empty then print them: if (length(env$logs) > 0) { diff --git a/R/meteo_imgw_hourly.R b/R/meteo_imgw_hourly.R index 467add7e..b34e7456 100644 --- a/R/meteo_imgw_hourly.R +++ b/R/meteo_imgw_hourly.R @@ -9,9 +9,6 @@ #' (default status = FALSE - i.e. the status columns are deleted) #' @param coords add coordinates of the station (logical value TRUE or FALSE) #' @param station name of meteorological station(s) (character vector) -#' @param col_names three types of column names possible: "short" - default, -#' values with shorten names, "full" - full English description, -#' "polish" - original names in the dataset #' @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 #' @param ... other parameters that may be passed to the 'shortening' #' function that shortens column names @@ -31,7 +28,6 @@ meteo_imgw_hourly = function(rank = "synop", status = FALSE, coords = FALSE, station = NULL, - col_names = "short", allow_failure = TRUE, ...) { if (allow_failure) { @@ -41,8 +37,7 @@ meteo_imgw_hourly = function(rank = "synop", year, status, coords, - station, - col_names, ... + station, ... ), error = function(e) { message(paste( @@ -58,8 +53,7 @@ meteo_imgw_hourly = function(rank = "synop", year, status, coords, - station, - col_names, ... + station, ... ) } } @@ -70,8 +64,7 @@ meteo_imgw_hourly_bp = function(rank, year, status, coords, - station, - col_names, ...) { + station, ...) { translit = check_locale() stopifnot(rank == "synop" | rank == "climate") # for hourly data only synop and climate has data base_url = "https://danepubliczne.imgw.pl/data/dane_pomiarowo_obserwacyjne/" @@ -279,7 +272,7 @@ meteo_imgw_hourly_bp = function(rank, } all_data = imgw_rename_params_to_labels(all_data, meta) - all_data = meteo_shortening_imgw(all_data, col_names = col_names, ...) + all_data = meteo_shortening_imgw(all_data, ...) # check if there any messages gathered in env$logs and if it is not empty then print them: if (length(env$logs) > 0) { diff --git a/R/meteo_imgw_monthly.R b/R/meteo_imgw_monthly.R index f8c3d9db..e40e9394 100644 --- a/R/meteo_imgw_monthly.R +++ b/R/meteo_imgw_monthly.R @@ -12,9 +12,6 @@ #' It accepts names (characters in CAPITAL LETTERS). Stations' IDs (numeric) are no longer supported. #' Please note that station names may change over time and thus sometimes 2 names #' are required in some cases, e.g. `c("POZNAŃ", "POZNAŃ-ŁAWICA")`. -#' @param col_names three types of column names possible: "short" - default, -#' values with shorten names, "full" - full English description, -#' "polish" - original names in the dataset #' @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 #' @param ... other parameters that may be passed to the @@ -29,12 +26,6 @@ #' monthly = meteo_imgw_monthly(rank = "climate", year = 1969) #' head(monthly) #' -#' # a descriptive (long) column names: -#' monthly2 = meteo_imgw_monthly( -#' rank = "synop", year = 2018, -#' col_names = "full" -#' ) -#' head(monthly2) #' } #' meteo_imgw_monthly = function(rank = "synop", @@ -42,7 +33,6 @@ meteo_imgw_monthly = function(rank = "synop", status = FALSE, coords = FALSE, station = NULL, - col_names = "short", allow_failure = TRUE, ...) { if (allow_failure) { @@ -53,7 +43,6 @@ meteo_imgw_monthly = function(rank = "synop", status, coords, station, - col_names, ... ), error = function(e) { @@ -71,7 +60,6 @@ meteo_imgw_monthly = function(rank = "synop", status, coords, station, - col_names, ... ) } @@ -84,7 +72,6 @@ meteo_imgw_monthly_bp = function(rank, status, coords, station, - col_names, ...) { translit = check_locale() base_url = "https://danepubliczne.imgw.pl/data/dane_pomiarowo_obserwacyjne/" @@ -245,6 +232,6 @@ meteo_imgw_monthly_bp = function(rank, } all_data = imgw_rename_params_to_labels(all_data, meta) - all_data = meteo_shortening_imgw(all_data, col_names = col_names, ...) + all_data = meteo_shortening_imgw(all_data, ...) return(all_data) } diff --git a/R/meteo_shortening_imgw.R b/R/meteo_shortening_imgw.R index 4c87d894..8f44fa39 100644 --- a/R/meteo_shortening_imgw.R +++ b/R/meteo_shortening_imgw.R @@ -3,30 +3,36 @@ #' Shortening column names of meteorological parameters to improve the readability of downloaded dataset from the danepubliczne.imgw.pl collection and removing duplicated column names #' #' @param data downloaded dataset with original column names -#' @param col_names three types of column names possible: "short" - default, values with shorten names, "full" - full English description, "polish" - original names in the dataset #' @param remove_duplicates whether to remove duplicated column names (default TRUE - i.e., columns with duplicated names are deleted) #' @export -#' @returns data.frame with modified names of meteorological parameters +#' @returns data.frame with short English names of meteorological parameters. +#' Existing column attributes, including the original IMGW `label` metadata, +#' are preserved. #' #' @examples #' \donttest{ #' monthly = meteo_imgw("monthly", rank = "climate", year = 1969) #' -#' abbr = meteo_shortening_imgw(data = monthly, -#' col_names = "full", -#' remove_duplicates = TRUE) +#' abbr = meteo_shortening_imgw(data = monthly, remove_duplicates = TRUE) #' head(abbr) #' } #' -meteo_shortening_imgw = function(data, col_names = "short", remove_duplicates = TRUE) { +meteo_shortening_imgw = function(data, remove_duplicates = TRUE) { data = as.data.frame(data) + column_attributes = lapply(data, attributes) + # removing duplicated column names: (e.g. station's name) if (remove_duplicates == TRUE) { - data = data[, !duplicated(colnames(data))] + keep = !duplicated(colnames(data)) + data = data[, keep, drop = FALSE] + column_attributes = column_attributes[keep] # fix for merged station names with suffixes if (any(colnames(data) %in% c("Nazwa stacji.x", "Nazwa stacji.y"))) { + keep = colnames(data) != "Nazwa stacji.y" + data = data[, keep, drop = FALSE] + column_attributes = column_attributes[keep] data$`Nazwa stacji.y` = NULL colnames(data)[colnames(data) == "Nazwa stacji.x"] = "Nazwa stacji" } @@ -34,30 +40,26 @@ meteo_shortening_imgw = function(data, col_names = "short", remove_duplicates = # fix for mean air temperature which is stated sometimes in two files as: # "Srednia dobowa temperatura[°C]" and "Srednia temperatura dobowa [°C]" if (any(grepl(x = colnames(data), "Srednia dobowa temperatura"))) { - data[, which(grepl(x = colnames(data), "Srednia dobowa temperatura"))] = NULL + keep = !grepl(x = colnames(data), "Srednia dobowa temperatura") + data = data[, keep, drop = FALSE] + column_attributes = column_attributes[keep] } } - if (col_names != "polish") { - abbrev = climate::imgw_meteo_abbrev - orig_columns = trimws(gsub("\\s+", " ", colnames(data))) # remove double spaces - orig_columns = trimws(gsub("\\[.*?]", "", orig_columns)) # remove brackets and content inside - - abbrev$fullname = trimws(gsub("\\[.*?]", "", abbrev$fullname)) - matches = match(orig_columns, abbrev$fullname) - matches = matches[!is.na(matches)] - - if (col_names == "short") { - # abbrev english - colnames(data)[orig_columns %in% abbrev$fullname] = abbrev$abbr_eng[matches] - } + abbrev = climate::imgw_meteo_abbrev + orig_columns = trimws(gsub("\\s+", " ", colnames(data))) # remove double spaces + orig_columns = trimws(gsub("\\[.*?]", "", orig_columns)) # remove brackets and content inside - if (col_names == "full") { - # full english names: - colnames(data)[orig_columns %in% abbrev$fullname] = abbrev$fullname_eng[matches] + abbrev$fullname = trimws(gsub("\\[.*?]", "", abbrev$fullname)) + matches = match(orig_columns, abbrev$fullname) + matches = matches[!is.na(matches)] + colnames(data)[orig_columns %in% abbrev$fullname] = abbrev$abbr_eng[matches] + data = unique(data) + for (ind in seq_along(column_attributes)) { + if (!is.null(column_attributes[[ind]])) { + attributes(data[[ind]]) = column_attributes[[ind]] } } - data = unique(data) rownames(data) = NULL return(data) } diff --git a/R/utils.R b/R/utils.R index 997b5396..6c19161c 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,4 +1,4 @@ -#' Rename parameter code columns to full Polish label names +#' Rename parameter code columns to full Polish label names and attach metadata labels #' #' Translates short internal parameter codes (e.g. NSP, POST, TMAX) to the #' original full Polish labels stored in the metadata, so that the result can @@ -18,7 +18,10 @@ imgw_rename_params_to_labels = function(data, meta) { param_map = setNames(meta$label, meta$parameters) cols = colnames(data) in_map = cols %in% names(param_map) - colnames(data)[in_map] = param_map[cols[in_map]] + for (ind in which(in_map)) { + attr(data[[ind]], "label") = unname(param_map[cols[ind]]) + } + colnames(data)[in_map] = unname(param_map[cols[in_map]]) data } diff --git a/README.md b/README.md index c370eb49..2311c4ba 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ Downloading measurements of the vertical profile of atmosphere (aka rawinsonde d 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. +IMGW archive outputs use short English parameter names; the original IMGW names are +available as `label` attributes on the corresponding columns. ### (Polish) Hydrological data @@ -69,6 +71,8 @@ It is a wrapper for `meteo_monthly()`, `meteo_daily()`, `meteo_hourly()` and `me 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()` +IMGW archive outputs use short English parameter names; the original IMGW names are +available as `label` attributes on the corresponding columns. - 🇵🇱 [**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. @@ -193,7 +197,7 @@ h = hydro_imgw(interval = "daily", year = 2010:2011) head(h) ``` -| id | station | riv_or_lake | date | hyy | idhyy | dd | H | Q | T | mm | thick | +| id | station | riv_or_lake | Data | hyy | idhyy | dd | H | Q | T | mm | thick | |-----------|---------|-------------|------------|------|-------|----|-----|-----|----|----|-------| | 150210180 | ANNOPOL | Wisła (2) | 2009-11-01 | 2010 | 1 | 1 | 287 | 436 | NA | 11 | NA | | 150210180 | ANNOPOL | Wisła (2) | 2009-11-02 | 2010 | 1 | 2 | 282 | 412 | NA | 11 | NA | @@ -202,6 +206,9 @@ head(h) | 150210180 | ANNOPOL | Wisła (2) | 2009-11-05 | 2010 | 1 | 5 | 264 | 336 | NA | 11 | NA | | 150210180 | ANNOPOL | Wisła (2) | 2009-11-06 | 2010 | 1 | 6 | 260 | 320 | NA | 11 | NA | +The original IMGW description of `H` can be inspected with +`attr(h$H, "label")`. + ## Example 5 #### Create Walter & Lieth climatic diagram based on downloaded data diff --git a/data-raw/hydro_parametry_skroty.csv b/data-raw/hydro_parametry_skroty.csv index 25582403..da5bcc39 100644 --- a/data-raw/hydro_parametry_skroty.csv +++ b/data-raw/hydro_parametry_skroty.csv @@ -27,3 +27,4 @@ Grubość lodu [cm];thick;Thickness of ice [cm];; Kod zjawiska lodowego (słownik poniżej);id_ice;Ice phenomena;; "Procent udziału zjawiska lodowego [mnożnik *10; np. 3 oznacza 30% udziału zjawisk lodowych]";p_ice;Percentage of ice phenomena;; Kod zarastania (słownik poniżej);id_over_grow;Overgrowing;; +Kod zarastania (szczegółowe informacje poniżej);id_over_grow;Overgrowing;; diff --git a/data-raw/parametry_skrot.csv b/data-raw/parametry_skrot.csv index 425c383b..9af97863 100644 --- a/data-raw/parametry_skrot.csv +++ b/data-raw/parametry_skrot.csv @@ -253,3 +253,35 @@ Nazwa stacji.x,station,Station Nazwa stacji.y,station,Station rank_code,rank,Station rank code Zapas wody w sniegu [mm],water_in_snow,Water content in snow [mm] +Absolutna maksymalna temperatura powietrza [C],tmax_abs,Absolute maximum air temperature [C] +Absolutna minimalna temperatura powietrza [C],tmin_abs,Absolute minimum air temperature [C] +Charakterystyka tendencji cisnienia [kod],press_tend,Pressure tendency +Cisnienie atmosferyczne na poziomie morza [hPa],slp,Sea level pressure [hPa] +Cisnienie atmosferyczne na poziomie stacji [hPa],press,Station level pressure [hPa] +Liczba dni ze zmetnieniem opalizujacym,hazyness_days,Days with hazyness +Maksymalna dobowa suma opadow w miesiacu [mm],rr_max_daily,Maximum daily precipitation [mm] +Maksymalna dobowa temperatura powietrza [C],tmax_daily,Maximum daily air temperature [C] +Minimalna dobowa temperatura powietrza [C],tmin_daily,Minimum daily air temperature [C] +Minimalna dobowa temperatura powietrza przy gruncie [C],t5cm_min,Minimum daily near surface air temperature [C] +Minimalna temperatura powietrza przy gruncie za 12 godzin [C],tmin_soil_12h,Minimum near surface air temperature for 12 hours [C] +Minimalna temperatura powietrza za 12 godzin [C],tmin_12h,Minimum air temperature for 12 hours [C] +Minimalna temperatura powietrza przy gruncie [C],tmin_soil,Minimum near surface air temperature [C] +Temperatura minimalna powietrza przy gruncie za 12 godzin [C],tmin_soil_12h,Minimum near surface air temperature for 12 hours [C] +Niedosyt wilgotnosci [hPa],vapor_press_deficit,Vapour pressure deficit [hPa] +Srednia dobowa temperatura powietrza [C],t2m_mean_daily,Daily mean air temperature [C] +Srednie dobowe cisnienie na poziomie morza [hPa],slp_mean_daily,Daily mean sea level pressure [hPa] +Srednie dobowe cisnienie na poziomie stacji [hPa],press_mean_daily,Daily mean pressure at station level [hPa] +Srednie dobowe cisnienie pary wodnej [hPa],vapor_press_mean_daily,Daily mean vapour pressure [hPa] +Srednia maksymalna temperatura powietrza [C],tmax_mean,Monthly mean maximum air temperature [C] +Srednia minimalna temperatura powietrza [C],tmin_mean,Monthly mean minimum air temperature [C] +Srednia miesieczna temperatura powietrza [C],t2m_mean_mon,Monthly mean air temperature [C] +Srednie miesieczne cisnienie na poziomie morza [hPa],slp_mean_mon,Monthly mean sea level pressure [hPa] +Temperatura gruntu na glebokosci 5 cm [C],t5_soil,Soil temperature 5 cm below surface [C] +Temperatura gruntu na glebokosci 10 cm [C],t10_soil,Soil temperature 10 cm below surface [C] +Temperatura gruntu na glebokosci 20 cm [C],t20_soil,Soil temperature 20 cm below surface [C] +Temperatura gruntu na glebokosci 50 cm [C],t50_soil,Soil temperature 50 cm below surface [C] +Temperatura gruntu na glebokosci 100 cm [C],t100_soil,Soil temperature 100 cm below surface [C] +Temperatura maksymalna powietrza za 12 godzin [C],tmax_12h,Maximum air temperature for 12 hours [C] +Temperatura minimalna powietrza za 12 godzin [C],tmin_12h,Minimum air temperature for 12 hours [C] +Wartosc tendencji cisnienia [wartosc],tendency,Pressure tendency [value] +Zachmurzenie ogolne [0-10 do dn. 31.12.1988/oktanty od dn. 01.01.1989],cl_tot,"Total cloudiness [0-10 to 1988, octants since 1999]" diff --git a/data/imgw_hydro_abbrev.rda b/data/imgw_hydro_abbrev.rda index 75a94a80c3bcbced76cce22a5a232326431ef8f1..1690126b84f1d064f3911b06e7ee597d6f316716 100644 GIT binary patch literal 1123 zcmV-p1f2UqT4*^jL0KkKS?kY*ivR*vf9?PO|I1SM{#p<3{_DU0-|$v|00;;a4ge4U z00Gbh9sq;@1EAEo003kOO(2Pr zKujm7#MH`WhM|xE2AQUlC#WmsB23H+zsnm}LJGKT zx$P`ZC~`h5HCUdFs&x45b4_piktGS)7`!81vCNBPFs5d1lK>>Z$uN*4B*;iWkc5(8 z7(khl24)ffbj%Fi6mX_tpnz<5Ek~O+V9sC4xUTl}cQ+-b6Yee(g@i8N7!J0J2{aP6 z8_3gyiINyF`COdfq0RwPy)hDsFH;- z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OLy|JAszzl>`w~{8{8Xls8cV_Q zH*{z#_-YRePDKm}W=QhWF{RT)?*nk@CSn`dX^R)qEN|b#D98TO6R^N?I!9n+_ zJ^t$36TQnQ?6xo~CeZh012`pGdf0$AIYFWMp60hp*}-{f8$VA~=;~dTG7(c{mRXc= zK2h{K(=6+){@n8trKs>I^pxb_pZ8&<0AU4H3^C)j1$XB_Ug+99wNS@9bKopyF&%tb z79-v%LB)7wS|Qp>M^CSyQ3SFFIIYD7F7Ki~8c-o|Q0$}k(><#6f+BrtDP@zT=Qxyl z%$ewyUMXsVa2lEMub9IRdr25-!0P&C!=*?zSI6R$vywwEB$0J!4;OJok&T|xE-#v2 g!>l%J4$J!L{eoX-XJ>!o&p-O}FOFgjYaj^#09lCYU;qFB diff --git a/data/imgw_meteo_abbrev.rda b/data/imgw_meteo_abbrev.rda index 891716ed54eda98103be99834ef9eb59da47a557..23e8ab6c476ca560eb709a528ebc4a9a9cea8d7d 100644 GIT binary patch literal 5230 zcmV-!6p`yfT4*^jL0KkKS)g=RR{#_a|H1$N|NsC0|KorE-}=A*|MEZp5C8xH;2A%C z-BPb&@%6VGi?MBXU7Xt<^m}8ILyEhJ5zkPfgHDEl(G@5{D5U@>7Qn3rw9-Zzo}*Jh zLroeHzLi$)FOM5eSV>(JAPSJw|GJnjVD7r=$ZzKr|Wv007VfKmtuk6F^hc^)h-% zr?mw24K&HL6DC7OMuva@00E!?$OuwBLSkT;CYT7sz!8an0GePX0E|WuyvL_kiIB0_G{q!19mAupFX1Li2fQ;kmFtl!Ye^6vL@ z7fdg;hHRI&W{}u=cZm=bYm*Jy$fOngo=$(;&C}3N>O{sUVI-`J2SlV{1fnr`TIuME z%hucCYU;;lcaGHD`bcgu5KVa3h|PNwy)%>b=Xh|ruU9IHwka>hsUwC5#hDTj98Hbr z(V$s=C$L)==oL~l3rN4Hj4THgxk1(Yz3+ltM2b~|?@@;I@yl4L?o355qjPv5H z(W5}J{7+j{!it%Q;UoT9#z$y->1Ecb(~e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-w#nc~$XT%ra3DG)Mkw?M+yz@Lv(ESe1fMwNLHjR)M<8+-h z%~uAm85LX!0(0zlx)B$kpX=z%ZcNL1W&>-NCNGLtryp=~p-<+ZYHI6y8t z?a(>%Ng#6(M??O`=9_{xaMGF^y)A5HYgIJV=AUU)wl#W(W4|n6&>Dk{)5D;&DOvia z?$*^@;|eV;S&F6Qy56#|wqj89g51c4Hm^>1I>c)YBJk-37*fd*1e5eoCK&_wwaAlb zHge^I=s${$sW3wP;&ox-BL^o4QJcKGEz)vxPx(g=zW2SpNnSy{ zLHDvY2%27Yq8SBzC7+H|f?k1JV3&A4wS@b(Vz{ZS`}z{!YAW@9cS##L;=*x+;i|)6 zBc_WO{b2TNS22cT&UzV>WB=1073QBIocZSwamYWufA6@U<{NL`J4rxpQl)PXvMOl68;^I1+Lr=<@<-KfC%we}br9bTBa|iT)~*0bkfaA7HZ(|3br;zpVRm z@pP(|gNIa3+0h~4uX1PzeECZF%Lcn5etye3kEM#~WWhzs1|sW63_>oVs3`F-#jWP!_M!u zN&Jw%^&)-Ew)_iyCnj4Af}ro&9!oDRkOW?y`og|a0l=Tx9V@xN{K~?D&PJcBifzg3 z1L#s~ahI12TvmWXZ0CbgFCfJYH!E*o+(QlbZ(%O%2M~vo(v_aGE!R!8E9o1ug^HBy zNxUWP9S|j4c-Js{^faR0{I!$gxjX-nyYnY{Q>Am|(oK1sV=t1BH-8-TBGr>7%{$wW z_mFEA2xY0e&)L)6SV vWW-s|P2IQWG3io<&&1K_Et|s~___AK@Si{a_=AA{MSlJd^|)_fxK{uG?2suQ diff --git a/man/hydro_imgw.Rd b/man/hydro_imgw.Rd index 66904cca..d38b884f 100644 --- a/man/hydro_imgw.Rd +++ b/man/hydro_imgw.Rd @@ -25,6 +25,7 @@ function that shortens column names} A data.frame with columns describing the hydrological parameters (e.g. flow, water level) where each row represent a measurement, depending on the interval, at a given hour, month or year. +IMGW parameter columns carry a \code{label} attribute with the original metadata label. If \code{coords = TRUE} additional two columns with geographic coordinates are added. } \description{ diff --git a/man/hydro_shortening_imgw.Rd b/man/hydro_shortening_imgw.Rd index a477bbcf..32de1490 100644 --- a/man/hydro_shortening_imgw.Rd +++ b/man/hydro_shortening_imgw.Rd @@ -4,21 +4,18 @@ \alias{hydro_shortening_imgw} \title{Shortening column names for hydrological variables} \usage{ -hydro_shortening_imgw(data, col_names = "short", remove_duplicates = TRUE) +hydro_shortening_imgw(data, remove_duplicates = TRUE) } \arguments{ \item{data}{downloaded dataset with original column names} -\item{col_names}{three types of column names possible: "short" - default, -values with shorten names, -"full" - full English description, -"polish" - original names in the dataset} - \item{remove_duplicates}{whether to remove duplicated column names (default TRUE - i.e., columns with duplicated names are deleted)} } \value{ -data.frame with shorten names of hydrological parameters +data.frame with short English names of hydrological parameters. +Existing column attributes, including the original IMGW \code{label} metadata, +are preserved. } \description{ Shortening column names of hydrological parameters to improve the readability of downloaded dataset from @@ -26,12 +23,10 @@ the danepubliczne.imgw.pl collection and removing duplicated column names } \examples{ \donttest{ - monthly = data = hydro_imgw("monthly", year = 1969, col_names = "polish") + monthly = data = hydro_imgw("monthly", year = 1969) if (is.data.frame(monthly)) { - abbr = hydro_shortening_imgw(data = monthly, - col_names = "full", - remove_duplicates = TRUE) + abbr = hydro_shortening_imgw(data = monthly, remove_duplicates = TRUE) head(abbr) } } diff --git a/man/meteo_imgw.Rd b/man/meteo_imgw.Rd index a300d83e..b5bbe120 100644 --- a/man/meteo_imgw.Rd +++ b/man/meteo_imgw.Rd @@ -11,7 +11,6 @@ meteo_imgw( status = FALSE, coords = FALSE, station = NULL, - col_names = "short", parameters = NULL, ... ) @@ -40,9 +39,6 @@ e.g. \code{c("POZNAŃ", "POZNAŃ-ŁAWICA")}. For \code{rank = "telemetry"}: station name(s) as listed by \code{stations_meteo_imgw_telemetry()}. \code{NULL} (default) downloads all available stations.} -\item{col_names}{column name style: \code{"short"} (default), \code{"full"} (English descriptions), -or \code{"polish"} (original dataset names). Not used when \code{rank = "telemetry"}.} - \item{parameters}{character vector of parameter codes to download. Only used when \code{rank = "telemetry"}. \code{NULL} (default) downloads all available parameters. Accepted values: \code{"wd"}, \code{"t2m"}, \code{"t0m"}, \code{"rr_24h"}, \code{"rr_1h"}, \code{"rr_10min"}, @@ -55,6 +51,7 @@ Accepted values: \code{"wd"}, \code{"t2m"}, \code{"t0m"}, \code{"rr_24h"}, \code A data.frame with meteorological parameters where each row is a measurement. For ranks \code{"synop"}, \code{"climate"}, \code{"precip"}: measurements at a given hour, day, or month, depending on \code{interval}. If \code{coords = TRUE} two additional coordinate columns are appended. +IMGW parameter columns also carry a \code{label} attribute with the original Polish metadata label. For \code{rank = "telemetry"}: a data.table with 10-minute interval observations (not expert-validated). If \code{coords = TRUE} columns \code{name}, \code{lon}, \code{lat}, and \code{alt} are appended. } diff --git a/man/meteo_imgw_daily.Rd b/man/meteo_imgw_daily.Rd index 8d51bfbb..1eaf7f17 100644 --- a/man/meteo_imgw_daily.Rd +++ b/man/meteo_imgw_daily.Rd @@ -10,7 +10,6 @@ meteo_imgw_daily( status = FALSE, coords = FALSE, station = NULL, - col_names = "short", allow_failure = TRUE, ... ) @@ -32,11 +31,6 @@ database and thus providing both names is needed (e.g. \code{station = c("POZNAŃ", "POZNAŃ-ŁAWICA", "WARSZAWA", "WARSZAWA-OKĘCIE")}). Stations' IDs (numeric) are no longer valid} -\item{col_names}{three types of column names possible: -"short" - default, values with shorten names, -"full" - full English description, -"polish" - original names in the dataset} - \item{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} \item{...}{other parameters that may be passed to the 'shortening' function that diff --git a/man/meteo_imgw_hourly.Rd b/man/meteo_imgw_hourly.Rd index 7f116074..630c0cb3 100644 --- a/man/meteo_imgw_hourly.Rd +++ b/man/meteo_imgw_hourly.Rd @@ -10,7 +10,6 @@ meteo_imgw_hourly( status = FALSE, coords = FALSE, station = NULL, - col_names = "short", allow_failure = TRUE, ... ) @@ -27,10 +26,6 @@ meteo_imgw_hourly( \item{station}{name of meteorological station(s) (character vector)} -\item{col_names}{three types of column names possible: "short" - default, -values with shorten names, "full" - full English description, -"polish" - original names in the dataset} - \item{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} \item{...}{other parameters that may be passed to the 'shortening' diff --git a/man/meteo_imgw_monthly.Rd b/man/meteo_imgw_monthly.Rd index 3d3f2224..31f03d4e 100644 --- a/man/meteo_imgw_monthly.Rd +++ b/man/meteo_imgw_monthly.Rd @@ -10,7 +10,6 @@ meteo_imgw_monthly( status = FALSE, coords = FALSE, station = NULL, - col_names = "short", allow_failure = TRUE, ... ) @@ -30,10 +29,6 @@ It accepts names (characters in CAPITAL LETTERS). Stations' IDs (numeric) are no Please note that station names may change over time and thus sometimes 2 names are required in some cases, e.g. \code{c("POZNAŃ", "POZNAŃ-ŁAWICA")}.} -\item{col_names}{three types of column names possible: "short" - default, -values with shorten names, "full" - full English description, -"polish" - original names in the dataset} - \item{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} @@ -52,12 +47,6 @@ SYNOP / CLIMATE / PRECIP stations available in the danepubliczne.imgw.pl collect monthly = meteo_imgw_monthly(rank = "climate", year = 1969) head(monthly) -# a descriptive (long) column names: -monthly2 = meteo_imgw_monthly( - rank = "synop", year = 2018, - col_names = "full" -) -head(monthly2) } } diff --git a/man/meteo_shortening_imgw.Rd b/man/meteo_shortening_imgw.Rd index df754523..deba7a17 100644 --- a/man/meteo_shortening_imgw.Rd +++ b/man/meteo_shortening_imgw.Rd @@ -4,17 +4,17 @@ \alias{meteo_shortening_imgw} \title{Shortening column names for meteorological variables} \usage{ -meteo_shortening_imgw(data, col_names = "short", remove_duplicates = TRUE) +meteo_shortening_imgw(data, remove_duplicates = TRUE) } \arguments{ \item{data}{downloaded dataset with original column names} -\item{col_names}{three types of column names possible: "short" - default, values with shorten names, "full" - full English description, "polish" - original names in the dataset} - \item{remove_duplicates}{whether to remove duplicated column names (default TRUE - i.e., columns with duplicated names are deleted)} } \value{ -data.frame with modified names of meteorological parameters +data.frame with short English names of meteorological parameters. +Existing column attributes, including the original IMGW \code{label} metadata, +are preserved. } \description{ Shortening column names of meteorological parameters to improve the readability of downloaded dataset from the danepubliczne.imgw.pl collection and removing duplicated column names @@ -23,9 +23,7 @@ Shortening column names of meteorological parameters to improve the readability \donttest{ monthly = meteo_imgw("monthly", rank = "climate", year = 1969) - abbr = meteo_shortening_imgw(data = monthly, - col_names = "full", - remove_duplicates = TRUE) + abbr = meteo_shortening_imgw(data = monthly, remove_duplicates = TRUE) head(abbr) } diff --git a/tests/testthat/test-hydro_imgw.R b/tests/testthat/test-hydro_imgw.R index 67c00e79..9a7c6f8e 100644 --- a/tests/testthat/test-hydro_imgw.R +++ b/tests/testthat/test-hydro_imgw.R @@ -6,9 +6,11 @@ test_that("hydro_imgw_not_available", { station = "not available", allow_failure = FALSE))) # monthly download for a single station: - w = hydro_imgw(interval = "monthly", year = 2010, station = "WIGRY", + w = hydro_imgw(interval = "monthly", year = 2010, station = "WIGRY", allow_failure = FALSE) expect_true(is.data.frame(w) && nrow(w) == 36) + expect_true(all(c("station", "riv_or_lake", "H") %in% names(w))) + expect_identical(attr(w$H, "label"), "Stan wody [cm]") h2022_2023 = hydro_imgw(interval = "monthly", year = 2022:2023, @@ -30,6 +32,7 @@ test_that("hydro_imgw_not_available", { testthat::expect_true(is.data.frame(h2022_2023d)) testthat::expect_true(nrow(h2022_2023d) > 50000) testthat::expect_true(class(h2022_2023d$Data) == "Date") + testthat::expect_true("H" %in% names(h2022_2023d)) } } diff --git a/tests/testthat/test-hydro_shortening_imgw.R b/tests/testthat/test-hydro_shortening_imgw.R index 1d734a98..e00c835b 100644 --- a/tests/testthat/test-hydro_shortening_imgw.R +++ b/tests/testthat/test-hydro_shortening_imgw.R @@ -10,10 +10,38 @@ test_that("hydro_shortening_imgw", { `Przepływ [m3/s]` = c(288, 413.266), `Temperatura wody [st. C]` = c(NA_real_, NA_real_), `Miesiąc kalendarzowy` = c(11L, 11L)), row.names = 7165:7166, class = "data.frame") - eng_full = hydro_shortening_imgw(data = df, col_names = "full") - eng_short = hydro_shortening_imgw(data = df, col_names = "short") + eng_short = hydro_shortening_imgw(data = df) - expect_true("River_or_Lake" %in% colnames(eng_full)) expect_true("riv_or_lake" %in% colnames(eng_short)) - + expect_true("Q" %in% colnames(eng_short)) + +}) + +test_that("hydro IMGW column labels are retained as attributes", { + data = structure( + list( + `Stan wody [cm]` = c(258L, 287L), + `Przepływ [m3/s]` = c(288, 413.266) + ), + row.names = c(1L, 2L), + class = "data.frame" + ) + attr(data[[1]], "label") = "Stan wody [cm]" + attr(data[[2]], "label") = "Przepływ [m3/s]" + + result = hydro_shortening_imgw(data) + + expect_equal( + unname(vapply(result, attr, character(1), which = "label")), + c("Stan wody [cm]", "Przepływ [m3/s]") + ) +}) + +test_that("generated hydro date column is not renamed", { + data = data.frame(Data = as.Date("2020-01-01") + 0:1, check.names = FALSE) + + result = hydro_shortening_imgw(data) + + expect_identical(names(result), "Data") + expect_s3_class(result$Data, "Date") }) \ No newline at end of file diff --git a/tests/testthat/test-imgw_meteo_abbrev.R b/tests/testthat/test-imgw_meteo_abbrev.R index 211a4840..43e2d922 100644 --- a/tests/testthat/test-imgw_meteo_abbrev.R +++ b/tests/testthat/test-imgw_meteo_abbrev.R @@ -1,5 +1,5 @@ context("meteo-abbrev") test_that("meteo-metadata works!", { - expect_equal(dim(imgw_meteo_abbrev), c(254, 3)) + expect_equal(dim(imgw_meteo_abbrev), c(286, 3)) }) diff --git a/tests/testthat/test-meteo_imgw.R b/tests/testthat/test-meteo_imgw.R index ffb0fb0d..7c3a8698 100644 --- a/tests/testthat/test-meteo_imgw.R +++ b/tests/testthat/test-meteo_imgw.R @@ -18,8 +18,8 @@ test_that("meteo_imgw works!", { x = meteo_imgw("monthly", "precip", year = y) x = meteo_imgw("monthly", "synop", year = y, status = TRUE) x = meteo_imgw("monthly", "synop", year = y, coords = TRUE) - x = meteo_imgw("monthly", "synop", year = y, col_names = "full") - x = meteo_imgw("monthly", "synop", year = y, coords = TRUE, col_names = "polish") + x = meteo_imgw("monthly", "synop", year = y) + x = meteo_imgw("monthly", "synop", year = y, coords = TRUE) expect_message(suppressWarnings(meteo_imgw_daily(rank = "synop", year = 2001, station = "blabla"))) leszno = meteo_imgw(interval = "monthly", rank = "synop", year = 2020:2021, station = "LESZNO") testthat::expect_equal(nrow(leszno), 24) diff --git a/tests/testthat/test-meteo_imgw_daily.R b/tests/testthat/test-meteo_imgw_daily.R index cf277f60..2ae5b317 100644 --- a/tests/testthat/test-meteo_imgw_daily.R +++ b/tests/testthat/test-meteo_imgw_daily.R @@ -80,3 +80,43 @@ test_that("check_encoding_in_non_synop", { expect_identical(nchar(non_synop$NSP), nchar(trimws(non_synop$NSP))) } }) + +test_that("current IMGW daily labels use short names", { + data = data.frame( + "Maksymalna dobowa temperatura powietrza [°C]" = 1, + "Minimalna dobowa temperatura powietrza [°C]" = 2, + "Minimalna dobowa temperatura powietrza przy gruncie [°C]" = 3, + check.names = FALSE + ) + + expect_named( + meteo_shortening_imgw(data), + c("tmax_daily", "tmin_daily", "t5cm_min") + ) +}) + +test_that("IMGW column labels are retained as attributes", { + data = data.frame( + TMAX = 1:2, + TMIN = 3:4, + TMNG = 5:6, + check.names = FALSE + ) + meta = data.frame( + parameters = c("TMAX", "TMIN", "TMNG"), + label = c( + "Maksymalna dobowa temperatura powietrza [°C]", + "Minimalna dobowa temperatura powietrza [°C]", + "Minimalna dobowa temperatura powietrza przy gruncie [°C]" + ), + stringsAsFactors = FALSE + ) + + data = imgw_rename_params_to_labels(data, meta) + data = meteo_shortening_imgw(data) + + expect_equal( + unname(vapply(data, attr, character(1), which = "label")), + meta$label + ) +}) diff --git a/vignettes/articles/pl.Rmd b/vignettes/articles/pl.Rmd index 121543e1..87067c35 100644 --- a/vignettes/articles/pl.Rmd +++ b/vignettes/articles/pl.Rmd @@ -86,31 +86,31 @@ h = hydro_imgw(interval = "monthly", year = 2001:2010) head(h) ``` -Zmienna `MCWSKEX` reprezentuje etykietę ekstremum, gdzie "1" oznacza +Zmienna `idex` reprezentuje etykietę ekstremum, gdzie "1" oznacza minimum, "2" oznacza średnią, a "3" maksimum. [^1] [^1]: Więcej informacji na ten temat można znaleźć w zestawie danych - `hydro_abbrev`. + `imgw_hydro_abbrev`. Analizy hydrologiczne często koncentrują się na jednej grupy zjawisk, np. związanych z przepływami maksymalnymi. W tym celu pozostaną w ramce danych tylko wartości przepływów maksymalnych oraz kolumny zawierające interesujące nas informacje, tj. identyfikator stacji - `id`, rok -hydrologiczny (`MCROKH`), szerokość geograficzną `X` i długość -geograficzną`Y`. +hydrologiczny (`hyy`), nazwę stacji (`station`), szerokość geograficzną +`X` i długość geograficzną `Y`. Następnie obliczymy średnią maksymalną wartość przepływu na stacjach w każdym roku za pomocą `dplyr::summarise()`, oraz rozdzielimy dane według roku używając `spread ()` aby uzyskać roczne średnie maksymalne -przepływy (`MCPRZP`) w kolejnych kolumnach. +przepływy (`Q`) w kolejnych kolumnach. ```{r filtering, eval=TRUE, echo=TRUE, message=FALSE, warning=FALSE, include=TRUE, paged.print=TRUE} h2 = h %>% - dplyr::filter(MCWSKEX == 3) %>% - dplyr::select(id, PSNZWP, X, Y, MCROKH, MCPRZP) %>% - dplyr::group_by(MCROKH, id, PSNZWP, X, Y) %>% - dplyr::summarise(srednie_roczne_Q = round(mean(MCPRZP, na.rm = TRUE), 1)) %>% - spread(MCROKH, srednie_roczne_Q) + dplyr::filter(idex == 3) %>% + dplyr::select(id, station, X, Y, hyy, Q) %>% + dplyr::group_by(hyy, id, station, X, Y) %>% + dplyr::summarise(srednie_roczne_Q = round(mean(Q, na.rm = TRUE), 1)) %>% + spread(hyy, srednie_roczne_Q) ``` ```{r filtering2, eval=TRUE, echo=TRUE, message=FALSE, warning=FALSE, include=TRUE, paged.print=TRUE} diff --git a/vignettes/getstarted.Rmd b/vignettes/getstarted.Rmd index e420fb69..ba5d7df0 100644 --- a/vignettes/getstarted.Rmd +++ b/vignettes/getstarted.Rmd @@ -42,6 +42,9 @@ default for `interval = "hourly"`) and **HTML scraping** (`source = "html"`, def SYNOP/CLIMATE/PRECIP stations 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 monthly to even 10-min datasets. +IMGW archive outputs use short English parameter names. The original IMGW names are +available as `label` attributes on the corresponding columns, for example +`attr(df$t2m_mean_mon, "label")`. - **meteo_noaa_hourly()** - Downloading hourly NCEI/NOAA Integrated Surface Hourly (ISH) meteorological data - some stations have > 100 years of observations. @@ -59,6 +62,9 @@ data frames. For a full walkthrough see the - **hydro_imgw()** - Downloading daily and monthly hydrological data from stations available in the danepubliczne.imgw.pl collection. It is a wrapper for `hydro_monthly()` and `hydro_daily()`. +IMGW archive outputs use short English parameter names. The original IMGW names are +available as `label` attributes on the corresponding columns, for example +`attr(h$Q, "label")`. - **hydro_imgw_datastore()** - Downloading hourly and sub-hourly hydrological data from the IMGW-PIB hydro telemetry stations.