Data quality: compare SPEED scenarios with CHESS baseline data


In this script we compare environmental variables from:

  • CHESS 2015 project
  • SPEED scenarios (1990-2010 and 2000-2020)
  • SPEED based-corrected scenarios (1990-2010 and 2000-2020)

Load packages, read data and source custom scripts

rm(list = ls())
library(stars)
#> Loading required package: abind
#> Loading required package: sf
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(purrr)

path_proj <- day2day::git_path()
path_data <- file.path(path_proj, "data")
path_raw <- file.path(path_data, "raw")
path_cleaned <- file.path(path_data, "cleaned")
path_processed <- file.path(path_data, "processed")

source(file.path(path_proj, "src", "32-soil-moisture.R"))
source(file.path(path_proj, "src", "61-vis-stars.R"))

uk <- st_read(file.path(path_cleaned, "uk_simple.gpkg"), "union")
#> Reading layer `union' from data source `/home/rstudio/Documents/Projects/land-suitability/data/cleaned/uk_simple.gpkg' using driver `GPKG'
#> Simple feature collection with 1 feature and 0 fields
#> geometry type:  MULTIPOLYGON
#> dimension:      XY
#> bbox:           xmin: -116.1923 ymin: 7054.099 xmax: 655644.8 ymax: 1218625
#> projected CRS:  OSGB 1936 / British National Grid
chess_meta <- readr::read_csv(file.path(path_cleaned, "chess-metadata.csv")) %>%
    subset(from_year == 1991)
#> Parsed with column specification:
#> cols(
#>   file = col_character(),
#>   variable = col_character(),
#>   summary = col_character(),
#>   temp_resolution = col_character(),
#>   from = col_double(),
#>   to = col_double(),
#>   from_year = col_double(),
#>   from_month = col_character(),
#>   to_year = col_double(),
#>   to_month = col_double(),
#>   description = col_character()
#> )
speed_meta <- readr::read_csv(file.path(path_cleaned, "ukcp18-speed_rcp85_01_metadata.csv")) %>%
    subset(from_year %in% c(1990, 2000)  | grepl("aws", variable))
#> Parsed with column specification:
#> cols(
#>   file = col_character(),
#>   variable = col_character(),
#>   summary = col_character(),
#>   temp_resolution = col_character(),
#>   from = col_double(),
#>   to = col_double(),
#>   from_year = col_double(),
#>   from_month = col_double(),
#>   to_year = col_double(),
#>   to_month = col_double(),
#>   description = col_character()
#> )
speed_bias_meta <- readr::read_csv(file.path(path_cleaned, "ukcp18-speed_rcp85_bias_corrected_01_metadata.csv")) %>%
    subset(from_year %in% c(1990, 2000)  | grepl("aws", variable))
#> Parsed with column specification:
#> cols(
#>   file = col_character(),
#>   variable = col_character(),
#>   summary = col_character(),
#>   temp_resolution = col_character(),
#>   from = col_double(),
#>   to = col_double(),
#>   from_year = col_double(),
#>   from_month = col_double(),
#>   to_year = col_double(),
#>   to_month = col_double(),
#>   description = col_character()
#> )
metadata <- list(chess_meta, speed_meta, speed_bias_meta)

Growing degree days (gdd)

plot_compare("gdd", metadata, path_cleaned, boundary = uk, plot_fun = plot_gdd)

Maximum temperature (max_tas)

plot_compare("max_tas", metadata, path_cleaned, boundary = uk, plot_fun = plot_tas)

Maximum temperature (max_tasmax)

plot_compare("max_tasmax", metadata, path_cleaned, boundary = uk, plot_fun = plot_tas)

Maximum temperature (maxmonth_tas)

plot_compare("maxmonth_tas", metadata, path_cleaned, boundary = uk, plot_fun = plot_tas)

Minimum temperature (min_tas)

plot_compare("min_tas", metadata, path_cleaned, boundary = uk, plot_fun = plot_tas)

Minimum temperature (min_tasmin)

plot_compare("min_tasmin", metadata, path_cleaned, boundary = uk, plot_fun = plot_tas)

Soil moisture deficit (smd)

plot_compare("smd", path = path_processed, boundary = uk, plot_fun = plot_smd)

Soil moisture surplus (sms)

plot_compare("sms", path = path_processed, boundary = uk, plot_fun = plot_sms)

Monthly potential evapotranspiration with correction (peti)

We need to convert SPEED evapotranspiration data to total.

plot_compare_monthly("peti", metadata, path_cleaned, boundary = uk,
                     trans_fun = pet_to_total, plot_fun = plot_pet)

Monthly precipitation (precip)

We need to convert SPEED precipitation data to total.

plot_compare_monthly(c("precip", "pr"), metadata, path_cleaned, boundary = uk,
                     trans_fun = precip_to_total, plot_fun = plot_prec,
                     breaks = "equal")

Time to execute the task

Only useful when executed with Rscript.

proc.time()
#>    user  system elapsed 
#> 205.110  14.583 219.871