diff --git a/inst/doc/UseCase1_WindEvent_March2018.R b/inst/doc/UseCase1_WindEvent_March2018.R index d3bbb9363ba0c9058efa573bae6f0a9512163a80..2bb64f0b4394745ebd084316b1417cb24c677716 100644 --- a/inst/doc/UseCase1_WindEvent_March2018.R +++ b/inst/doc/UseCase1_WindEvent_March2018.R @@ -10,6 +10,7 @@ rm(list=ls()); gc(); # in December 2017, January 2018 and February 2018 # This code includes the bias adjustent and the results visualization # ---------------------------------------- +# Update date: "March 2023" #library(CSTools) library(s2dv) @@ -55,7 +56,7 @@ for (mm in 1:3) { latmin = 36, latmax = 44, lonmin = -10, lonmax = 4, # latmin = 42, latmax = 44, lonmin = -10, lonmax = 1, output = 'lonlat', nprocs = 1) - str(wind_hcst$Dates) + str(wind_hcst$attrs$Dates) dim(wind_hcst$data) fcst_sdates <- paste0(year, months_in_advance[mm], '01') wind_fcst <- CSTools::CST_Load(var = 'sfcWind', exp = list(exp_path), @@ -66,7 +67,7 @@ for (mm in 1:3) { # latmin = 42, latmax = 44, lonmin = -10, lonmax = 1, output = 'lonlat', nprocs = 1) - str(wind_fcst$Dates) + str(wind_fcst$attrs$Dates) dim(wind_fcst$data) wind_ref <- CSTools::CST_Load(var = 'windagl100', obs = list(obs_path), @@ -77,9 +78,9 @@ for (mm in 1:3) { # latmin = 42, latmax = 44, lonmin = -10, lonmax = 1, output = 'lonlat', nprocs = 1, grid = 'r360x181') - str(wind_ref$Dates) + str(wind_ref$attrs$Dates) dim(wind_ref$data) - print(wind_ref$Dates$start) + print(wind_ref$attrs$Dates) wind_ref_terciles <- rbind(wind_ref_terciles, quantile(MeanDims(wind_ref$data, c('lat', 'lon')), c(0.3, 0.6))) @@ -140,8 +141,8 @@ for (mm in 1:3) { source("/esarchive/scratch/nperez/git/cstools/R/PlotMostLikelyQuantileMap.R") agg_png(paste0(output_dir, "Wind_MostLikely_", mm, "_obstercile.png"), width = 1050, height = 1000, units = 'px', res = 144) - PlotMostLikelyQuantileMap(probs = Mean_PB, lon = wind_fsct$lon, - lat = wind_fsct$lat, sizetit = 1.5, + PlotMostLikelyQuantileMap(probs = Mean_PB, lon = wind_fsct$coords$lon, + lat = wind_fsct$coords$lat, sizetit = 1.5, intylat = 2, intxlon = 2, coast_width = 1.5, legend_scale = 0.8, cat_dim = 'bin', dot_size = 2.5, @@ -197,7 +198,7 @@ agg_png(paste0(output_dir, "MostLikely_Observed_obstercile.png"), width = 1000, height = 1000, units = 'px', res = 144) s2dv::PlotEquiMap(wind_obs_obstercile, - lon = wind_obs$lon, lat = wind_obs$lat, + lon = wind_obs$coords$lon, lat = wind_obs$coords$lat, brks = c(0,1,2,3), cols = c("#6BAED6FF", "#FFEDA0FF", "#FC4E2AFF"), intylat = 2, intxlon = 2, diff --git a/inst/doc/UseCase2_PrecipitationDownscaling_RainFARM_RF100.R b/inst/doc/UseCase2_PrecipitationDownscaling_RainFARM_RF100.R index 146382dc8983caa3873a8b13665214b6d0dfb7d0..23654b5621c7c4d35122f7a2bb181b7250beca6b 100644 --- a/inst/doc/UseCase2_PrecipitationDownscaling_RainFARM_RF100.R +++ b/inst/doc/UseCase2_PrecipitationDownscaling_RainFARM_RF100.R @@ -18,6 +18,7 @@ rm(list=ls()); gc(); # In this file, the lines are commented since they have been run and the # result saved on disk, then the result is loaded. # ---------------------------------------- +# Update date: "March 2023" # # Load required libraries and setup output directory: library(CSTools) @@ -102,7 +103,7 @@ load(paste0(dir_output, 'weightsRF100.RDS')) # -------------------------------------------- agg_png(paste0(dir_output, "RF100_WeightsDec.png"), width = 1000, height = 1100, units = 'px',res = 144) -PlotEquiMap(weight$data[,,12], lon = weight$lon, lat = weight$lat, +PlotEquiMap(weight$data[,,12], lon = weight$coords$lon, lat = weight$coords$lat, filled.continents = FALSE, title_scale = 1, intylat = 2, intxlon = 2, toptitle = 'December Weights RF 100') @@ -135,20 +136,20 @@ for (realizations in 1:10) { # ---------------------------- agg_png(paste0(dir_output, "RF100_Down_11dec.png"), width = 1000, height = 1100, units = 'px',res = 144) - PlotEquiMap(fs$data[1,11,,],lon = fs$lon, lat = fs$lat, + PlotEquiMap(fs$data[1,11,,],lon = fs$coords$lon, lat = fs$coords$lat, filled.continents = FALSE, bar_limits = c(0,40), intylat = 2, intxlon = 2, title_scale = 1, triangle_ends = c(TRUE, FALSE), toptitle = 'Downsacaled RF 100', units = 'precipitation (mm)') dev.off() } - result$lon <- fs$lon - result$lat <- fs$lat + result$coords$lon <- fs$coords$lon + result$coords$lat <- fs$coords$lat result <- CST_MergeDims(result, merge_dims = c("ftime", "monthly"), na.rm = TRUE) - result$Dataset <- paste0('RF100_ECMWFC3S_QM_member_', member, '_real_', + result$attrs$Dataset <- paste0('RF100_ECMWFC3S_QM_member_', member, '_real_', realizations) - result$Dates[[1]] <- exp$Dates[[1]] + result$attrs$Dates <- exp$attrs$Dates CST_SaveExp(result, destination = dir_output, extra_string = paste0('member', k)) gc() diff --git a/inst/doc/UseCase2_PrecipitationDownscaling_RainFARM_RF4.R b/inst/doc/UseCase2_PrecipitationDownscaling_RainFARM_RF4.R index ee2df1943eef5547d21401f55c8fe10d2853132d..de205fdef5e96da8314b70683e6bb5000350d897 100644 --- a/inst/doc/UseCase2_PrecipitationDownscaling_RainFARM_RF4.R +++ b/inst/doc/UseCase2_PrecipitationDownscaling_RainFARM_RF4.R @@ -17,6 +17,7 @@ rm(list=ls()); gc(); # In this file, the lines are commented since they have been run and the # result saved on disk, then the result is loaded. # ---------------------------------------- +# Update date: "March 2023" # # Load required libraries and setup output directory: library(CSTools) @@ -110,7 +111,7 @@ fs <- CST_RainFARM(exp.qm, nf = 4, newfs <- CST_MergeDims(fs, merge_dims = c("ftime", "monthly"), na.rm = TRUE) -newfs$Dates[[1]] <- exp$Dates[[1]] +newfs$attrs$Dates <- exp$attrs$Dates CST_SaveExp(newfs, destination = paste0(dir_output, 'RF4/')) Rprof(NULL) @@ -121,7 +122,7 @@ profile.info <- summaryRprof(paste0(dir_output, "Rprof.out")) library(s2dv) agg_png(paste0(dir_output, "EXP_11dec.png"), width = 800, height = 900, units = 'px',res = 144) -PlotEquiMap(exp$data[1,1,1,11,,,2],lon = exp$lon, lat = exp$lat, +PlotEquiMap(exp$data[1,1,1,11,,,2],lon = exp$coords$lon, lat = exp$coords$lat, filled.continents = FALSE, bar_limits = c(0,40), intylat = 2, intxlon = 2, title_scale = 0.8, bar_label_scale = 1.3, axes_label_scale = 1.2, @@ -130,7 +131,7 @@ PlotEquiMap(exp$data[1,1,1,11,,,2],lon = exp$lon, lat = exp$lat, dev.off() agg_png(paste0(dir_output, "EXPQM_11dec.png"), width = 800, height = 900, units = 'px',res = 144) -PlotEquiMap(exp.qm$data[1,1,1,11,,,2],lon = exp$lon, lat = exp$lat, +PlotEquiMap(exp.qm$data[1,1,1,11,,,2],lon = exp$coords$lon, lat = exp$coords$lat, filled.continents = FALSE, bar_limits = c(0,40), intylat = 2, intxlon = 2, title_scale = 0.8, bar_label_scale = 1.3, axes_label_scale = 1.2, @@ -139,7 +140,7 @@ PlotEquiMap(exp.qm$data[1,1,1,11,,,2],lon = exp$lon, lat = exp$lat, dev.off() agg_png(paste0(dir_output, "RF4_Down_11dec.png"), width = 800, height = 900, units = 'px',res = 144) -PlotEquiMap(fs$data[1,1,1,11,,,2],lon = fs$lon, lat = fs$lat, +PlotEquiMap(fs$data[1,1,1,11,,,2],lon = fs$coords$lon, lat = fs$coords$lat, filled.continents = FALSE, bar_limits = c(0,40), intylat = 2, intxlon = 2, title_scale = 0.8, bar_label_scale = 1.3, axes_label_scale = 1.2, @@ -148,7 +149,7 @@ PlotEquiMap(fs$data[1,1,1,11,,,2],lon = fs$lon, lat = fs$lat, dev.off() agg_png(paste0(dir_output, "RF4_WeightsDec.png"), width = 800, height = 900, units = 'px',res = 144) -PlotEquiMap(weight$data[,,12], lon = weight$lon, lat = weight$lat, +PlotEquiMap(weight$data[,,12], lon = weight$coords$lon, lat = weight$coords$lat, filled.continents = FALSE, title_scale = 0.8, bar_label_scale = 1.3, axes_label_scale = 1.2, intylat = 2, intxlon = 2, degree_sym = TRUE, diff --git a/inst/doc/UseCase3_data_preparation_SCHEME_model.R b/inst/doc/UseCase3_data_preparation_SCHEME_model.R index ada24ef2c762ca78eef563a2fca2c97a75a44903..9e38208c8e106a3862a95cf9eed315973013f8ec 100644 --- a/inst/doc/UseCase3_data_preparation_SCHEME_model.R +++ b/inst/doc/UseCase3_data_preparation_SCHEME_model.R @@ -1,6 +1,8 @@ # Author: Bert Van Schaeybroeck # Use Case 3: Seasonal forecasts for a river flow # ----------------------------------------------- +# Update date: "March 2023" + rm(list = ls()) library(CSTools) library(s2dverification) @@ -337,12 +339,12 @@ obs.low.res.merge <- CST_MergeDims( #amount of ensemble members from experiment. For ECMWF Sys5 it is 25: amt.mbr <- as.numeric(dim(cal.merge$data)["member"]) -lon.low.res <- as.vector(cal.merge$lon) -lat.low.res <- as.vector(cal.merge$lat) -lon.high.res <- as.vector(obs.high.res$lon) -lat.high.res <- as.vector(obs.high.res$lat) -lon.eur <- as.vector(obs.msl.eur.merge.an$lon) -lat.eur <- as.vector(obs.msl.eur.merge.an$lat) +lon.low.res <- as.vector(cal.merge$coords$lon) +lat.low.res <- as.vector(cal.merge$coords$lat) +lon.high.res <- as.vector(obs.high.res$coords$lon) +lat.high.res <- as.vector(obs.high.res$coords$lat) +lon.eur <- as.vector(obs.msl.eur.merge.an$coords$lon) +lat.eur <- as.vector(obs.msl.eur.merge.an$coords$lat) #amount of lead times in months. For ECMWF Sys5 it is 7: amt.lead.mon <- as.numeric(dim(cal.merge$data)["monthly"]) @@ -448,8 +450,8 @@ for(i.mbr in seq(1, amt.mbr)){ pdf(file = file.fig) PlotEquiMap( exp.low.res.tmp[ , ], - lon = obs.low.res.merge$lon, - lat = obs.low.res.merge$lat, + lon = obs.low.res.merge$coords$lon, + lat = obs.low.res.merge$coords$lat, filled.continents = F, intylat = 2, intxlon = 2, @@ -463,8 +465,8 @@ for(i.mbr in seq(1, amt.mbr)){ pdf(file = file.fig) PlotEquiMap( cal.low.res.tmp, - lon = obs.low.res.merge$lon, - lat = obs.low.res.merge$lat, + lon = obs.low.res.merge$coords$lon, + lat = obs.low.res.merge$coords$lat, filled.continents = F, intylat = 2, intxlon = 2, @@ -477,8 +479,8 @@ for(i.mbr in seq(1, amt.mbr)){ pdf(file = file.fig) PlotEquiMap( obs.low.res.tmp[corr.dex, , ], - lon = obs.low.res.merge$lon, - lat = obs.low.res.merge$lat, + lon = obs.low.res.merge$coords$lon, + lat = obs.low.res.merge$coords$lat, filled.continents = F, intylat = 2, intxlon = 2, @@ -492,8 +494,8 @@ for(i.mbr in seq(1, amt.mbr)){ pdf(file = file.fig) PlotEquiMap( obs.high.res.tmp[corr.dex, , ], - lon = obs.high.res.merge$lon, - lat = obs.high.res.merge$lat, + lon = obs.high.res.merge$coords$lon, + lat = obs.high.res.merge$coords$lat, filled.continents = F, intylat = 2, intxlon = 2,