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/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index cf2ffe0d..28793f8b 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -26,10 +26,11 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::covr, any::archive + extra-packages: any::covr, any::xml2, any::archive needs: coverage - name: Test coverage + timeout-minutes: 70 run: | cov <- covr::package_coverage( quiet = FALSE, 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 75a94a80..1690126b 100644 Binary files a/data/imgw_hydro_abbrev.rda and b/data/imgw_hydro_abbrev.rda differ diff --git a/data/imgw_meteo_abbrev.rda b/data/imgw_meteo_abbrev.rda index 891716ed..23e8ab6c 100644 Binary files a/data/imgw_meteo_abbrev.rda and b/data/imgw_meteo_abbrev.rda differ 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.