Downloads climate normals from Environment and Climate Change Canada (ECCC) for one or more stations (defined by climate_ids). For details and units, see the glossary_normals data frame or the glossary_normals vignette: vignette("glossary_normals", package = "weathercan")

normals_dl(
  climate_ids,
  normals_years = "1981-2010",
  format = TRUE,
  stn = weathercan::stations,
  verbose = FALSE,
  quiet = FALSE
)

Arguments

climate_ids

Character. A vector containing the Climate ID(s) of the station(s) you wish to download data from. See the stations data frame or the stations_search function to find Climate IDs.

normals_years

Character. The year range for which you want climate normals. Default "1981-2010".

format

Logical. If TRUE (default) formats measurements to numeric and date accordingly. Unlike weather_dl(), normals_dl() will always format column headings as normals data from ECCC cannot be directly made into a data frame without doing so.

stn

Data frame. The stations data frame to use. Will use the one included in the package unless otherwise specified.

verbose

Logical. Include progress messages

quiet

Logical. Suppress all messages (including messages regarding missing data, etc.)

Value

tibble with nested normals and first/last frost data

Details

Climate normals from ECCC include two types of data, averages by month for a variety of measurements as well as data relating to the frost-free period. Because these two data sources are quite different, we return them as nested data so the user can extract them as they wish. See examples for how to use the unnest() function from the tidyr package to extract the two different datasets.

The data also returns a column called meets_wmo this reflects whether or not the climate normals for this station met the WMO standards for temperature and precipitation (i.e. both have code >= A). Each measurement column has a corresponding _code column which reflects the data quality of that measurement (see the ECCC calculations document for more details)

Climate normals are downloaded from the url stored in option weathercan.urls.normals. To change this location use: options(weathercan.urls.normals = "your_new_url").

Examples

# \donttest{ # Find the climate_id stations_search("Brandon A", normals_only = TRUE)
#> # A tibble: 1 x 11 #> prov station_name station_id climate_id WMO_id TC_id lat lon elev tz #> <chr> <chr> <dbl> <chr> <dbl> <chr> <dbl> <dbl> <dbl> <chr> #> 1 MB BRANDON A 3471 5010480 71140 YBR 49.9 -100. 409. Etc/… #> # … with 1 more variable: normals <lgl>
# Download climate normals n <- normals_dl(climate_ids = "5010480") # Pull out last frost data library(tidyr) f <- unnest(n, frost) # Pull out normals nm <- unnest(n, normals) # Download multiple stations n <- normals_dl(climate_ids = c("3010234", "3010410", "3010815"))
#> Not all stations have climate normals available (climate ids: 3010410, 3010815)
n
#> # A tibble: 1 x 6 #> prov station_name climate_id meets_wmo normals frost #> <chr> <chr> <chr> <lgl> <list> <list> #> 1 AB ANDREW 3010234 FALSE <tibble [13 × 123]> <tibble [7 × 8]>
# Note that some have files online but no data n$normals[2]
#> [[1]] #> NULL #>
# Some have no last frost data n$frost[3]
#> [[1]] #> NULL #>
# Note, putting both into the same data set can be done but makes for # a very unweildly dataset (there is lots of repetition) nm <- unnest(n, normals) f <- unnest(n, frost) both <- dplyr::full_join(nm, f)
#> Joining, by = c("prov", "station_name", "climate_id", "meets_wmo")
# }