From d8fcea54643bf04ecccfbe4bbafe1e18b3f5ca69 Mon Sep 17 00:00:00 2001 From: aho Date: Tue, 22 Sep 2020 15:59:12 +0200 Subject: [PATCH 01/23] Change time zone from local to UTC --- R/Load.R | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/R/Load.R b/R/Load.R index cded9565..bbaf2c89 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1553,7 +1553,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, # the current date. if (is.null(exp) || dims == 0) { if (is.null(leadtimemax)) { - diff <- Sys.time() - as.POSIXct(sdates[1], format = '%Y%m%d') + diff <- Sys.time() - as.POSIXct(sdates[1], format = '%Y%m%d', tz = "GMT") if (diff > 0) { .warning("Loading observations only and no 'leadtimemax' specified. Data will be loaded from each starting date to current time.") if (storefreq == 'monthly') { @@ -1709,7 +1709,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, } day <- as.integer(day) startdate <- as.POSIXct(paste(substr(sdate, 1, 4), '-', - substr(sdate, 5, 6), '-', day, ' 12:00:00', sep = '')) + + substr(sdate, 5, 6), '-', day, ' 12:00:00', sep = ''), tz = "GMT") + (leadtimemin - 1) * 86400 year <- as.integer(substr(startdate, 1, 4)) month <- as.integer(substr(startdate, 6, 7)) @@ -2226,9 +2226,11 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, function(x) { do.call(c, lapply((0:(number_ftime - 1)) * sampleperiod, function(y) { - addTime(as.POSIXct(x, format = "%Y%m%d"), store_period, y + leadtimemin - 1) + addTime(as.POSIXct(x, format = "%Y%m%d", tz = "GMT"), store_period, y + leadtimemin - 1) })) })) + attr(dates[["start"]], "tzone") <- "GMT" + # end is similar to start, but contains the end dates of each forecast # time step dates[["end"]] <- do.call(c, lapply(dates[["start"]], @@ -2238,6 +2240,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, addTime(y, store_period) })) })) + attr(dates[["end"]], "tzone") <- "GMT" tags_to_find <- c('START_DATE', 'MEMBER_NUMBER', 'YEAR', 'MONTH', 'DAY') position_of_tags <- na.omit(match(tags_to_find, names(replace_values))) @@ -2249,14 +2252,19 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, models <- list() for (jmod in 1:length(exp)) { member_names <- paste0("Member_", 1:nmember[jmod]) - models[[exp[[jmod]][["name"]]]] <- list( - InitializationDates = lapply(member_names, + + InitializationDates <- do.call(c, lapply(member_names, function(x) { do.call(c, lapply(sdates, function(y) { - as.POSIXct(y, format = "%Y%m%d") + as.POSIXct(y, format = "%Y%m%d", tz = "GMT") })) - }), + })) + attr(InitializationDates, "tzone") <- "GMT" + + models[[exp[[jmod]][["name"]]]] <- list( + InitializationDates = InitializationDates, Members = member_names) + names(models[[exp[[jmod]][["name"]]]]$InitializationDates) <- member_names attr(models[[exp[[jmod]][["name"]]]], 'dataset') <- exp[[jmod]][["name"]] attr(models[[exp[[jmod]][["name"]]]], 'source') <- { -- GitLab From 83d6ba167f600ee368b52e7f3b79132cb2f7e42f Mon Sep 17 00:00:00 2001 From: aho Date: Tue, 22 Sep 2020 16:00:36 +0200 Subject: [PATCH 02/23] Change from GMT to UTC --- R/Load.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/R/Load.R b/R/Load.R index bbaf2c89..6b136ec9 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1553,7 +1553,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, # the current date. if (is.null(exp) || dims == 0) { if (is.null(leadtimemax)) { - diff <- Sys.time() - as.POSIXct(sdates[1], format = '%Y%m%d', tz = "GMT") + diff <- Sys.time() - as.POSIXct(sdates[1], format = '%Y%m%d', tz = "UTC") if (diff > 0) { .warning("Loading observations only and no 'leadtimemax' specified. Data will be loaded from each starting date to current time.") if (storefreq == 'monthly') { @@ -1709,7 +1709,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, } day <- as.integer(day) startdate <- as.POSIXct(paste(substr(sdate, 1, 4), '-', - substr(sdate, 5, 6), '-', day, ' 12:00:00', sep = ''), tz = "GMT") + + substr(sdate, 5, 6), '-', day, ' 12:00:00', sep = ''), tz = "UTC") + (leadtimemin - 1) * 86400 year <- as.integer(substr(startdate, 1, 4)) month <- as.integer(substr(startdate, 6, 7)) @@ -2226,10 +2226,10 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, function(x) { do.call(c, lapply((0:(number_ftime - 1)) * sampleperiod, function(y) { - addTime(as.POSIXct(x, format = "%Y%m%d", tz = "GMT"), store_period, y + leadtimemin - 1) + addTime(as.POSIXct(x, format = "%Y%m%d", tz = "UTC"), store_period, y + leadtimemin - 1) })) })) - attr(dates[["start"]], "tzone") <- "GMT" + attr(dates[["start"]], "tzone") <- "UTC" # end is similar to start, but contains the end dates of each forecast # time step @@ -2240,7 +2240,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, addTime(y, store_period) })) })) - attr(dates[["end"]], "tzone") <- "GMT" + attr(dates[["end"]], "tzone") <- "UTC" tags_to_find <- c('START_DATE', 'MEMBER_NUMBER', 'YEAR', 'MONTH', 'DAY') position_of_tags <- na.omit(match(tags_to_find, names(replace_values))) @@ -2256,10 +2256,10 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, InitializationDates <- do.call(c, lapply(member_names, function(x) { do.call(c, lapply(sdates, function(y) { - as.POSIXct(y, format = "%Y%m%d", tz = "GMT") + as.POSIXct(y, format = "%Y%m%d", tz = "UTC") })) })) - attr(InitializationDates, "tzone") <- "GMT" + attr(InitializationDates, "tzone") <- "UTC" models[[exp[[jmod]][["name"]]]] <- list( InitializationDates = InitializationDates, -- GitLab From 3aec51a5cd211216cb2e1bd586798c4071f71ece Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 14 Oct 2020 17:47:30 +0200 Subject: [PATCH 03/23] First version to check the first timestamp in files --- R/Load.R | 35 +++++++++++++++++++++++++++++++++-- R/Utils.R | 24 ++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/R/Load.R b/R/Load.R index 6b136ec9..83012596 100644 --- a/R/Load.R +++ b/R/Load.R @@ -850,6 +850,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, configfile = NULL, varmin = NULL, varmax = NULL, silent = FALSE, nprocs = NULL, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial') { + #library(parallel) #library(bigmemory) @@ -1052,7 +1053,6 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (!is.character(storefreq) || !(storefreq %in% c('monthly', 'daily'))) { stop("Error: parameter 'storefreq' is wrong, can take value 'daily' or 'monthly'.") } - # sampleperiod if (is.null(sampleperiod) || !is.numeric(sampleperiod)) { stop("Error: parameter 'sampleperiod' is wrong. It should be numeric.") @@ -1732,7 +1732,36 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, ## This condition must be fulfilled to put all the month time steps ## in the dimension of length nleadtimes. Otherwise it must be cut: #(length(leadtimes) - 1)*sampleperiod + 1 - (jleadtime - 1)*sampleperiod >= days_in_month - day + 1 + + ## Nuria: The first time step in exp could be different from sdate: +if (jleadtime == 1) { + print("NEW:") + print(jleadtime) + if (is.null(found_data$time_dim)) { + stop("Check 'time' variable in the experimental files, ", + "since not units or first time step have been found.") + } else { + print("found_data$time_dim TRUE") + origin <- as.POSIXct( + paste(strsplit(found_data$time_dim$time_units , " ")[[1]][c(3,4)], + collapse = " "), tz = 'UTC') + units <- strsplit(found_data$time_dim$time_units, " ")[[1]][1] + if (units == 'hours') { + exp_first_time_step <- as.POSIXct(found_data$time_dim$first_time_step_in_file * + 3600, origin = origin, tz = 'UTC') + } else if (units == 'days') { + exp_first_time_step <- as.POSIXct(found_data$time_dim$first_time_step_in_file * + 86400, origin = origin, tz = 'UTC') + } + } + print(paste("exp_first_time_step :", exp_first_time_step)) + if (as.numeric(format(exp_first_time_step, "%d")) > 1) { + day <- as.numeric(format(exp_first_time_step, "%d")) + print(paste("day:", day)) + } +} obs_file_indices <- seq(day, min(days_in_month, (length(leadtimes) - jleadtime) * sampleperiod + day), sampleperiod) +print(obs_file_indices) } else { obs_file_indices <- 1 } @@ -1828,7 +1857,9 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, } if (storefreq == 'daily') { - startdate <- startdate + 86400 * sampleperiod * length(obs_file_indices) + #startdate <- startdate + 86400 * sampleperiod * length(obs_file_indices) +startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) +print(paste("New startdate:", startdate)) year <- as.integer(substr(startdate, 1, 4)) month <- as.integer(substr(startdate, 6, 7)) day <- as.integer(substr(startdate, 9, 10)) diff --git a/R/Utils.R b/R/Utils.R index 44600181..d59a32ec 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -590,7 +590,14 @@ if (length(time_dimname) == 1) { nltime <- fnc$var[[namevar]][['dim']][[match(time_dimname, var_dimnames)]]$len expected_dims <- c(expected_dims, time_dimname) +print(expected_dims) +print(time_dimname) dim_matches <- match(expected_dims, var_dimnames) +first_time_step_in_file <- fnc$var[[namevar]][['dim']][[match(time_dimname, + var_dimnames)]]$vals[1] +time_units <- fnc$var[[namevar]][['dim']][[match(time_dimname, var_dimnames)]]$units +print(first_time_step_in_file) +print(time_units) } else { if (!is.null(old_members_dimname)) { expected_dims[which(expected_dims == 'lev')] <- old_members_dimname @@ -621,6 +628,7 @@ # 3) Members (even if is not a file per member experiment) # 4) Lead-times if (work_piece[['is_file_per_dataset']]) { +print("HERE") time_indices <- 1:nltime mons <- strsplit(system(paste('cdo showmon ', filein, ' 2>/dev/null'), intern = TRUE), split = ' ') @@ -631,7 +639,8 @@ time_indices <- ts(time_indices, start = c(years[1], mons[1]), end = c(years[length(years)], mons[length(mons)]), frequency = 12) - ltimes_list <- list() +print(time_indices) + ltimes_list <- list() for (sdate in work_piece[['startdates']]) { selected_time_indices <- window(time_indices, start = c(as.numeric( substr(sdate, 1, 4)), as.numeric(substr(sdate, 5, 6))), @@ -639,7 +648,9 @@ selected_time_indices <- selected_time_indices[work_piece[['leadtimes']]] ltimes_list <- c(ltimes_list, list(selected_time_indices)) } +print(ltimes_list) } else { +print("HERE 2") ltimes <- work_piece[['leadtimes']] #if (work_piece[['dataset_type']] == 'exp') { ltimes_list <- list(ltimes[which(ltimes <= nltime)]) @@ -687,14 +698,19 @@ final_dims[3] <- length(members) } if (time_dimname %in% expected_dims) { +print("HERE 3") if (any(!is.na(ltimes))) { +print("HERE 4") start <- c(start, head(ltimes[which(!is.na(ltimes))], 1)) end <- c(end, tail(ltimes[which(!is.na(ltimes))], 1)) subset_indices <- c(subset_indices, list(ltimes - head(ltimes[which(!is.na(ltimes))], 1) + 1)) +print(subset_indices) } else { start <- c(start, NA) end <- c(end, NA) subset_indices <- c(subset_indices, list(ltimes)) +print("HERE 5") +print(subset_indices) } dim_time <- ncdim_def(time_dimname, "", 1:length(ltimes), unlim = TRUE) ncdf_dims <- c(ncdf_dims, list(dim_time)) @@ -854,6 +870,8 @@ } } dims <- list(member = nmemb, ftime = nltime, lon = final_lons, lat = final_lats) +print("HERE 6") +print(dims) } else { # If we are not exploring, then we have to process the retrieved data if (is_2d_var) { @@ -938,7 +956,9 @@ if (explore_dims) { list(dims = dims, is_2d_var = is_2d_var, grid = grid_name, units = units, var_long_name = var_long_name, - data_across_gw = data_across_gw, array_across_gw = array_across_gw) + data_across_gw = data_across_gw, array_across_gw = array_across_gw, + time_dim = list(first_time_step_in_file = first_time_step_in_file, + time_units = time_units)) } else { ###if (!silent && !is.null(progress_connection) && !is.null(work_piece[['progress_amount']])) { ### foobar <- writeBin(work_piece[['progress_amount']], progress_connection) -- GitLab From 565e7394db75693eeef438eea4853b11b56c4522 Mon Sep 17 00:00:00 2001 From: nperez Date: Fri, 16 Oct 2020 15:15:26 +0200 Subject: [PATCH 04/23] Load properly working for 2 sdates when loading ecmwf s5c3s --- R/Load.R | 99 ++++++++++++++++++++++++++++++++----------------------- R/Utils.R | 19 ++--------- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/R/Load.R b/R/Load.R index 83012596..3d015dac 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1382,6 +1382,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, dims2define <- TRUE is_file_per_member_exp <- rep(nmod, FALSE) exp_work_pieces <- list() + first_time_step_list <- NULL jmod <- 1 while (jmod <= nmod) { first_dataset_file_found <- FALSE @@ -1445,6 +1446,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, found_dims <- found_data$dims var_long_name <- found_data$var_long_name units <- found_data$units + first_time_step_list <- c(first_time_step_list, list(found_data$time_dim)) if (!is.null(found_dims)) { # If a file is found, we can define the dimensions of the output arrays. is_2d_var <- found_data$is_2d_var @@ -1635,6 +1637,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, found_data <- .LoadDataFile(work_piece, explore_dims = TRUE, silent = silent) found_dims <- found_data$dims var_long_name <- found_data$var_long_name + first_time_step_list <- c(first_time_step_list, list(found_data$time_dim)) units <- found_data$units if (!is.null(found_dims)) { is_2d_var <- found_data$is_2d_var @@ -1734,34 +1737,31 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, #(length(leadtimes) - 1)*sampleperiod + 1 - (jleadtime - 1)*sampleperiod >= days_in_month - day + 1 ## Nuria: The first time step in exp could be different from sdate: -if (jleadtime == 1) { - print("NEW:") - print(jleadtime) - if (is.null(found_data$time_dim)) { - stop("Check 'time' variable in the experimental files, ", - "since not units or first time step have been found.") - } else { - print("found_data$time_dim TRUE") - origin <- as.POSIXct( - paste(strsplit(found_data$time_dim$time_units , " ")[[1]][c(3,4)], - collapse = " "), tz = 'UTC') - units <- strsplit(found_data$time_dim$time_units, " ")[[1]][1] - if (units == 'hours') { - exp_first_time_step <- as.POSIXct(found_data$time_dim$first_time_step_in_file * + if (jleadtime == 1) { + if (is.null(first_time_step_list[[1]])) { + stop("Check 'time' variable in the experimental files ", + "since not units or first time step have been found.") + } else { + origin <- as.POSIXct( + paste(strsplit(first_time_step_list[[1]]$time_units, " ")[[1]][c(3,4)], + collapse = " "), tz = 'UTC') + units <- strsplit(first_time_step_list[[1]]$time_units, " ")[[1]][1] + if (units == 'hours') { + exp_first_time_step <- as.POSIXct( + first_time_step_list[[1]]$first_time_step_in_file * 3600, origin = origin, tz = 'UTC') - } else if (units == 'days') { - exp_first_time_step <- as.POSIXct(found_data$time_dim$first_time_step_in_file * + } else if (units == 'days') { + exp_first_time_step <- as.POSIXct( + first_time_step_list[[1]]$first_time_step_in_file * 86400, origin = origin, tz = 'UTC') - } - } - print(paste("exp_first_time_step :", exp_first_time_step)) - if (as.numeric(format(exp_first_time_step, "%d")) > 1) { - day <- as.numeric(format(exp_first_time_step, "%d")) - print(paste("day:", day)) - } -} - obs_file_indices <- seq(day, min(days_in_month, (length(leadtimes) - jleadtime) * sampleperiod + day), sampleperiod) -print(obs_file_indices) + } + } + if (as.numeric(format(exp_first_time_step, "%d")) > 1) { + day <- as.numeric(format(exp_first_time_step, "%d")) + } + } + obs_file_indices <- seq(day, min(days_in_month, + (length(leadtimes) - jleadtime) * sampleperiod + day), sampleperiod) } else { obs_file_indices <- 1 } @@ -2173,49 +2173,55 @@ print(paste("New startdate:", startdate)) attr(variable, 'daily_agg_cellfun') <- 'none' attr(variable, 'monthly_agg_cellfun') <- 'none' attr(variable, 'verification_time') <- 'none' - - number_ftime <- NULL + + number_ftime <- NULL if (is.null(var_exp)) { mod_data <- NULL - } else { + } else { dim_reorder <- length(dim_exp):1 dim_reorder[2:3] <- dim_reorder[3:2] old_dims <- dim_exp dim_exp <- dim_exp[dim_reorder] - mod_data <- aperm(array(bigmemory::as.matrix(var_exp), dim = old_dims), dim_reorder) + mod_data <- + aperm(array(bigmemory::as.matrix(var_exp), dim = old_dims), dim_reorder) attr(mod_data, 'dimensions') <- names(dim_exp) names(dim(mod_data)) <- names(dim_exp) number_ftime <- dim_exp[["ftime"]] } - + if (is.null(var_obs)) { obs_data <- NULL - } else { + } else { dim_reorder <- length(dim_obs):1 dim_reorder[2:3] <- dim_reorder[3:2] old_dims <- dim_obs dim_obs <- dim_obs[dim_reorder] - obs_data <- aperm(array(bigmemory::as.matrix(var_obs), dim = old_dims), dim_reorder) + obs_data <- + aperm(array(bigmemory::as.matrix(var_obs), dim = old_dims), dim_reorder) attr(obs_data, 'dimensions') <- names(dim_obs) names(dim(obs_data)) <- names(dim_obs) if (is.null(number_ftime)) { number_ftime <- dim_obs[["ftime"]] } } - + if (is.null(latitudes)) { lat <- 0 attr(lat, 'cdo_grid_name') <- 'none' attr(lat, 'first_lat') <- 'none' - attr(lat, 'last_lat') <- 'none' + attr(lat, 'last_lat') <- 'none' } else { lat <- latitudes - attr(lat, 'cdo_grid_name') <- if (is.null(grid)) 'none' else grid + attr(lat, 'cdo_grid_name') <- + if (is.null(grid)) + 'none' + else + grid attr(lat, 'first_lat') <- tail(lat, 1) attr(lat, 'last_lat') <- head(lat, 1) } attr(lat, 'projection') <- 'none' - + if (is.null(longitudes)) { lon <- 0 attr(lon, 'cdo_grid_name') <- 'none' @@ -2225,14 +2231,18 @@ print(paste("New startdate:", startdate)) attr(lon, 'last_lon') <- 'none' } else { lon <- longitudes - attr(lon, 'cdo_grid_name') <- if (is.null(grid)) 'none' else grid + attr(lon, 'cdo_grid_name') <- + if (is.null(grid)) + 'none' + else + grid attr(lon, 'data_across_gw') <- data_across_gw attr(lon, 'array_across_gw') <- array_across_gw attr(lon, 'first_lon') <- lon[which.min(abs(lon - lonmin))] attr(lon, 'last_lon') <- lon[which.min(abs(lon - lonmax))] } attr(lon, 'projection') <- 'none' - + dates <- list() ## we must put a start and end time for each prediction c(start date, forecast time) if (storefreq == 'minutely') { @@ -2244,18 +2254,23 @@ print(paste("New startdate:", startdate)) } else if (storefreq == 'monthly') { store_period <- 'month' } - + addTime <- function(date, period, n = 1) { seq(date, by = paste(n, period), length = 2)[2] } - + # We build dates, a list with components start and end. # Start is a list with as many components as start dates. # Each component is a vector of the initial POSIXct date of each # forecast time step + if (storefreq == 'daily') { + origin <- as.numeric(format(exp_first_time_step, "%d")) - 1 + } else { + origin <- 0 + } dates[["start"]] <- do.call(c, lapply(sdates, function(x) { - do.call(c, lapply((0:(number_ftime - 1)) * sampleperiod, + do.call(c, lapply((origin:(origin + number_ftime - 1)) * sampleperiod, function(y) { addTime(as.POSIXct(x, format = "%Y%m%d", tz = "UTC"), store_period, y + leadtimemin - 1) })) diff --git a/R/Utils.R b/R/Utils.R index d59a32ec..a7415c51 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -590,14 +590,10 @@ if (length(time_dimname) == 1) { nltime <- fnc$var[[namevar]][['dim']][[match(time_dimname, var_dimnames)]]$len expected_dims <- c(expected_dims, time_dimname) -print(expected_dims) -print(time_dimname) dim_matches <- match(expected_dims, var_dimnames) -first_time_step_in_file <- fnc$var[[namevar]][['dim']][[match(time_dimname, + first_time_step_in_file <- fnc$var[[namevar]][['dim']][[match(time_dimname, var_dimnames)]]$vals[1] -time_units <- fnc$var[[namevar]][['dim']][[match(time_dimname, var_dimnames)]]$units -print(first_time_step_in_file) -print(time_units) + time_units <- fnc$var[[namevar]][['dim']][[match(time_dimname, var_dimnames)]]$units } else { if (!is.null(old_members_dimname)) { expected_dims[which(expected_dims == 'lev')] <- old_members_dimname @@ -628,7 +624,6 @@ print(time_units) # 3) Members (even if is not a file per member experiment) # 4) Lead-times if (work_piece[['is_file_per_dataset']]) { -print("HERE") time_indices <- 1:nltime mons <- strsplit(system(paste('cdo showmon ', filein, ' 2>/dev/null'), intern = TRUE), split = ' ') @@ -639,7 +634,6 @@ print("HERE") time_indices <- ts(time_indices, start = c(years[1], mons[1]), end = c(years[length(years)], mons[length(mons)]), frequency = 12) -print(time_indices) ltimes_list <- list() for (sdate in work_piece[['startdates']]) { selected_time_indices <- window(time_indices, start = c(as.numeric( @@ -648,9 +642,7 @@ print(time_indices) selected_time_indices <- selected_time_indices[work_piece[['leadtimes']]] ltimes_list <- c(ltimes_list, list(selected_time_indices)) } -print(ltimes_list) } else { -print("HERE 2") ltimes <- work_piece[['leadtimes']] #if (work_piece[['dataset_type']] == 'exp') { ltimes_list <- list(ltimes[which(ltimes <= nltime)]) @@ -698,19 +690,14 @@ print("HERE 2") final_dims[3] <- length(members) } if (time_dimname %in% expected_dims) { -print("HERE 3") if (any(!is.na(ltimes))) { -print("HERE 4") start <- c(start, head(ltimes[which(!is.na(ltimes))], 1)) end <- c(end, tail(ltimes[which(!is.na(ltimes))], 1)) subset_indices <- c(subset_indices, list(ltimes - head(ltimes[which(!is.na(ltimes))], 1) + 1)) -print(subset_indices) } else { start <- c(start, NA) end <- c(end, NA) subset_indices <- c(subset_indices, list(ltimes)) -print("HERE 5") -print(subset_indices) } dim_time <- ncdim_def(time_dimname, "", 1:length(ltimes), unlim = TRUE) ncdf_dims <- c(ncdf_dims, list(dim_time)) @@ -870,8 +857,6 @@ print(subset_indices) } } dims <- list(member = nmemb, ftime = nltime, lon = final_lons, lat = final_lats) -print("HERE 6") -print(dims) } else { # If we are not exploring, then we have to process the retrieved data if (is_2d_var) { -- GitLab From 34dc2ddb91b7d5016b61bb0ece2d10c35b6d0b22 Mon Sep 17 00:00:00 2001 From: nperez Date: Fri, 16 Oct 2020 15:52:18 +0200 Subject: [PATCH 05/23] Tests added for loading exp system5 and obs --- tests/testthat/test-Load.R | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/testthat/test-Load.R diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R new file mode 100644 index 00000000..43111a0e --- /dev/null +++ b/tests/testthat/test-Load.R @@ -0,0 +1,56 @@ +Context("Testing Load with ECMWF System5c3s daily data") +test_that("First time step is correctly interpreted:", { + data <- Load(var = 'prlr', + exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), + obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 25,leadtimemin = 1, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) + expect_equal(dim(data$mod), c(dataset = 1, member = 25, sdate = 2, ftime = 214, + lat = 8, lon = 8)) + expect_equal(dim(data$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 214, + lat = 8, lon = 8)) + expect_equal(sum(is.na(data$mod)), 0) + expect_equal(sum(is.na(data$obs)), 0) + dates <- c(seq(as.POSIXct("1993-11-02", tz = 'UTC'), + as.POSIXct("1994-06-03", tz = 'UTC'), "d"), + seq(as.POSIXct("1994-11-02", tz = 'UTC'), + as.POSIXct("1995-06-03", tz = 'UTC'), "d")) + attributes(dates)$tzone <- 'UTC' + expect_equal(data$Dates$start, dates) + dates <- c(seq(as.POSIXct("1993-11-03", tz = 'UTC'), + as.POSIXct("1994-06-04", tz = 'UTC'), "d"), + seq(as.POSIXct("1994-11-03", tz = 'UTC'), + as.POSIXct("1995-06-04", tz = 'UTC'), "d")) + attributes(dates)$tzone <- 'UTC' + expect_equal(data$Dates$end, dates) + + obs <- s2dverification::Load(var = 'prlr', exp = NULL, + obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), + sdates = c('19931101', '19941101'), + #paste0(1993:2018, '1101') + nmember = 25,leadtimemin = 1, + leadtimemax = 2, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = 1, nleadtime = NULL) + # The values of observation when loading exp and obs simultaneously corresponds to the second day of the observations in the file: + expect_equal(data$obs[1,1,1,1,,], obs$obs[1,1,1,2,,]) + expect_equal(data$obs[1,1,2,1,,], obs$obs[1,1,2,2,,]) + +} \ No newline at end of file -- GitLab From 1f070a739b8b865ed77ccda5b5500cf924b9c74a Mon Sep 17 00:00:00 2001 From: nperez Date: Fri, 16 Oct 2020 16:08:31 +0200 Subject: [PATCH 06/23] fix end of line --- R/Load.R | 1 - tests/testthat/test-Load.R | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/Load.R b/R/Load.R index 3d015dac..d35697b3 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1859,7 +1859,6 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (storefreq == 'daily') { #startdate <- startdate + 86400 * sampleperiod * length(obs_file_indices) startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) -print(paste("New startdate:", startdate)) year <- as.integer(substr(startdate, 1, 4)) month <- as.integer(substr(startdate, 6, 7)) day <- as.integer(substr(startdate, 9, 10)) diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index 43111a0e..5384e1dd 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -53,4 +53,7 @@ test_that("First time step is correctly interpreted:", { expect_equal(data$obs[1,1,1,1,,], obs$obs[1,1,1,2,,]) expect_equal(data$obs[1,1,2,1,,], obs$obs[1,1,2,2,,]) -} \ No newline at end of file + + + +}) \ No newline at end of file -- GitLab From 6d86c28445063e11bbf667a7ff1dc21294fbe340 Mon Sep 17 00:00:00 2001 From: nperez Date: Fri, 16 Oct 2020 16:15:07 +0200 Subject: [PATCH 07/23] fix function context in tests --- tests/testthat/test-Load.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index 5384e1dd..0e5cf9d2 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -1,4 +1,4 @@ -Context("Testing Load with ECMWF System5c3s daily data") +context("Testing Load with ECMWF System5c3s daily data") test_that("First time step is correctly interpreted:", { data <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), -- GitLab From 482a04a94d3f4b19a9f4f5f939157866c0292214 Mon Sep 17 00:00:00 2001 From: nperez Date: Fri, 16 Oct 2020 18:03:09 +0200 Subject: [PATCH 08/23] New tests and fixes --- R/Load.R | 4 ++-- tests/testthat/test-Load.R | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/R/Load.R b/R/Load.R index d35697b3..1b7edbb3 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1737,7 +1737,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, #(length(leadtimes) - 1)*sampleperiod + 1 - (jleadtime - 1)*sampleperiod >= days_in_month - day + 1 ## Nuria: The first time step in exp could be different from sdate: - if (jleadtime == 1) { + if (jleadtime == 1 & !is.null(exp)) { if (is.null(first_time_step_list[[1]])) { stop("Check 'time' variable in the experimental files ", "since not units or first time step have been found.") @@ -2262,7 +2262,7 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) # Start is a list with as many components as start dates. # Each component is a vector of the initial POSIXct date of each # forecast time step - if (storefreq == 'daily') { + if (storefreq == 'daily' & !is.null(exp)) { origin <- as.numeric(format(exp_first_time_step, "%d")) - 1 } else { origin <- 0 diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index 0e5cf9d2..a067c65b 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -4,7 +4,7 @@ test_that("First time step is correctly interpreted:", { exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') - nmember = 25,leadtimemin = 1, + nmember = 5,leadtimemin = 1, leadtimemax = NULL, storefreq = "daily", sampleperiod = 1, latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, @@ -15,7 +15,8 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - expect_equal(dim(data$mod), c(dataset = 1, member = 25, sdate = 2, ftime = 214, + + expect_equal(dim(data$mod), c(dataset = 1, member = 5, sdate = 2, ftime = 214, lat = 8, lon = 8)) expect_equal(dim(data$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 214, lat = 8, lon = 8)) @@ -34,21 +35,20 @@ test_that("First time step is correctly interpreted:", { attributes(dates)$tzone <- 'UTC' expect_equal(data$Dates$end, dates) - obs <- s2dverification::Load(var = 'prlr', exp = NULL, - obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), - sdates = c('19931101', '19941101'), - #paste0(1993:2018, '1101') - nmember = 25,leadtimemin = 1, - leadtimemax = 2, - storefreq = "daily", sampleperiod = 1, - latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, - output = 'lonlat', nprocs = 1, - method = 'conservative', grid = 'r360x181', - maskmod = vector("list", 15), maskobs = vector("list", 15), - configfile = NULL, varmin = NULL, varmax = NULL, - silent = FALSE, dimnames = NULL, - remapcells = 2, path_glob_permissive = 'partial', - nmemberobs = 1, nleadtime = NULL) + obs <- Load(var = 'prlr', exp = NULL, + obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), + sdates = c('19931101', '19941101'), + nmember = 1, leadtimemin = 1, + leadtimemax = 2, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = 1, nleadtime = NULL) # The values of observation when loading exp and obs simultaneously corresponds to the second day of the observations in the file: expect_equal(data$obs[1,1,1,1,,], obs$obs[1,1,1,2,,]) expect_equal(data$obs[1,1,2,1,,], obs$obs[1,1,2,2,,]) @@ -56,4 +56,4 @@ test_that("First time step is correctly interpreted:", { -}) \ No newline at end of file +}) -- GitLab From e969afd0472ce91b26024fc1a39e1476b12aa98a Mon Sep 17 00:00:00 2001 From: nperez Date: Fri, 16 Oct 2020 18:10:06 +0200 Subject: [PATCH 09/23] gitlab-ci now loads CDO --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b1cf9976..39a31ecb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ build: stage: build script: - module load R -# - module load CDO + - module load CDO - R CMD build --resave-data . - R CMD check --as-cran --no-manual --run-donttest s2dverification_*.tar.gz - R -e 'covr::package_coverage()' -- GitLab From aa78dd0a0049c771725bb65dbfe865838d216a2f Mon Sep 17 00:00:00 2001 From: nperez Date: Mon, 19 Oct 2020 19:48:12 +0200 Subject: [PATCH 10/23] New version working for several experiments --- R/Load.R | 92 +++++++++++++++++++++++++++++--------- tests/testthat/test-Load.R | 52 +++++++++++++++++++++ 2 files changed, 124 insertions(+), 20 deletions(-) diff --git a/R/Load.R b/R/Load.R index 1b7edbb3..14ab6d2f 100644 --- a/R/Load.R +++ b/R/Load.R @@ -840,6 +840,7 @@ #' } #'@import parallel bigmemory methods #'@importFrom stats ts window na.omit +#'@importFrom abind abind #'@export Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, nmemberobs = NULL, nleadtime = NULL, leadtimemin = 1, @@ -1428,6 +1429,21 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (is_file_per_member_exp[jmod]) { replace_values[["MEMBER_NUMBER"]] <- '*' } + if (jsdate == 1) { + work_piecetime <- list(dataset_type = dataset_type, + filename = .ConfigReplaceVariablesInString(quasi_final_path, + replace_values), + namevar = namevar, grid = grid, remap = remap, + remapcells = remapcells, + is_file_per_member = is_file_per_member_exp[jmod], + is_file_per_dataset = FALSE, + lon_limits = c(lonmin, lonmax), + lat_limits = c(latmin, latmax), dimnames = exp[[jmod]][['dimnames']], + single_dataset = single_dataset) + looking_time <- .LoadDataFile(work_piecetime, explore_dims = TRUE, + silent = silent) + first_time_step_list <- c(first_time_step_list, list(looking_time$time_dim)) + } # If the dimensions of the output matrices are still to define, we try to read # the metadata of the data file that corresponds to the current iteration if (dims2define) { @@ -1446,7 +1462,6 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, found_dims <- found_data$dims var_long_name <- found_data$var_long_name units <- found_data$units - first_time_step_list <- c(first_time_step_list, list(found_data$time_dim)) if (!is.null(found_dims)) { # If a file is found, we can define the dimensions of the output arrays. is_2d_var <- found_data$is_2d_var @@ -1533,6 +1548,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, jsdate <- jsdate + 1 } replace_values[extra_vars] <- NULL + #first_dataset_file_found <- FALSE jmod <- jmod + 1 } if (dims2define && length(exp) > 0) { @@ -1573,6 +1589,25 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, } leadtimes <- seq(leadtimemin, leadtimemax, sampleperiod) } + # If there are differences in the first time stamp in exp files: + in_date <- lapply(first_time_step_list, function(x) { + origin <- as.POSIXct( + paste(strsplit(x$time_units, " ")[[1]][c(3,4)], + collapse = " "), tz = 'UTC') + units <- strsplit(x$time_units, " ")[[1]][1] + if (units == 'hours') { + exp_first_time_step <- as.POSIXct( + x$first_time_step_in_file * + 3600, origin = origin, tz = 'UTC') + } else if (units == 'days') { + exp_first_time_step <- as.POSIXct( + x$first_time_step_in_file * + 86400, origin = origin, tz = 'UTC') + } + day <- as.numeric(format(exp_first_time_step, "%d")) + return(day) + }) + exp_first_time_step <- min(unlist(in_date)) # Now we start iterating over observations. We try to find the output matrix # dimensions and we build anyway the work pieces corresponding to the observational @@ -1736,30 +1771,17 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, ## in the dimension of length nleadtimes. Otherwise it must be cut: #(length(leadtimes) - 1)*sampleperiod + 1 - (jleadtime - 1)*sampleperiod >= days_in_month - day + 1 - ## Nuria: The first time step in exp could be different from sdate: + ## The first time step in exp could be different from sdate: if (jleadtime == 1 & !is.null(exp)) { if (is.null(first_time_step_list[[1]])) { stop("Check 'time' variable in the experimental files ", "since not units or first time step have been found.") } else { - origin <- as.POSIXct( - paste(strsplit(first_time_step_list[[1]]$time_units, " ")[[1]][c(3,4)], - collapse = " "), tz = 'UTC') - units <- strsplit(first_time_step_list[[1]]$time_units, " ")[[1]][1] - if (units == 'hours') { - exp_first_time_step <- as.POSIXct( - first_time_step_list[[1]]$first_time_step_in_file * - 3600, origin = origin, tz = 'UTC') - } else if (units == 'days') { - exp_first_time_step <- as.POSIXct( - first_time_step_list[[1]]$first_time_step_in_file * - 86400, origin = origin, tz = 'UTC') + if (exp_first_time_step > 1) { + day <- exp_first_time_step + } } - } - if (as.numeric(format(exp_first_time_step, "%d")) > 1) { - day <- as.numeric(format(exp_first_time_step, "%d")) } - } obs_file_indices <- seq(day, min(days_in_month, (length(leadtimes) - jleadtime) * sampleperiod + day), sampleperiod) } else { @@ -2203,6 +2225,36 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) number_ftime <- dim_obs[["ftime"]] } } + if (any(in_date > 1) & length(in_date) > 1) { + .warning(paste("There is at least one experiment with first timestamp in ", + "file one or more days ahead from the start date. The data ", + "could containg missing values.")) + pos_max <- max(unlist(in_date)) - 1 + empty_slice <- array(NA, c(ftime = 1, dim(mod_data[1,,,1,,]))) + empty_slice <- .aperm2(empty_slice, c(2, 3, 1, 4, 5)) + new_data <- lapply(1:length(in_date), function(x) { + pos <- in_date[[x]] - 1 + res <- mod_data[x,,,,,] + if (pos > 0) { + while (pos > 0) { + res <- abind(empty_slice, res, along = 3) + pos <- pos - 1 + } + } else { + while(pos < pos_max) { + res <- abind(res, empty_slice, along = 3) + pos <- pos + 1 + } + } + return(res) + }) + new_data <- abind(new_data, along = 6) + mod_data <- .aperm2(new_data, c(6,1,2,3,4,5)) + names(dim(mod_data)) <- names(dim_exp) + attr(mod_data, 'dimensions') <- names(dim_exp) + names(dim(mod_data)) <- names(dim_exp) + number_ftime <- dim(mod_data)[["ftime"]] + } if (is.null(latitudes)) { lat <- 0 @@ -2262,8 +2314,8 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) # Start is a list with as many components as start dates. # Each component is a vector of the initial POSIXct date of each # forecast time step - if (storefreq == 'daily' & !is.null(exp)) { - origin <- as.numeric(format(exp_first_time_step, "%d")) - 1 + if (storefreq == 'daily' & !is.null(exp) & exp_first_time_step > 1) { + origin <- exp_first_time_step - 1 } else { origin <- 0 } diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index a067c65b..f5269ab1 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -54,6 +54,58 @@ test_that("First time step is correctly interpreted:", { expect_equal(data$obs[1,1,2,1,,], obs$obs[1,1,2,2,,]) + # Test when 2 observational datasets are requested: + data <- Load(var = 'prlr', + exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), + obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc'), list(name = 'erainterim')), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 5,leadtimemin = 1, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) + expect_equal(data$obs[1,1,1,1,,], obs$obs[1,1,1,2,,]) + expect_equal(data$obs[1,1,2,1,,], obs$obs[1,1,2,2,,]) + eraint <- Load(var = 'prlr', exp = NULL, + obs = list(list(name = 'erainterim')), + sdates = c('19931101', '19941101'), + nmember = 1, leadtimemin = 1, + leadtimemax = 2, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = 1, nleadtime = NULL) + expect_equal(data$obs[2,1,1,1,,], eraint$obs[1,1,1,2,,]) + expect_equal(data$obs[2,1,2,1,,], eraint$obs[1,1,2,2,,]) + + # Test for 2 experimental datasets + data <- Load(var = 'prlr', + exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc"), + list(name = 'ecmwfS4', path = "/esarchive/exp/ecmwf/system4_m1/$STORE_FREQ$/$VAR_NAME$/$VAR_NAME$_$START_DATE$.nc")), + obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 5,leadtimemin = 1, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) }) -- GitLab From f857fe168c563f6949d0fd18d9f6550456a0e367 Mon Sep 17 00:00:00 2001 From: nperez Date: Mon, 19 Oct 2020 20:04:23 +0200 Subject: [PATCH 11/23] automatic documentation updated and extra tests --- NAMESPACE | 1 + man/Composite.Rd | 10 +++++- tests/testthat/test-Load.R | 67 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 4e855789..8561a4f0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -93,6 +93,7 @@ import(methods) import(ncdf4) import(parallel) import(plyr) +importFrom(abind,abind) importFrom(grDevices,bmp) importFrom(grDevices,col2rgb) importFrom(grDevices,colorRampPalette) diff --git a/man/Composite.Rd b/man/Composite.Rd index 4e990020..b9151d82 100644 --- a/man/Composite.Rd +++ b/man/Composite.Rd @@ -4,7 +4,7 @@ \alias{Composite} \title{Computes composites} \usage{ -Composite(var, occ, lag = 0, eno = FALSE, fileout = NULL) +Composite(var, occ, lag = 0, eno = FALSE, K = NULL, fileout = NULL) } \arguments{ \item{var}{3-dimensional array (x, y, time) containing the variable to @@ -23,6 +23,8 @@ use +2 occurrences (i.e., shifted 2 time steps forward). Default is lag = 0.} \item{eno}{For using the effective sample size (TRUE) or the total sample size (FALSE that is the default) for the number of degrees of freedom.} +\item{K}{numeric value indicating the maximum number of composites. By default (NULL), it takes the maximum value provided in occ.} + \item{fileout}{Name of the .sav output file (NULL is the default).} } \value{ @@ -76,6 +78,12 @@ occ2 <- rep(0, 30) occ2[c(3, 9, 15, 21)] <- 1 filled.contour(Composite(var=f1, occ=occ2)$composite[,,1]) + +Example with one missing composite (#3) in occ: +data <- 1 : (4 * 5 * 6) +dim(data) <- c(lon = 4, lat = 5, case = 6) +occ <- c(1, 1, 2, 2, 3, 3) +res <- Composite(data, occ, K = 4) } \author{ History: diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index f5269ab1..6622a7ee 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -108,4 +108,71 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) + + expect_equal(sum(is.na(data$obs)), 0) + expect_equal(sum(is.na(data$mod[1,,,-1,,])), 0) + expect_equal(sum(is.na(data$mod[2,,,-215,,])), 0) + expect_equal(sum(is.na(data$mod[1,,,1,,,])), 640) + expect_equal(sum(is.na(data$mod[2,,,215,,])), 640) + dates <- c(seq(as.POSIXct("1993-11-01", tz = 'UTC'), + as.POSIXct("1994-06-03", tz = 'UTC'), "d"), + seq(as.POSIXct("1994-11-01", tz = 'UTC'), + as.POSIXct("1995-06-03", tz = 'UTC'), "d")) + attributes(dates)$tzone <- 'UTC' + expect_equal(data$Dates$start, dates) + dates <- c(seq(as.POSIXct("1993-11-02", tz = 'UTC'), + as.POSIXct("1994-06-04", tz = 'UTC'), "d"), + seq(as.POSIXct("1994-11-02", tz = 'UTC'), + as.POSIXct("1995-06-04", tz = 'UTC'), "d")) + attributes(dates)$tzone <- 'UTC' + expect_equal(data$Dates$end, dates) + + obs <- Load(var = 'prlr', exp = NULL, + obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), + sdates = c('19931101', '19941101'), + nmember = 1, leadtimemin = 1, + leadtimemax = 215, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = 1, nleadtime = NULL) + expect_equal(obs$obs, data$obs) + + system5 <- Load(var = 'prlr', + exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 5,leadtimemin = 1, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) + + expect_equal(system5$exp, data$exp[1,,,-1,,]) + system4 <- Load(var = 'prlr', + exp = list(list(name = 'ecmwfS4', path = "/esarchive/exp/ecmwf/system4_m1/$STORE_FREQ$/$VAR_NAME$/$VAR_NAME$_$START_DATE$.nc")), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 5,leadtimemin = 1, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) + + expect_equal(system4$exp, data$exp[2,,,-215,,]) }) -- GitLab From 55885301b107398a3cc3015479bab41ff660e65d Mon Sep 17 00:00:00 2001 From: nperez Date: Mon, 19 Oct 2020 20:24:03 +0200 Subject: [PATCH 12/23] test fixed --- tests/testthat/test-Load.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index 6622a7ee..815c376c 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -112,7 +112,7 @@ test_that("First time step is correctly interpreted:", { expect_equal(sum(is.na(data$obs)), 0) expect_equal(sum(is.na(data$mod[1,,,-1,,])), 0) expect_equal(sum(is.na(data$mod[2,,,-215,,])), 0) - expect_equal(sum(is.na(data$mod[1,,,1,,,])), 640) + expect_equal(sum(is.na(data$mod[1,,,1,,])), 640) expect_equal(sum(is.na(data$mod[2,,,215,,])), 640) dates <- c(seq(as.POSIXct("1993-11-01", tz = 'UTC'), as.POSIXct("1994-06-03", tz = 'UTC'), "d"), -- GitLab From 12ee096533a4835ab32d40c9f9a61a294249a62a Mon Sep 17 00:00:00 2001 From: nperez Date: Mon, 19 Oct 2020 20:36:18 +0200 Subject: [PATCH 13/23] Try tests --- tests/testthat/test-Load.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index 815c376c..1ac0d837 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -141,7 +141,9 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = 1, nleadtime = NULL) - expect_equal(obs$obs, data$obs) + print(dim(obs$obs)) + print(dim(data$obs)) + expect_equal(obs$obs, data$obs[,1,,,,,]) system5 <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), -- GitLab From 9302c9eee9b9600bdce6535b5a759f69937e99b9 Mon Sep 17 00:00:00 2001 From: nperez Date: Mon, 19 Oct 2020 20:51:33 +0200 Subject: [PATCH 14/23] try test --- tests/testthat/test-Load.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index 1ac0d837..dcdcca31 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -143,6 +143,8 @@ test_that("First time step is correctly interpreted:", { nmemberobs = 1, nleadtime = NULL) print(dim(obs$obs)) print(dim(data$obs)) + expect_equal(dim(obs$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 215, + lon = 8, lat = 8)) expect_equal(obs$obs, data$obs[,1,,,,,]) system5 <- Load(var = 'prlr', -- GitLab From 84c595784d053fe63af38477f284454a77d3a763 Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 20 Oct 2020 09:53:58 +0200 Subject: [PATCH 15/23] Fix era5 in test --- R/Load.R | 2 ++ tests/testthat/test-Load.R | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/R/Load.R b/R/Load.R index 14ab6d2f..cbeff7a2 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1923,7 +1923,9 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) pointer_var_exp <- pointer_var_obs <- NULL if (!is.null(dim_exp) && (length(unlist(dim_exp)) == length(dim_exp)) && !any(is.na(unlist(dim_exp))) && !any(unlist(dim_exp) == 0)) { + print(dim_exp) var_exp <- big.matrix(nrow = prod(unlist(dim_exp)), ncol = 1) + print(var_exp) pointer_var_exp <- describe(var_exp) } if (!is.null(dim_obs) && (length(unlist(dim_obs)) == length(dim_obs)) && diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index dcdcca31..e0f5733e 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -131,7 +131,7 @@ test_that("First time step is correctly interpreted:", { obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), sdates = c('19931101', '19941101'), nmember = 1, leadtimemin = 1, - leadtimemax = 215, + leadtimemax = 214, storefreq = "daily", sampleperiod = 1, latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, output = 'lonlat', nprocs = 1, -- GitLab From dfc9a5e4751dd9f2021fa90f6f11f3be9df7dfa0 Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 20 Oct 2020 11:00:19 +0200 Subject: [PATCH 16/23] fix when exp is null --- R/Load.R | 37 ++++++++++++++++++------------------- tests/testthat/test-Load.R | 2 +- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/R/Load.R b/R/Load.R index cbeff7a2..c8978d48 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1590,25 +1590,26 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, leadtimes <- seq(leadtimemin, leadtimemax, sampleperiod) } # If there are differences in the first time stamp in exp files: - in_date <- lapply(first_time_step_list, function(x) { - origin <- as.POSIXct( - paste(strsplit(x$time_units, " ")[[1]][c(3,4)], - collapse = " "), tz = 'UTC') - units <- strsplit(x$time_units, " ")[[1]][1] - if (units == 'hours') { - exp_first_time_step <- as.POSIXct( - x$first_time_step_in_file * + if (!is.null(exp)) { + in_date <- lapply(first_time_step_list, function(x) { + origin <- as.POSIXct( + paste(strsplit(x$time_units, " ")[[1]][c(3,4)], + collapse = " "), tz = 'UTC') + units <- strsplit(x$time_units, " ")[[1]][1] + if (units == 'hours') { + exp_first_time_step <- as.POSIXct( + x$first_time_step_in_file * 3600, origin = origin, tz = 'UTC') - } else if (units == 'days') { - exp_first_time_step <- as.POSIXct( - x$first_time_step_in_file * + } else if (units == 'days') { + exp_first_time_step <- as.POSIXct( + x$first_time_step_in_file * 86400, origin = origin, tz = 'UTC') - } - day <- as.numeric(format(exp_first_time_step, "%d")) - return(day) - }) - exp_first_time_step <- min(unlist(in_date)) - + } + day <- as.numeric(format(exp_first_time_step, "%d")) + return(day) + }) + exp_first_time_step <- min(unlist(in_date)) + } # Now we start iterating over observations. We try to find the output matrix # dimensions and we build anyway the work pieces corresponding to the observational # data that time-corresponds the experimental data or the time-steps until the @@ -1923,9 +1924,7 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) pointer_var_exp <- pointer_var_obs <- NULL if (!is.null(dim_exp) && (length(unlist(dim_exp)) == length(dim_exp)) && !any(is.na(unlist(dim_exp))) && !any(unlist(dim_exp) == 0)) { - print(dim_exp) var_exp <- big.matrix(nrow = prod(unlist(dim_exp)), ncol = 1) - print(var_exp) pointer_var_exp <- describe(var_exp) } if (!is.null(dim_obs) && (length(unlist(dim_obs)) == length(dim_obs)) && diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index e0f5733e..dcdcca31 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -131,7 +131,7 @@ test_that("First time step is correctly interpreted:", { obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), sdates = c('19931101', '19941101'), nmember = 1, leadtimemin = 1, - leadtimemax = 214, + leadtimemax = 215, storefreq = "daily", sampleperiod = 1, latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, output = 'lonlat', nprocs = 1, -- GitLab From 5bd19eb89a1c0a67f2cb649355ad9de235b03fb8 Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 20 Oct 2020 13:08:48 +0200 Subject: [PATCH 17/23] version working for two experiments in different order --- R/Load.R | 70 +++++++++++++++++++++----------------- tests/testthat/test-Load.R | 33 +++++++++++++++--- 2 files changed, 68 insertions(+), 35 deletions(-) diff --git a/R/Load.R b/R/Load.R index c8978d48..edb55eab 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1609,6 +1609,10 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, return(day) }) exp_first_time_step <- min(unlist(in_date)) + if (max(unlist(in_date)) > 1) { + leadtimes <- seq(exp_first_time_step, leadtimemax + max(unlist(in_date)) - 1, + sampleperiod) + } } # Now we start iterating over observations. We try to find the output matrix # dimensions and we build anyway the work pieces corresponding to the observational @@ -2226,37 +2230,37 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) number_ftime <- dim_obs[["ftime"]] } } - if (any(in_date > 1) & length(in_date) > 1) { - .warning(paste("There is at least one experiment with first timestamp in ", - "file one or more days ahead from the start date. The data ", - "could containg missing values.")) - pos_max <- max(unlist(in_date)) - 1 - empty_slice <- array(NA, c(ftime = 1, dim(mod_data[1,,,1,,]))) - empty_slice <- .aperm2(empty_slice, c(2, 3, 1, 4, 5)) - new_data <- lapply(1:length(in_date), function(x) { - pos <- in_date[[x]] - 1 - res <- mod_data[x,,,,,] - if (pos > 0) { - while (pos > 0) { - res <- abind(empty_slice, res, along = 3) - pos <- pos - 1 + if (!is.null(exp)) { + if (any(in_date > 1) & length(in_date) > 1 & in_date[[1]] > 1) { + .warning(paste("There is at least one experiment with first timestamp in ", + "file one or more days ahead from the start date. The data ", + "could containg missing values.")) + pos_max <- max(unlist(in_date)) - 1 + empty_slice <- array(NA, c(ftime = 1, dim(mod_data[1,,,1,,]))) + empty_slice <- .aperm2(empty_slice, c(2, 3, 1, 4, 5)) + new_data <- lapply(1:length(in_date), function(x) { + pos <- in_date[[x]] - 1 + res <- mod_data[x,,,,,] + if (pos > 0) { + while (pos > 0) { + res <- abind(empty_slice, res, along = 3) + pos <- pos - 1 + } + } else { + while(pos < pos_max) { + res <- abind(res, empty_slice, along = 3) + pos <- pos + 1 + } } - } else { - while(pos < pos_max) { - res <- abind(res, empty_slice, along = 3) - pos <- pos + 1 - } - } - return(res) - }) - new_data <- abind(new_data, along = 6) - mod_data <- .aperm2(new_data, c(6,1,2,3,4,5)) - names(dim(mod_data)) <- names(dim_exp) - attr(mod_data, 'dimensions') <- names(dim_exp) - names(dim(mod_data)) <- names(dim_exp) - number_ftime <- dim(mod_data)[["ftime"]] + return(res) + }) + new_data <- abind(new_data, along = 6) + mod_data <- .aperm2(new_data, c(6,1,2,3,4,5)) + names(dim(mod_data)) <- names(dim_exp) + attr(mod_data, 'dimensions') <- names(dim_exp) + number_ftime <- dim(mod_data)[["ftime"]] + } } - if (is.null(latitudes)) { lat <- 0 attr(lat, 'cdo_grid_name') <- 'none' @@ -2315,8 +2319,12 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) # Start is a list with as many components as start dates. # Each component is a vector of the initial POSIXct date of each # forecast time step - if (storefreq == 'daily' & !is.null(exp) & exp_first_time_step > 1) { - origin <- exp_first_time_step - 1 + if (!is.null(exp)) { + if (storefreq == 'daily' & exp_first_time_step > 1) { + origin <- exp_first_time_step - 1 + } else { + origin <- 0 + } } else { origin <- 0 } diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index dcdcca31..d6c3ba84 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -141,11 +141,10 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = 1, nleadtime = NULL) - print(dim(obs$obs)) - print(dim(data$obs)) + expect_equal(dim(obs$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 215, - lon = 8, lat = 8)) - expect_equal(obs$obs, data$obs[,1,,,,,]) + lat = 8, lon = 8)) + expect_equal(obs$obs, data$obs) system5 <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), @@ -179,4 +178,30 @@ test_that("First time step is correctly interpreted:", { nmemberobs = NULL, nleadtime = NULL) expect_equal(system4$exp, data$exp[2,,,-215,,]) + expect_equal(system4$Dates$start, data$Dates$start) + + + # Test for 2 experimental datasets oposite order + data <- Load(var = 'prlr', + exp = list(list(name = 'ecmwfS4', path = "/esarchive/exp/ecmwf/system4_m1/$STORE_FREQ$/$VAR_NAME$/$VAR_NAME$_$START_DATE$.nc"), + list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), + obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 5,leadtimemin = 1, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) + expect_equal(dim(data$mod), c(dataset = 2, member = 5, sdate = 2, ftime = 215, + lat = 8, lon = 8)) + expect_equal(sum(is.na(data$mod[1,,,,,])), 0) + expect_equal(data$Dates$start, system4$Dates$start) + + # Test leadtimemin > 1 }) -- GitLab From fdd3af50dce544e80fede696efd429604670a717 Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 20 Oct 2020 15:50:02 +0200 Subject: [PATCH 18/23] New test for leadtimemin 2 --- tests/testthat/test-Load.R | 61 +++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index d6c3ba84..1e83fe13 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -1,5 +1,21 @@ context("Testing Load with ECMWF System5c3s daily data") test_that("First time step is correctly interpreted:", { + system5 <- Load(var = 'prlr', + exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 5,leadtimemin = 1, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) + + data <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), @@ -35,6 +51,8 @@ test_that("First time step is correctly interpreted:", { attributes(dates)$tzone <- 'UTC' expect_equal(data$Dates$end, dates) + expect_equal(data$mod, system5$mod) + obs <- Load(var = 'prlr', exp = NULL, obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), sdates = c('19931101', '19941101'), @@ -73,7 +91,7 @@ test_that("First time step is correctly interpreted:", { expect_equal(data$obs[1,1,1,1,,], obs$obs[1,1,1,2,,]) expect_equal(data$obs[1,1,2,1,,], obs$obs[1,1,2,2,,]) - + expect_equal(system5$mod, data$mod) eraint <- Load(var = 'prlr', exp = NULL, obs = list(list(name = 'erainterim')), sdates = c('19931101', '19941101'), @@ -145,23 +163,8 @@ test_that("First time step is correctly interpreted:", { expect_equal(dim(obs$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 215, lat = 8, lon = 8)) expect_equal(obs$obs, data$obs) - - system5 <- Load(var = 'prlr', - exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), - sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') - nmember = 5,leadtimemin = 1, - leadtimemax = NULL, - storefreq = "daily", sampleperiod = 1, - latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, - output = 'lonlat', nprocs = 1, - method = 'conservative', grid = 'r360x181', - maskmod = vector("list", 15), maskobs = vector("list", 15), - configfile = NULL, varmin = NULL, varmax = NULL, - silent = FALSE, dimnames = NULL, - remapcells = 2, path_glob_permissive = 'partial', - nmemberobs = NULL, nleadtime = NULL) - expect_equal(system5$exp, data$exp[1,,,-1,,]) + system4 <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS4', path = "/esarchive/exp/ecmwf/system4_m1/$STORE_FREQ$/$VAR_NAME$/$VAR_NAME$_$START_DATE$.nc")), sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') @@ -204,4 +207,28 @@ test_that("First time step is correctly interpreted:", { expect_equal(data$Dates$start, system4$Dates$start) # Test leadtimemin > 1 + data <- Load(var = 'prlr', + exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc"), + list(name = 'ecmwfS4', path = "/esarchive/exp/ecmwf/system4_m1/$STORE_FREQ$/$VAR_NAME$/$VAR_NAME$_$START_DATE$.nc")), + obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 5,leadtimemin = 2, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) + system4$mod[1,1,1,1,,] + data$mod[1,1,1,1,,] + s2dv::PlotEquiMap(system5$mod[1,1,1,2,,], lon = system4$lon, lat = system4$lat, + filled.continents = F) + s2dv::PlotEquiMap(data$mod[1,1,1,2,,], lon = data$lon, lat = data$lat, + filled.continents = F) + expect_equal(system4$mod[1,1,1,2:214,,], data$mod[2,1,1,1:213,,]) + expect_equal(system5$mod[1,1,1,2:214,,], data$mod[1,1,1,2:214,,]) }) -- GitLab From 8f2dc4f3cfe406632a18fb45dbd3db6b80ffccd6 Mon Sep 17 00:00:00 2001 From: nperez Date: Tue, 20 Oct 2020 18:51:50 +0200 Subject: [PATCH 19/23] Remove unnecessary lines --- tests/testthat/test-Load.R | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index 1e83fe13..57f62b0a 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -223,12 +223,6 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - system4$mod[1,1,1,1,,] - data$mod[1,1,1,1,,] - s2dv::PlotEquiMap(system5$mod[1,1,1,2,,], lon = system4$lon, lat = system4$lat, - filled.continents = F) - s2dv::PlotEquiMap(data$mod[1,1,1,2,,], lon = data$lon, lat = data$lat, - filled.continents = F) expect_equal(system4$mod[1,1,1,2:214,,], data$mod[2,1,1,1:213,,]) expect_equal(system5$mod[1,1,1,2:214,,], data$mod[1,1,1,2:214,,]) }) -- GitLab From 6635fde8783ff9175dd8a79279114d7361805ddd Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 21 Oct 2020 12:34:47 +0200 Subject: [PATCH 20/23] run devtools document --- DESCRIPTION | 2 +- man/ACC.Rd | 21 +++++--- man/Alpha.Rd | 1 - man/AnimateMap.Rd | 33 +++++++++--- man/Ano.Rd | 1 - man/Ano_CrossValid.Rd | 1 - man/ArrayToNetCDF.Rd | 1 - man/BrierScore.Rd | 13 +++-- man/CDORemap.Rd | 14 +++-- man/Clim.Rd | 1 - man/Cluster.Rd | 9 ++-- man/ColorBar.Rd | 32 +++++++++--- man/Composite.Rd | 1 - man/ConfigApplyMatchingEntries.Rd | 21 +++++--- man/ConfigEditDefinition.Rd | 9 ++-- man/ConfigEditEntry.Rd | 53 +++++++++++++------ man/ConfigFileOpen.Rd | 13 +++-- man/ConfigShowSimilarEntries.Rd | 27 ++++++---- man/ConfigShowTable.Rd | 13 +++-- man/Consist_Trend.Rd | 1 - man/Corr.Rd | 21 +++++--- man/EOF.Rd | 7 ++- man/Enlarge.Rd | 1 - man/Eno.Rd | 1 - man/EnoNew.Rd | 11 ++-- man/Filter.Rd | 1 - man/FitAcfCoef.Rd | 1 - man/FitAutocor.Rd | 1 - man/GenSeries.Rd | 1 - man/Histo2Hindcast.Rd | 1 - man/IniListDims.Rd | 1 - man/InsertDim.Rd | 1 - man/LeapYear.Rd | 1 - man/Load.Rd | 40 ++++++++++---- man/Mean1Dim.Rd | 1 - man/MeanListDim.Rd | 1 - man/NAO.Rd | 21 +++++--- man/Plot2VarsVsLTime.Rd | 31 ++++++++--- man/PlotACC.Rd | 27 +++++++--- man/PlotAno.Rd | 31 ++++++++--- man/PlotBoxWhisker.Rd | 29 ++++++++--- man/PlotClim.Rd | 26 +++++++--- man/PlotEquiMap.Rd | 86 ++++++++++++++++++++++++------- man/PlotLayout.Rd | 73 ++++++++++++++++++-------- man/PlotMatrix.Rd | 29 ++++++++--- man/PlotSection.Rd | 25 +++++++-- man/PlotStereoMap.Rd | 61 +++++++++++++++++----- man/PlotVsLTime.Rd | 30 ++++++++--- man/ProbBins.Rd | 12 +++-- man/ProjectField.Rd | 7 ++- man/RMS.Rd | 15 ++++-- man/RMSSS.Rd | 3 +- man/RatioRMS.Rd | 3 +- man/RatioSDRMS.Rd | 3 +- man/Regression.Rd | 1 - man/SVD.Rd | 12 +++-- man/Season.Rd | 1 - man/SelIndices.Rd | 1 - man/Smoothing.Rd | 1 - man/Spectrum.Rd | 1 - man/Spread.Rd | 1 - man/StatSeasAtlHurr.Rd | 9 ++-- man/Subset.Rd | 1 - man/ToyModel.Rd | 15 ++++-- man/Trend.Rd | 3 +- man/UltimateBrier.Rd | 15 ++++-- man/clim.palette.Rd | 3 +- man/s2dverification.Rd | 9 +++- man/sampleDepthData.Rd | 1 - man/sampleMap.Rd | 1 - man/sampleTimeSeries.Rd | 1 - 71 files changed, 647 insertions(+), 299 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0045265c..1f0a201e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,4 +60,4 @@ BugReports: https://earth.bsc.es/gitlab/es/s2dverification/issues LazyData: true SystemRequirements: cdo Encoding: UTF-8 -RoxygenNote: 5.0.0 +RoxygenNote: 7.0.1 diff --git a/man/ACC.Rd b/man/ACC.Rd index e3db377f..61b286f2 100644 --- a/man/ACC.Rd +++ b/man/ACC.Rd @@ -4,8 +4,16 @@ \alias{ACC} \title{Computes Anomaly Correlation Coefficient} \usage{ -ACC(var_exp, var_obs, lon = NULL, lat = NULL, lonlatbox = NULL, - conf = TRUE, conftype = "parametric", siglev = 0.95) +ACC( + var_exp, + var_obs, + lon = NULL, + lat = NULL, + lonlatbox = NULL, + conf = TRUE, + conftype = "parametric", + siglev = 0.95 +) } \arguments{ \item{var_exp}{Array of experimental anomalies with dimensions: @@ -97,6 +105,10 @@ acc <- ACC(Mean1Dim(ano_exp, 2), Mean1Dim(ano_obs, 2)) PlotACC(acc$ACC, startDates) } } +\references{ +Joliffe and Stephenson (2012). Forecast Verification: A + Practitioner's Guide in Atmospheric Science. Wiley-Blackwell. +} \author{ History:\cr 0.1 - 2013-08 (V. Guemas, \email{virginie.guemas@bsc.es}) - Original code\cr @@ -107,9 +119,4 @@ History:\cr 1.3.1 - 2014-09 (C. Prodhomme, \email{chloe.prodhomme@bsc.es}) - Add comments and minor style changes\cr 1.3.2 - 2015-02 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Fixed ACC documentation and examples } -\references{ -Joliffe and Stephenson (2012). Forecast Verification: A - Practitioner's Guide in Atmospheric Science. Wiley-Blackwell. -} \keyword{datagen} - diff --git a/man/Alpha.Rd b/man/Alpha.Rd index c2350b2a..26596dc2 100644 --- a/man/Alpha.Rd +++ b/man/Alpha.Rd @@ -42,4 +42,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/AnimateMap.Rd b/man/AnimateMap.Rd index 96074b01..5dc756da 100644 --- a/man/AnimateMap.Rd +++ b/man/AnimateMap.Rd @@ -4,13 +4,33 @@ \alias{AnimateMap} \title{Animate Maps of Forecast/Observed Values or Scores Over Forecast Time} \usage{ -AnimateMap(var, lon, lat, toptitle = rep("", 11), sizetit = 1, units = "", - monini = 1, freq = 12, msk95lev = FALSE, brks = NULL, cols = NULL, - filled.continents = FALSE, lonmin = 0, lonmax = 360, latmin = -90, - latmax = 90, intlon = 20, intlat = 30, drawleg = TRUE, - subsampleg = 1, colNA = "white", equi = TRUE, +AnimateMap( + var, + lon, + lat, + toptitle = rep("", 11), + sizetit = 1, + units = "", + monini = 1, + freq = 12, + msk95lev = FALSE, + brks = NULL, + cols = NULL, + filled.continents = FALSE, + lonmin = 0, + lonmax = 360, + latmin = -90, + latmax = 90, + intlon = 20, + intlat = 30, + drawleg = TRUE, + subsampleg = 1, + colNA = "white", + equi = TRUE, fileout = c("output1_animvsltime.gif", "output2_animvsltime.gif", - "output3_animvsltime.gif"), ...) + "output3_animvsltime.gif"), + ... +) } \arguments{ \item{var}{Matrix of dimensions (nltime, nlat, nlon) or @@ -194,4 +214,3 @@ History:\cr 1.2 - 2015-05 (V. Guemas, \email{virginie.guemas@bsc.es}) - Use of PlotEquiMap and PlotStereoMap } \keyword{dynamic} - diff --git a/man/Ano.Rd b/man/Ano.Rd index 6143be88..6461ec77 100644 --- a/man/Ano.Rd +++ b/man/Ano.Rd @@ -49,4 +49,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to R CRAN } \keyword{datagen} - diff --git a/man/Ano_CrossValid.Rd b/man/Ano_CrossValid.Rd index 85d1badb..70017492 100644 --- a/man/Ano_CrossValid.Rd +++ b/man/Ano_CrossValid.Rd @@ -43,4 +43,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/ArrayToNetCDF.Rd b/man/ArrayToNetCDF.Rd index 77cbfaf8..4e05d829 100644 --- a/man/ArrayToNetCDF.Rd +++ b/man/ArrayToNetCDF.Rd @@ -238,4 +238,3 @@ History:\cr 0.0 - 2017-01 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Original code. } \keyword{datagen} - diff --git a/man/BrierScore.Rd b/man/BrierScore.Rd index 5094987c..e802dc35 100644 --- a/man/BrierScore.Rd +++ b/man/BrierScore.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/BrierScore.R \name{BrierScore} -\alias{.BrierScore} \alias{BrierScore} +\alias{.BrierScore} \title{Compute Brier Score And Its Decomposition And Brier Skill Score} \usage{ BrierScore(obs, pred, thresholds = seq(0, 1, 0.1)) @@ -85,11 +85,6 @@ bs2 <- veriApply("BrierScore2", bins_ano_exp, Mean1Dim(bins_ano_ob,s 3), tdim = 2, ensdim = 3) } } -\author{ -History:\cr - 0.1 - 2012-04 (L. Rodrigues, \email{lrodrigues@ic3.cat}) - Original code\cr - 0.2 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() -} \references{ Wilks (2006) Statistical Methods in the Atmospheric Sciences.\cr Stephenson et al. (2008). Two extra components in the Brier score decomposition. @@ -97,5 +92,9 @@ Stephenson et al. (2008). Two extra components in the Brier score decomposition. Ferro and Fricker (2012). A bias-corrected decomposition of the BS. Quarterly Journal of the Royal Meteorological Society, DOI: 10.1002/qj.1924. } +\author{ +History:\cr + 0.1 - 2012-04 (L. Rodrigues, \email{lrodrigues@ic3.cat}) - Original code\cr + 0.2 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() +} \keyword{datagen} - diff --git a/man/CDORemap.Rd b/man/CDORemap.Rd index b2d5eaa3..bae7aa55 100644 --- a/man/CDORemap.Rd +++ b/man/CDORemap.Rd @@ -4,8 +4,17 @@ \alias{CDORemap} \title{Interpolates arrays with longitude and latitude dimensions using CDO} \usage{ -CDORemap(data_array = NULL, lons, lats, grid, method, avoid_writes = TRUE, - crop = TRUE, force_remap = FALSE, write_dir = tempdir()) +CDORemap( + data_array = NULL, + lons, + lats, + grid, + method, + avoid_writes = TRUE, + crop = TRUE, + force_remap = FALSE, + write_dir = tempdir() +) } \arguments{ \item{data_array}{Multidimensional numeric array to be interpolated. If @@ -226,4 +235,3 @@ History:\cr 0.0 - 2017-01 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Original code. } \keyword{datagen} - diff --git a/man/Clim.Rd b/man/Clim.Rd index 1ef5e3da..69f7ceb0 100644 --- a/man/Clim.Rd +++ b/man/Clim.Rd @@ -63,4 +63,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to R CRAN } \keyword{datagen} - diff --git a/man/Cluster.Rd b/man/Cluster.Rd index 70f22347..782c37a4 100644 --- a/man/Cluster.Rd +++ b/man/Cluster.Rd @@ -92,7 +92,7 @@ for (i1 in c1) { a1[i1, ] <- x1 + rnorm(4, mean = mean1, sd = sd1) } -c1p5 <- c0[!(c0 \\\%in\\\% c1)] +c1p5 <- c0[!(c0 \\%in\\% c1)] c2 <- c1p5[seq(1, length(c1p5), 2)] x2 <- c(2, 2, 4, 4) for (i2 in c2) { @@ -114,12 +114,11 @@ res2 <- Cluster(var = a1, weights = array(1, dim = dim(a1)[2])) print(res2$cluster) print(res2$centers) } +\references{ +Wilks, 2011, Statistical Methods in the Atmospheric Sciences, 3rd ed., Elsevire, pp 676. +} \author{ History:\cr 1.0 # 2014-10 (N.S. Fuckar, \email{neven.fuckar@bsc.es}) - Original code } -\references{ -Wilks, 2011, Statistical Methods in the Atmospheric Sciences, 3rd ed., Elsevire, pp 676. -} \keyword{datagen} - diff --git a/man/ColorBar.Rd b/man/ColorBar.Rd index 71da02be..98c99679 100644 --- a/man/ColorBar.Rd +++ b/man/ColorBar.Rd @@ -4,13 +4,30 @@ \alias{ColorBar} \title{Draws a Color Bar} \usage{ -ColorBar(brks = NULL, cols = NULL, vertical = TRUE, subsampleg = NULL, - bar_limits = NULL, var_limits = NULL, triangle_ends = NULL, - col_inf = NULL, col_sup = NULL, color_fun = clim.palette(), - plot = TRUE, draw_ticks = TRUE, draw_separators = FALSE, - triangle_ends_scale = 1, extra_labels = NULL, title = NULL, - title_scale = 1, label_scale = 1, tick_scale = 1, - extra_margin = rep(0, 4), label_digits = 4, ...) +ColorBar( + brks = NULL, + cols = NULL, + vertical = TRUE, + subsampleg = NULL, + bar_limits = NULL, + var_limits = NULL, + triangle_ends = NULL, + col_inf = NULL, + col_sup = NULL, + color_fun = clim.palette(), + plot = TRUE, + draw_ticks = TRUE, + draw_separators = FALSE, + triangle_ends_scale = 1, + extra_labels = NULL, + title = NULL, + title_scale = 1, + label_scale = 1, + tick_scale = 1, + extra_margin = rep(0, 4), + label_digits = 4, + ... +) } \arguments{ \item{brks}{Can be provided in two formats: @@ -185,4 +202,3 @@ History:\cr (V. Torralba, \email{veronica.torralba@bsc.es}) } \keyword{hplot} - diff --git a/man/Composite.Rd b/man/Composite.Rd index b9151d82..f0ce4692 100644 --- a/man/Composite.Rd +++ b/man/Composite.Rd @@ -90,4 +90,3 @@ History: 0.1 # 2014-08 (N.S. Fuckar, \email{neven.fuckar@bsc.es}) # Original code } \keyword{datagen} - diff --git a/man/ConfigApplyMatchingEntries.Rd b/man/ConfigApplyMatchingEntries.Rd index 626e385d..74abb167 100644 --- a/man/ConfigApplyMatchingEntries.Rd +++ b/man/ConfigApplyMatchingEntries.Rd @@ -4,8 +4,14 @@ \alias{ConfigApplyMatchingEntries} \title{Apply Matching Entries To Dataset Name And Variable Name To Find Related Info} \usage{ -ConfigApplyMatchingEntries(configuration, var, exp = NULL, obs = NULL, - show_entries = FALSE, show_result = TRUE) +ConfigApplyMatchingEntries( + configuration, + var, + exp = NULL, + obs = NULL, + show_entries = FALSE, + show_result = TRUE +) } \arguments{ \item{configuration}{Configuration object obtained from ConfigFileOpen() @@ -63,15 +69,14 @@ configuration <- ConfigEditEntry(configuration, "experiments", 1, match_info <- ConfigApplyMatchingEntries(configuration, 'tas', exp = c('ExampleExperiment2'), show_result = TRUE) } -\author{ -History:\cr - 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr - 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage types -} \seealso{ ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable } +\author{ +History:\cr + 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr + 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage types +} \keyword{datagen} - diff --git a/man/ConfigEditDefinition.Rd b/man/ConfigEditDefinition.Rd index b1f7c882..a25a9c3b 100644 --- a/man/ConfigEditDefinition.Rd +++ b/man/ConfigEditDefinition.Rd @@ -52,14 +52,13 @@ match_info <- ConfigApplyMatchingEntries(configuration, 'tas', exp = c('ExampleExperiment2'), show_result = TRUE) } -\author{ -History: - 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version -} \seealso{ [ConfigApplyMatchingEntries()], [ConfigEditDefinition()], [ConfigEditEntry()], [ConfigFileOpen()], [ConfigShowSimilarEntries()], [ConfigShowTable()]. } +\author{ +History: + 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version +} \keyword{datagen} - diff --git a/man/ConfigEditEntry.Rd b/man/ConfigEditEntry.Rd index 83973231..2b13d0b9 100644 --- a/man/ConfigEditEntry.Rd +++ b/man/ConfigEditEntry.Rd @@ -1,22 +1,46 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/ConfigEditEntry.R \name{ConfigEditEntry} -\alias{ConfigAddEntry} \alias{ConfigEditEntry} +\alias{ConfigAddEntry} \alias{ConfigRemoveEntry} \title{Add, Remove Or Edit Entries In The Configuration} \usage{ -ConfigEditEntry(configuration, dataset_type, position, dataset_name = NULL, - var_name = NULL, main_path = NULL, file_path = NULL, - nc_var_name = NULL, suffix = NULL, varmin = NULL, varmax = NULL) +ConfigEditEntry( + configuration, + dataset_type, + position, + dataset_name = NULL, + var_name = NULL, + main_path = NULL, + file_path = NULL, + nc_var_name = NULL, + suffix = NULL, + varmin = NULL, + varmax = NULL +) -ConfigAddEntry(configuration, dataset_type, position = "last", - dataset_name = ".*", var_name = ".*", main_path = "*", - file_path = "*", nc_var_name = "*", suffix = "*", varmin = "*", - varmax = "*") +ConfigAddEntry( + configuration, + dataset_type, + position = "last", + dataset_name = ".*", + var_name = ".*", + main_path = "*", + file_path = "*", + nc_var_name = "*", + suffix = "*", + varmin = "*", + varmax = "*" +) -ConfigRemoveEntry(configuration, dataset_type, dataset_name = NULL, - var_name = NULL, position = NULL) +ConfigRemoveEntry( + configuration, + dataset_type, + dataset_name = NULL, + var_name = NULL, + position = NULL +) } \arguments{ \item{configuration}{Configuration object obtained via ConfigFileOpen() @@ -95,14 +119,13 @@ ConfigShowTable(configuration, "experiments") # Save the configuration ConfigFileSave(configuration, config_file, confirm = FALSE) } +\seealso{ +ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, + ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable +} \author{ History:\cr 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats } -\seealso{ -ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, - ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable -} \keyword{datagen} - diff --git a/man/ConfigFileOpen.Rd b/man/ConfigFileOpen.Rd index cff7427e..372ad386 100644 --- a/man/ConfigFileOpen.Rd +++ b/man/ConfigFileOpen.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/ConfigFileOpen.R \name{ConfigFileOpen} -\alias{ConfigFileCreate} \alias{ConfigFileOpen} +\alias{ConfigFileCreate} \alias{ConfigFileSave} \title{Functions To Create Open And Save Configuration File} \usage{ @@ -185,11 +185,6 @@ match_info <- ConfigApplyMatchingEntries(configuration, 'tas', # Finally save the configuration file. ConfigFileSave(configuration, config_file, confirm = FALSE) -} -\author{ -History: - 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version - 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats } \references{ [1] \url{https://stat.ethz.ch/R-manual/R-devel/library/base/html/regex.html}\cr @@ -199,5 +194,9 @@ History: ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable } +\author{ +History: + 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version + 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats +} \keyword{datagen} - diff --git a/man/ConfigShowSimilarEntries.Rd b/man/ConfigShowSimilarEntries.Rd index 312da795..154bcb28 100644 --- a/man/ConfigShowSimilarEntries.Rd +++ b/man/ConfigShowSimilarEntries.Rd @@ -4,10 +4,18 @@ \alias{ConfigShowSimilarEntries} \title{Find Similar Entries In Tables Of Datasets} \usage{ -ConfigShowSimilarEntries(configuration, dataset_name = NULL, - var_name = NULL, main_path = NULL, file_path = NULL, - nc_var_name = NULL, suffix = NULL, varmin = NULL, varmax = NULL, - n_results = 10) +ConfigShowSimilarEntries( + configuration, + dataset_name = NULL, + var_name = NULL, + main_path = NULL, + file_path = NULL, + nc_var_name = NULL, + suffix = NULL, + varmin = NULL, + varmax = NULL, + n_results = 10 +) } \arguments{ \item{configuration}{Configuration object obtained either from @@ -71,11 +79,6 @@ ConfigShowSimilarEntries(configuration, dataset_name = "Exper", var_name = "Vari") } -\author{ -History:\cr - 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr - 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats -} \references{ [1] Simon White, string seamness: \url{http://www.catalysoft.com/articles/StrikeAMatch.html} @@ -84,5 +87,9 @@ History:\cr ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable } +\author{ +History:\cr + 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr + 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats +} \keyword{datagen} - diff --git a/man/ConfigShowTable.Rd b/man/ConfigShowTable.Rd index a06b643e..56649156 100644 --- a/man/ConfigShowTable.Rd +++ b/man/ConfigShowTable.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/ConfigShowTable.R \name{ConfigShowTable} -\alias{ConfigShowDefinitions} \alias{ConfigShowTable} +\alias{ConfigShowDefinitions} \title{Show Configuration Tables And Definitions} \usage{ ConfigShowTable(configuration, dataset_type, line_numbers = NULL) @@ -48,16 +48,15 @@ configuration <- ConfigEditEntry(configuration, "experiments", 1, ConfigShowTable(configuration, 'experiments') ConfigShowDefinitions(configuration) -} -\author{ -History:\cr - 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr - 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats } \seealso{ [ConfigApplyMatchingEntries()], [ConfigEditDefinition()], [ConfigEditEntry()], [ConfigFileOpen()], [ConfigShowSimilarEntries()], [ConfigShowTable()]. } +\author{ +History:\cr + 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr + 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats +} \keyword{datagen} - diff --git a/man/Consist_Trend.Rd b/man/Consist_Trend.Rd index d067dcd7..124e5e3d 100644 --- a/man/Consist_Trend.Rd +++ b/man/Consist_Trend.Rd @@ -80,4 +80,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to R CRAN } \keyword{datagen} - diff --git a/man/Corr.Rd b/man/Corr.Rd index e311813d..11a40d79 100644 --- a/man/Corr.Rd +++ b/man/Corr.Rd @@ -1,16 +1,24 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/Corr.R \name{Corr} -\alias{.Corr} \alias{Corr} +\alias{.Corr} \title{Computes the correlation coefficient between an array of forecasts and their corresponding observations} \usage{ -Corr(var_exp, var_obs, posloop = 1, poscor = 2, compROW = NULL, - limits = NULL, siglev = 0.95, method = "pearson", conf = TRUE, - pval = TRUE) +Corr( + var_exp, + var_obs, + posloop = 1, + poscor = 2, + compROW = NULL, + limits = NULL, + siglev = 0.95, + method = "pearson", + conf = TRUE, + pval = TRUE +) -.Corr(exp, obs, siglev = 0.95, method = "pearson", conf = TRUE, - pval = TRUE) +.Corr(exp, obs, siglev = 0.95, method = "pearson", conf = TRUE, pval = TRUE) } \arguments{ \item{var_exp}{Array of experimental data.} @@ -131,4 +139,3 @@ History:\cr 1.3 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} - diff --git a/man/EOF.Rd b/man/EOF.Rd index bd0b31e4..25934f52 100644 --- a/man/EOF.Rd +++ b/man/EOF.Rd @@ -82,6 +82,9 @@ ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) eof <- EOF(Mean1Dim(ano$ano_exp, 2)[1, , 1, , ], sampleData$lon, sampleData$lat) PlotEquiMap(eof$EOFs[1, , ], sampleData$lon, sampleData$lat) +} +\seealso{ +ProjectField, NAO, PlotBoxWhisker } \author{ History:\cr @@ -115,8 +118,4 @@ weighted by cos(lat)\cr EOF * PC\cr 1.0 - 2016-03 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatting to R CRAN } -\seealso{ -ProjectField, NAO, PlotBoxWhisker -} \keyword{datagen} - diff --git a/man/Enlarge.Rd b/man/Enlarge.Rd index 76f5cccf..47aed320 100644 --- a/man/Enlarge.Rd +++ b/man/Enlarge.Rd @@ -29,4 +29,3 @@ History:\cr 1.1 - 2015-03 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Improved\cr } \keyword{datagen} - diff --git a/man/Eno.Rd b/man/Eno.Rd index ba4f2088..ea70bc5e 100644 --- a/man/Eno.Rd +++ b/man/Eno.Rd @@ -60,4 +60,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens at ic3.cat}) - Formatting to R CRAN } \keyword{datagen} - diff --git a/man/EnoNew.Rd b/man/EnoNew.Rd index cc2de760..32bf55fd 100644 --- a/man/EnoNew.Rd +++ b/man/EnoNew.Rd @@ -55,16 +55,15 @@ sampleData <- s2dverification:::.LoadSampleData('tos', c('experiment'), eno <- EnoNew(sampleData$mod[1, 1, , 1, 2, 3]) print(eno) -} -\author{ -History:\cr -0.1 - 2012-06 (V. Guemas, \email{virginie.guemas at ic3.cat}) - Original code\cr -1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens at ic3.cat}) - Formatting to CRAN } \references{ Guemas V, Auger L, Doblas-Reyes FJ, Rust H, Ribes A, 2014, Dependencies in Statistical Hypothesis Tests for Climate Time Series. Bulletin of the American Meteorological Society, 95 (11), 1666-1667. } +\author{ +History:\cr +0.1 - 2012-06 (V. Guemas, \email{virginie.guemas at ic3.cat}) - Original code\cr +1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens at ic3.cat}) - Formatting to CRAN +} \keyword{datagen} - diff --git a/man/Filter.Rd b/man/Filter.Rd index 3e40f105..21807f5d 100644 --- a/man/Filter.Rd +++ b/man/Filter.Rd @@ -48,4 +48,3 @@ History:\cr 1.0 - 2012-02 (N. Manubens, \email{nicolau.manubens at ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/FitAcfCoef.Rd b/man/FitAcfCoef.Rd index 6ca51444..6de266e5 100644 --- a/man/FitAcfCoef.Rd +++ b/man/FitAcfCoef.Rd @@ -38,4 +38,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/FitAutocor.Rd b/man/FitAutocor.Rd index ff3ab943..2d623603 100644 --- a/man/FitAutocor.Rd +++ b/man/FitAutocor.Rd @@ -35,4 +35,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/GenSeries.Rd b/man/GenSeries.Rd index 9a49ed9d..549b259e 100644 --- a/man/GenSeries.Rd +++ b/man/GenSeries.Rd @@ -34,4 +34,3 @@ History:\cr 1.0 - 2012-04 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/Histo2Hindcast.Rd b/man/Histo2Hindcast.Rd index 7000628a..0f9bd18b 100644 --- a/man/Histo2Hindcast.Rd +++ b/man/Histo2Hindcast.Rd @@ -79,4 +79,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/IniListDims.Rd b/man/IniListDims.Rd index 422a4c76..71369945 100644 --- a/man/IniListDims.Rd +++ b/man/IniListDims.Rd @@ -39,4 +39,3 @@ History:\cr 1.1 - 2015-03 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Improved } \keyword{datagen} - diff --git a/man/InsertDim.Rd b/man/InsertDim.Rd index 4cdc5377..e7e50d14 100644 --- a/man/InsertDim.Rd +++ b/man/InsertDim.Rd @@ -34,4 +34,3 @@ History:\cr 1.1 - 2015-03 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Improvements } \keyword{datagen} - diff --git a/man/LeapYear.Rd b/man/LeapYear.Rd index 12b02b49..7504a27e 100644 --- a/man/LeapYear.Rd +++ b/man/LeapYear.Rd @@ -27,4 +27,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/Load.Rd b/man/Load.Rd index c721e613..6554f58b 100644 --- a/man/Load.Rd +++ b/man/Load.Rd @@ -4,15 +4,36 @@ \alias{Load} \title{Loads Experimental And Observational Data} \usage{ -Load(var, exp = NULL, obs = NULL, sdates, nmember = NULL, - nmemberobs = NULL, nleadtime = NULL, leadtimemin = 1, - leadtimemax = NULL, storefreq = "monthly", sampleperiod = 1, - lonmin = 0, lonmax = 360, latmin = -90, latmax = 90, - output = "areave", method = "conservative", grid = NULL, - maskmod = vector("list", 15), maskobs = vector("list", 15), - configfile = NULL, varmin = NULL, varmax = NULL, silent = FALSE, - nprocs = NULL, dimnames = NULL, remapcells = 2, - path_glob_permissive = "partial") +Load( + var, + exp = NULL, + obs = NULL, + sdates, + nmember = NULL, + nmemberobs = NULL, + nleadtime = NULL, + leadtimemin = 1, + leadtimemax = NULL, + storefreq = "monthly", + sampleperiod = 1, + lonmin = 0, + lonmax = 360, + latmin = -90, + latmax = 90, + output = "areave", + method = "conservative", + grid = NULL, + maskmod = vector("list", 15), + maskobs = vector("list", 15), + configfile = NULL, + varmin = NULL, + varmax = NULL, + silent = FALSE, + nprocs = NULL, + dimnames = NULL, + remapcells = 2, + path_glob_permissive = "partial" +) } \arguments{ \item{var}{Short name of the variable to load. It should coincide with the @@ -883,4 +904,3 @@ History:\cr 1.4 - 2016-01 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Added subsetting capabilities } \keyword{datagen} - diff --git a/man/Mean1Dim.Rd b/man/Mean1Dim.Rd index 613fc468..6b45e1a7 100644 --- a/man/Mean1Dim.Rd +++ b/man/Mean1Dim.Rd @@ -36,4 +36,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to R CRAN } \keyword{datagen} - diff --git a/man/MeanListDim.Rd b/man/MeanListDim.Rd index 98e07c8e..2fdf8981 100644 --- a/man/MeanListDim.Rd +++ b/man/MeanListDim.Rd @@ -33,4 +33,3 @@ History:\cr 1.1 - 2015-03 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Improved memory usage } \keyword{datagen} - diff --git a/man/NAO.Rd b/man/NAO.Rd index 24d58830..34f36339 100644 --- a/man/NAO.Rd +++ b/man/NAO.Rd @@ -4,8 +4,14 @@ \alias{NAO} \title{Computes the North Atlantic Oscillation (NAO) Index} \usage{ -NAO(ano_exp = NULL, ano_obs = NULL, lon, lat, ftime_average = 2:4, - obsproj = TRUE) +NAO( + ano_exp = NULL, + ano_obs = NULL, + lon, + lat, + ftime_average = 2:4, + obsproj = TRUE +) } \arguments{ \item{ano_exp}{Array of North Atlantic SLP (20N-80N, 80W-40E) forecast @@ -113,6 +119,11 @@ PlotBoxWhisker(nao$NAO_exp, nao$NAO_obs, "NAO index, DJF", "NAO index (PC1) TOS" } } +\references{ +Doblas-Reyes, F.J., Pavan, V. and Stephenson, D. (2003). The skill of + multi-model seasonal forecasts of the wintertime North Atlantic Oscillation. + Climate Dynamics, 21, 501-514. DOI: 10.1007/s00382-003-0350-4 +} \author{ History:\cr 0.1 - 2013-08 (F. Lienert, \email{flienert@ic3.cat}) - Original code\cr @@ -127,10 +138,4 @@ History:\cr 1.0 - 2016-03 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatted to CRAN } -\references{ -Doblas-Reyes, F.J., Pavan, V. and Stephenson, D. (2003). The skill of - multi-model seasonal forecasts of the wintertime North Atlantic Oscillation. - Climate Dynamics, 21, 501-514. DOI: 10.1007/s00382-003-0350-4 -} \keyword{datagen} - diff --git a/man/Plot2VarsVsLTime.Rd b/man/Plot2VarsVsLTime.Rd index 8ba44e4e..11af98a7 100644 --- a/man/Plot2VarsVsLTime.Rd +++ b/man/Plot2VarsVsLTime.Rd @@ -4,12 +4,30 @@ \alias{Plot2VarsVsLTime} \title{Plot Two Scores With Confidence Intervals In A Common Plot} \usage{ -Plot2VarsVsLTime(var1, var2, toptitle = "", ytitle = "", monini = 1, - freq = 12, nticks = NULL, limits = NULL, listexp = c("exp1", "exp2", - "exp3"), listvars = c("var1", "var2"), biglab = FALSE, hlines = NULL, - leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, - fileout = "output_plot2varsvsltime.eps", width = 8, height = 5, - size_units = "in", res = 100, ...) +Plot2VarsVsLTime( + var1, + var2, + toptitle = "", + ytitle = "", + monini = 1, + freq = 12, + nticks = NULL, + limits = NULL, + listexp = c("exp1", "exp2", "exp3"), + listvars = c("var1", "var2"), + biglab = FALSE, + hlines = NULL, + leg = TRUE, + siglev = FALSE, + sizetit = 1, + show_conf = TRUE, + fileout = "output_plot2varsvsltime.eps", + width = 8, + height = 5, + size_units = "in", + res = 100, + ... +) } \arguments{ \item{var1}{Matrix of dimensions (nexp/nmod, nltime).} @@ -120,4 +138,3 @@ History:\cr - Original code } \keyword{dynamic} - diff --git a/man/PlotACC.Rd b/man/PlotACC.Rd index fc66200a..289fbf17 100644 --- a/man/PlotACC.Rd +++ b/man/PlotACC.Rd @@ -4,11 +4,27 @@ \alias{PlotACC} \title{Plot Plumes/Timeseries Of Anomaly Correlation Coefficients} \usage{ -PlotACC(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", - limits = NULL, legends = NULL, freq = 12, biglab = FALSE, - fill = FALSE, linezero = FALSE, points = TRUE, vlines = NULL, - fileout = "output_PlotACC.eps", width = 8, height = 5, - size_units = "in", res = 100, ...) +PlotACC( + ACC, + sdates, + toptitle = "", + sizetit = 1, + ytitle = "", + limits = NULL, + legends = NULL, + freq = 12, + biglab = FALSE, + fill = FALSE, + linezero = FALSE, + points = TRUE, + vlines = NULL, + fileout = "output_PlotACC.eps", + width = 8, + height = 5, + size_units = "in", + res = 100, + ... +) } \arguments{ \item{ACC}{ACC matrix with with dimensions:\cr @@ -122,4 +138,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{dynamic} - diff --git a/man/PlotAno.Rd b/man/PlotAno.Rd index dd059310..2ff2c46c 100644 --- a/man/PlotAno.Rd +++ b/man/PlotAno.Rd @@ -4,12 +4,30 @@ \alias{PlotAno} \title{Plot Raw Or Smoothed Anomalies} \usage{ -PlotAno(exp_ano, obs_ano = NULL, sdates, toptitle = rep("", 15), - ytitle = rep("", 15), limits = NULL, legends = NULL, freq = 12, - biglab = FALSE, fill = TRUE, memb = TRUE, ensmean = TRUE, - linezero = FALSE, points = FALSE, vlines = NULL, sizetit = 1, - fileout = paste0("output", 1:5, "_plotano.eps"), width = 8, height = 5, - size_units = "in", res = 100, ...) +PlotAno( + exp_ano, + obs_ano = NULL, + sdates, + toptitle = rep("", 15), + ytitle = rep("", 15), + limits = NULL, + legends = NULL, + freq = 12, + biglab = FALSE, + fill = TRUE, + memb = TRUE, + ensmean = TRUE, + linezero = FALSE, + points = FALSE, + vlines = NULL, + sizetit = 1, + fileout = paste0("output", 1:5, "_plotano.eps"), + width = 8, + height = 5, + size_units = "in", + res = 100, + ... +) } \arguments{ \item{exp_ano}{Array containing the experimental data:\cr @@ -109,4 +127,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{dynamic} - diff --git a/man/PlotBoxWhisker.Rd b/man/PlotBoxWhisker.Rd index a536686b..9d602103 100644 --- a/man/PlotBoxWhisker.Rd +++ b/man/PlotBoxWhisker.Rd @@ -4,10 +4,24 @@ \alias{PlotBoxWhisker} \title{Box-And-Whisker Plot of Time Series with Ensemble Distribution} \usage{ -PlotBoxWhisker(exp, obs, toptitle = "", ytitle = "", monini = 1, - yearini = 0, freq = 1, expname = "exp 1", obsname = "obs 1", - drawleg = TRUE, fileout = "output_PlotBoxWhisker.ps", width = 8, - height = 5, size_units = "in", res = 100, ...) +PlotBoxWhisker( + exp, + obs, + toptitle = "", + ytitle = "", + monini = 1, + yearini = 0, + freq = 1, + expname = "exp 1", + obsname = "obs 1", + drawleg = TRUE, + fileout = "output_PlotBoxWhisker.ps", + width = 8, + height = 5, + size_units = "in", + res = 100, + ... +) } \arguments{ \item{exp}{Forecast array of multi-member time series, e.g., the NAO index @@ -119,6 +133,9 @@ PlotBoxWhisker(nao$NAO_exp, nao$NAO_obs, "NAO index, DJF", "NAO index (PC1) TOS" monini = 12, yearini = 1985, freq = 1, "Exp. A", "Obs. X") } +} +\seealso{ +EOF, ProjectField, NAO } \author{ History:\cr @@ -127,8 +144,4 @@ History:\cr normalization for sake of clarity. 1.0 - 2016-03 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatting to R CRAN } -\seealso{ -EOF, ProjectField, NAO -} \keyword{datagen} - diff --git a/man/PlotClim.Rd b/man/PlotClim.Rd index 7ee001ee..f4fd7e1a 100644 --- a/man/PlotClim.Rd +++ b/man/PlotClim.Rd @@ -4,11 +4,26 @@ \alias{PlotClim} \title{Plots Climatologies} \usage{ -PlotClim(exp_clim, obs_clim = NULL, toptitle = "", ytitle = "", - monini = 1, freq = 12, limits = NULL, listexp = c("exp1", "exp2", - "exp3"), listobs = c("obs1", "obs2", "obs3"), biglab = FALSE, - leg = TRUE, sizetit = 1, fileout = "output_plotclim.eps", width = 8, - height = 5, size_units = "in", res = 100, ...) +PlotClim( + exp_clim, + obs_clim = NULL, + toptitle = "", + ytitle = "", + monini = 1, + freq = 12, + limits = NULL, + listexp = c("exp1", "exp2", "exp3"), + listobs = c("obs1", "obs2", "obs3"), + biglab = FALSE, + leg = TRUE, + sizetit = 1, + fileout = "output_plotclim.eps", + width = 8, + height = 5, + size_units = "in", + res = 100, + ... +) } \arguments{ \item{exp_clim}{Matrix containing the experimental data with dimensions:\cr @@ -87,4 +102,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index cb33fc60..c9db45b5 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -4,25 +4,72 @@ \alias{PlotEquiMap} \title{Maps A Two-Dimensional Variable On A Cylindrical Equidistant Projection} \usage{ -PlotEquiMap(var, lon, lat, varu = NULL, varv = NULL, toptitle = NULL, - sizetit = NULL, units = NULL, brks = NULL, cols = NULL, - bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, - col_sup = NULL, colNA = NULL, color_fun = clim.palette(), - square = TRUE, filled.continents = NULL, coast_color = NULL, - coast_width = 1, contours = NULL, brks2 = NULL, contour_lwd = 0.5, - contour_color = "black", contour_lty = 1, contour_label_scale = 1, - dots = NULL, dot_symbol = 4, dot_size = 1, - arr_subsamp = floor(length(lon)/30), arr_scale = 1, arr_ref_len = 15, - arr_units = "m/s", arr_scale_shaft = 1, arr_scale_shaft_angle = 1, - axelab = TRUE, labW = FALSE, intylat = 20, intxlon = 20, - axes_tick_scale = 1, axes_label_scale = 1, drawleg = TRUE, - subsampleg = NULL, bar_extra_labels = NULL, draw_bar_ticks = TRUE, - draw_separators = FALSE, triangle_ends_scale = 1, bar_label_digits = 4, - bar_label_scale = 1, units_scale = 1, bar_tick_scale = 1, - bar_extra_margin = rep(0, 4), boxlim = NULL, boxcol = "purple2", - boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, numbfig = NULL, - fileout = NULL, width = 8, height = 5, size_units = "in", res = 100, - ...) +PlotEquiMap( + var, + lon, + lat, + varu = NULL, + varv = NULL, + toptitle = NULL, + sizetit = NULL, + units = NULL, + brks = NULL, + cols = NULL, + bar_limits = NULL, + triangle_ends = NULL, + col_inf = NULL, + col_sup = NULL, + colNA = NULL, + color_fun = clim.palette(), + square = TRUE, + filled.continents = NULL, + coast_color = NULL, + coast_width = 1, + contours = NULL, + brks2 = NULL, + contour_lwd = 0.5, + contour_color = "black", + contour_lty = 1, + contour_label_scale = 1, + dots = NULL, + dot_symbol = 4, + dot_size = 1, + arr_subsamp = floor(length(lon)/30), + arr_scale = 1, + arr_ref_len = 15, + arr_units = "m/s", + arr_scale_shaft = 1, + arr_scale_shaft_angle = 1, + axelab = TRUE, + labW = FALSE, + intylat = 20, + intxlon = 20, + axes_tick_scale = 1, + axes_label_scale = 1, + drawleg = TRUE, + subsampleg = NULL, + bar_extra_labels = NULL, + draw_bar_ticks = TRUE, + draw_separators = FALSE, + triangle_ends_scale = 1, + bar_label_digits = 4, + bar_label_scale = 1, + units_scale = 1, + bar_tick_scale = 1, + bar_extra_margin = rep(0, 4), + boxlim = NULL, + boxcol = "purple2", + boxlwd = 5, + margin_scale = rep(1, 4), + title_scale = 1, + numbfig = NULL, + fileout = NULL, + width = 8, + height = 5, + size_units = "in", + res = 100, + ... +) } \arguments{ \item{var}{Array with the values at each cell of a grid on a regular @@ -288,4 +335,3 @@ History:\cr and adapted to new ColorBar. } \keyword{dynamic} - diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index e4cf4ecf..3cb81d15 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -4,20 +4,52 @@ \alias{PlotLayout} \title{Arrange and Fill Multi-Pannel Layouts With Optional Colour Bar} \usage{ -PlotLayout(fun, plot_dims, var, ..., special_args = NULL, nrow = NULL, - ncol = NULL, toptitle = NULL, row_titles = NULL, col_titles = NULL, - bar_scale = 1, title_scale = 1, title_margin_scale = 1, - title_left_shift_scale = 1, subtitle_scale = 1, - subtitle_margin_scale = 1, brks = NULL, cols = NULL, drawleg = "S", - titles = NULL, subsampleg = NULL, bar_limits = NULL, - triangle_ends = NULL, col_inf = NULL, col_sup = NULL, - color_fun = clim.colors, draw_bar_ticks = TRUE, draw_separators = FALSE, - triangle_ends_scale = 1, bar_extra_labels = NULL, units = NULL, - units_scale = 1, bar_label_scale = 1, bar_tick_scale = 1, - bar_extra_margin = rep(0, 4), bar_left_shift_scale = 1, - bar_label_digits = 4, extra_margin = rep(0, 4), fileout = NULL, - width = NULL, height = NULL, size_units = "in", res = 100, - close_device = TRUE) +PlotLayout( + fun, + plot_dims, + var, + ..., + special_args = NULL, + nrow = NULL, + ncol = NULL, + toptitle = NULL, + row_titles = NULL, + col_titles = NULL, + bar_scale = 1, + title_scale = 1, + title_margin_scale = 1, + title_left_shift_scale = 1, + subtitle_scale = 1, + subtitle_margin_scale = 1, + brks = NULL, + cols = NULL, + drawleg = "S", + titles = NULL, + subsampleg = NULL, + bar_limits = NULL, + triangle_ends = NULL, + col_inf = NULL, + col_sup = NULL, + color_fun = clim.colors, + draw_bar_ticks = TRUE, + draw_separators = FALSE, + triangle_ends_scale = 1, + bar_extra_labels = NULL, + units = NULL, + units_scale = 1, + bar_label_scale = 1, + bar_tick_scale = 1, + bar_extra_margin = rep(0, 4), + bar_left_shift_scale = 1, + bar_label_digits = 4, + extra_margin = rep(0, 4), + fileout = NULL, + width = NULL, + height = NULL, + size_units = "in", + res = 100, + close_device = TRUE +) } \arguments{ \item{fun}{Plot function (or name of the function) to be called on the @@ -48,6 +80,12 @@ applied to each of them. NAs can be passed to the list: a NA will yield a blank cell in the layout, which can be populated after (see .SwitchToFigure).} +\item{\dots}{Parameters to be sent to the plotting function 'fun'. If +multiple arrays are provided in 'var' and multiple functions are provided +in 'fun', the parameters provided through \dots will be sent to all the +plot functions, as common parameters. To specify concrete arguments for +each of the plot functions see parameter 'special_args'.} + \item{special_args}{List of sub-lists, each sub-list having specific extra arguments for each of the plot functions provided in 'fun'. If you want to fix a different value for each plot in the layout you can do so by @@ -164,12 +202,6 @@ the layout and a 'fileout' has been specified. This is useful to avoid closing the device when saving the layout into a file and willing to add extra elements or figures. Takes TRUE by default. Disregarded if no 'fileout' has been specified.} - -\item{\dots}{Parameters to be sent to the plotting function 'fun'. If -multiple arrays are provided in 'var' and multiple functions are provided -in 'fun', the parameters provided through \dots will be sent to all the -plot functions, as common parameters. To specify concrete arguments for -each of the plot functions see parameter 'special_args'.} } \value{ \item{brks}{ @@ -249,4 +281,3 @@ History:\cr 0.1 - 2016-08 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Original code } \keyword{dynamic} - diff --git a/man/PlotMatrix.Rd b/man/PlotMatrix.Rd index 70c1211e..88458856 100644 --- a/man/PlotMatrix.Rd +++ b/man/PlotMatrix.Rd @@ -4,12 +4,28 @@ \alias{PlotMatrix} \title{Function to convert any numerical table to a grid of coloured squares.} \usage{ -PlotMatrix(var, brks = NULL, cols = NULL, toptitle = NULL, - title.color = "royalblue4", xtitle = NULL, ytitle = NULL, - xlabels = NULL, xvert = FALSE, ylabels = NULL, line = 3, - figure.width = 1, legend = TRUE, legend.width = 0.15, - xlab_dist = NULL, ylab_dist = NULL, fileout = NULL, size_units = "px", - res = 100, ...) +PlotMatrix( + var, + brks = NULL, + cols = NULL, + toptitle = NULL, + title.color = "royalblue4", + xtitle = NULL, + ytitle = NULL, + xlabels = NULL, + xvert = FALSE, + ylabels = NULL, + line = 3, + figure.width = 1, + legend = TRUE, + legend.width = 0.15, + xlab_dist = NULL, + ylab_dist = NULL, + fileout = NULL, + size_units = "px", + res = 100, + ... +) } \arguments{ \item{var}{A numerical matrix containing the values to be displayed in a @@ -93,4 +109,3 @@ PlotMatrix(var = matrix(rnorm(n = 120, mean = 0.3), 10, 12), xlabels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) } - diff --git a/man/PlotSection.Rd b/man/PlotSection.Rd index f7447319..3dbe4fa1 100644 --- a/man/PlotSection.Rd +++ b/man/PlotSection.Rd @@ -4,10 +4,26 @@ \alias{PlotSection} \title{Plots A Vertical Section} \usage{ -PlotSection(var, horiz, depth, toptitle = "", sizetit = 1, units = "", - brks = NULL, cols = NULL, axelab = TRUE, intydep = 200, - intxhoriz = 20, drawleg = TRUE, fileout = NULL, width = 8, - height = 5, size_units = "in", res = 100, ...) +PlotSection( + var, + horiz, + depth, + toptitle = "", + sizetit = 1, + units = "", + brks = NULL, + cols = NULL, + axelab = TRUE, + intydep = 200, + intxhoriz = 20, + drawleg = TRUE, + fileout = NULL, + width = 8, + height = 5, + size_units = "in", + res = 100, + ... +) } \arguments{ \item{var}{Matrix to plot with (longitude/latitude, depth) dimensions.} @@ -75,4 +91,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{dynamic} - diff --git a/man/PlotStereoMap.Rd b/man/PlotStereoMap.Rd index 3bf2f69c..7559f6f7 100644 --- a/man/PlotStereoMap.Rd +++ b/man/PlotStereoMap.Rd @@ -4,19 +4,53 @@ \alias{PlotStereoMap} \title{Maps A Two-Dimensional Variable On A Polar Stereographic Projection} \usage{ -PlotStereoMap(var, lon, lat, latlims = c(60, 90), toptitle = NULL, - sizetit = NULL, units = NULL, brks = NULL, cols = NULL, - bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, - col_sup = NULL, colNA = NULL, color_fun = clim.palette(), - filled.continents = FALSE, coast_color = NULL, coast_width = 1, - dots = NULL, dot_symbol = 4, dot_size = 0.8, intlat = 10, - drawleg = TRUE, subsampleg = NULL, bar_extra_labels = NULL, - draw_bar_ticks = TRUE, draw_separators = FALSE, triangle_ends_scale = 1, - bar_label_digits = 4, bar_label_scale = 1, units_scale = 1, - bar_tick_scale = 1, bar_extra_margin = rep(0, 4), boxlim = NULL, - boxcol = "purple2", boxlwd = 5, margin_scale = rep(1, 4), - title_scale = 1, numbfig = NULL, fileout = NULL, width = 6, - height = 5, size_units = "in", res = 100, ...) +PlotStereoMap( + var, + lon, + lat, + latlims = c(60, 90), + toptitle = NULL, + sizetit = NULL, + units = NULL, + brks = NULL, + cols = NULL, + bar_limits = NULL, + triangle_ends = NULL, + col_inf = NULL, + col_sup = NULL, + colNA = NULL, + color_fun = clim.palette(), + filled.continents = FALSE, + coast_color = NULL, + coast_width = 1, + dots = NULL, + dot_symbol = 4, + dot_size = 0.8, + intlat = 10, + drawleg = TRUE, + subsampleg = NULL, + bar_extra_labels = NULL, + draw_bar_ticks = TRUE, + draw_separators = FALSE, + triangle_ends_scale = 1, + bar_label_digits = 4, + bar_label_scale = 1, + units_scale = 1, + bar_tick_scale = 1, + bar_extra_margin = rep(0, 4), + boxlim = NULL, + boxcol = "purple2", + boxlwd = 5, + margin_scale = rep(1, 4), + title_scale = 1, + numbfig = NULL, + fileout = NULL, + width = 6, + height = 5, + size_units = "in", + res = 100, + ... +) } \arguments{ \item{var}{Array with the values at each cell of a grid on a regular @@ -192,4 +226,3 @@ History:\cr border and Constantin boxes. } \keyword{dynamic} - diff --git a/man/PlotVsLTime.Rd b/man/PlotVsLTime.Rd index 2c71e9fa..402414d1 100644 --- a/man/PlotVsLTime.Rd +++ b/man/PlotVsLTime.Rd @@ -4,12 +4,29 @@ \alias{PlotVsLTime} \title{Plots A Score Along The Forecast Time With Its Confidence Interval} \usage{ -PlotVsLTime(var, toptitle = "", ytitle = "", monini = 1, freq = 12, - nticks = NULL, limits = NULL, listexp = c("exp1", "exp2", "exp3"), - listobs = c("obs1", "obs2", "obs3"), biglab = FALSE, hlines = NULL, - leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, - fileout = "output_plotvsltime.eps", width = 8, height = 5, - size_units = "in", res = 100, ...) +PlotVsLTime( + var, + toptitle = "", + ytitle = "", + monini = 1, + freq = 12, + nticks = NULL, + limits = NULL, + listexp = c("exp1", "exp2", "exp3"), + listobs = c("obs1", "obs2", "obs3"), + biglab = FALSE, + hlines = NULL, + leg = TRUE, + siglev = FALSE, + sizetit = 1, + show_conf = TRUE, + fileout = "output_plotvsltime.eps", + width = 8, + height = 5, + size_units = "in", + res = 100, + ... +) } \arguments{ \item{var}{Matrix containing any Prediction Score with dimensions:\cr @@ -133,4 +150,3 @@ History:\cr 1.0 - 2013-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{dynamic} - diff --git a/man/ProbBins.Rd b/man/ProbBins.Rd index 6df49cc2..56cf0511 100644 --- a/man/ProbBins.Rd +++ b/man/ProbBins.Rd @@ -4,8 +4,15 @@ \alias{ProbBins} \title{Computes Probabilistic Information of a Forecast Relative to a Threshold or a Quantile} \usage{ -ProbBins(ano, fcyr = "all", thr, quantile = TRUE, posdates = 3, - posdim = 2, compPeriod = "Full period") +ProbBins( + ano, + fcyr = "all", + thr, + quantile = TRUE, + posdates = 3, + posdim = 2, + compPeriod = "Full period" +) } \arguments{ \item{ano}{Array of anomalies from Ano().\cr @@ -86,4 +93,3 @@ History:\cr 2.1 - 2017-02 (V. Torralba and N. Manubens, \email{veronica.torralba@bsc.es}) - Fix bug with cross-validation } \keyword{datagen} - diff --git a/man/ProjectField.Rd b/man/ProjectField.Rd index 7b2e9e93..7dd77123 100644 --- a/man/ProjectField.Rd +++ b/man/ProjectField.Rd @@ -74,6 +74,9 @@ for (i in 1:dim(sampleData$mod)[2]) { ylim = c(-15000, 15000)) } +} +\seealso{ +EOF, NAO, PlotBoxWhisker } \author{ History:\cr @@ -105,8 +108,4 @@ multiplied by W. Getting input dimensions. 1.0 - 2016-03 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatting to R CRAN\cr (J.-P. Baudouin, \email{jean.baudouin@bsc.es}) - Example code and testing } -\seealso{ -EOF, NAO, PlotBoxWhisker -} \keyword{datagen} - diff --git a/man/RMS.Rd b/man/RMS.Rd index 715f84d1..877300fa 100644 --- a/man/RMS.Rd +++ b/man/RMS.Rd @@ -1,12 +1,20 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/RMS.R \name{RMS} -\alias{.RMS} \alias{RMS} +\alias{.RMS} \title{Computes Root Mean Square Error} \usage{ -RMS(var_exp, var_obs, posloop = 1, posRMS = 2, compROW = NULL, - limits = NULL, siglev = 0.95, conf = TRUE) +RMS( + var_exp, + var_obs, + posloop = 1, + posRMS = 2, + compROW = NULL, + limits = NULL, + siglev = 0.95, + conf = TRUE +) .RMS(exp, obs, siglev = 0.95, conf = TRUE) } @@ -119,4 +127,3 @@ History:\cr 1.1 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} - diff --git a/man/RMSSS.Rd b/man/RMSSS.Rd index f602702b..8bc0d803 100644 --- a/man/RMSSS.Rd +++ b/man/RMSSS.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/RMSSS.R \name{RMSSS} -\alias{.RMSSS} \alias{RMSSS} +\alias{.RMSSS} \title{Computes Root Mean Square Skill Score} \usage{ RMSSS(var_exp, var_obs, posloop = 1, posRMS = 2, pval = TRUE) @@ -93,4 +93,3 @@ History:\cr 1.1 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} - diff --git a/man/RatioRMS.Rd b/man/RatioRMS.Rd index 44d13dbb..b1abbca1 100644 --- a/man/RatioRMS.Rd +++ b/man/RatioRMS.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/RatioRMS.R \name{RatioRMS} -\alias{.RatioRMS} \alias{RatioRMS} +\alias{.RatioRMS} \title{Computes the Ratio Between The RMSE of Two Experiments} \usage{ RatioRMS(var_exp1, var_exp2, var_obs, posRMS = 1, pval = TRUE) @@ -121,4 +121,3 @@ History:\cr 1.1 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} - diff --git a/man/RatioSDRMS.Rd b/man/RatioSDRMS.Rd index 09484740..97efe6da 100644 --- a/man/RatioSDRMS.Rd +++ b/man/RatioSDRMS.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/RatioSDRMS.R \name{RatioSDRMS} -\alias{.RatioSDRMS} \alias{RatioSDRMS} +\alias{.RatioSDRMS} \title{Computes the ratio between the ensemble spread and RMSE} \usage{ RatioSDRMS(var_exp, var_obs, pval = TRUE) @@ -86,4 +86,3 @@ History:\cr 1.1 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} - diff --git a/man/Regression.Rd b/man/Regression.Rd index 55646576..a3763150 100644 --- a/man/Regression.Rd +++ b/man/Regression.Rd @@ -73,4 +73,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/SVD.Rd b/man/SVD.Rd index 698df952..bbbcaa49 100644 --- a/man/SVD.Rd +++ b/man/SVD.Rd @@ -4,8 +4,15 @@ \alias{SVD} \title{Single Value Decomposition (Maximum Covariance Analysis)} \usage{ -SVD(vary, varx, laty = NULL, latx = NULL, nmodes = 15, corr = FALSE, - weight = TRUE) +SVD( + vary, + varx, + laty = NULL, + latx = NULL, + nmodes = 15, + corr = FALSE, + weight = TRUE +) } \arguments{ \item{vary}{Array containing the anomalies field for the predictor. The @@ -117,4 +124,3 @@ History:\cr 1.0 - 2016-04 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatting to R CRAN } \keyword{datagen} - diff --git a/man/Season.Rd b/man/Season.Rd index cc97941c..76f64053 100644 --- a/man/Season.Rd +++ b/man/Season.Rd @@ -54,4 +54,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/SelIndices.Rd b/man/SelIndices.Rd index dbf34da2..ab3ca88e 100644 --- a/man/SelIndices.Rd +++ b/man/SelIndices.Rd @@ -37,4 +37,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/Smoothing.Rd b/man/Smoothing.Rd index 4fa9c596..492370e9 100644 --- a/man/Smoothing.Rd +++ b/man/Smoothing.Rd @@ -47,4 +47,3 @@ History:\cr making it able to work on arrays of any number of dimensions. } \keyword{datagen} - diff --git a/man/Spectrum.Rd b/man/Spectrum.Rd index de5a2e5e..a3fce568 100644 --- a/man/Spectrum.Rd +++ b/man/Spectrum.Rd @@ -48,4 +48,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/Spread.Rd b/man/Spread.Rd index f84cecf3..a9f3125b 100644 --- a/man/Spread.Rd +++ b/man/Spread.Rd @@ -93,4 +93,3 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} - diff --git a/man/StatSeasAtlHurr.Rd b/man/StatSeasAtlHurr.Rd index 9822eb90..053698f7 100644 --- a/man/StatSeasAtlHurr.Rd +++ b/man/StatSeasAtlHurr.Rd @@ -66,10 +66,6 @@ hr_count <- StatSeasAtlHurr(atlano = AtlAno, hrvar = 'HR') print(hr_count$mean) -} -\author{ -History:\cr -0.1 - 2015-11 (Louis-Philippe Caron, \email{louis-philippe.caron@bsc.es}) - Original code } \references{ Villarini et al. (2010) Mon Wea Rev, 138, 2681-2705.\cr @@ -81,5 +77,8 @@ Caron, L.-P. et al. (2014) Multi-year prediction skill of Atlantic hurricane activity in CMIP5 decadal hindcasts. Climate Dynamics, 42, 2675-2690. doi:10.1007/s00382-013-1773-1. } +\author{ +History:\cr +0.1 - 2015-11 (Louis-Philippe Caron, \email{louis-philippe.caron@bsc.es}) - Original code +} \keyword{datagen} - diff --git a/man/Subset.Rd b/man/Subset.Rd index bccec4ac..570cd732 100644 --- a/man/Subset.Rd +++ b/man/Subset.Rd @@ -45,4 +45,3 @@ PlotLayout(PlotEquiMap, c('lat', 'lon'), subset, } \keyword{datagen} - diff --git a/man/ToyModel.Rd b/man/ToyModel.Rd index ca47b449..5eee0393 100644 --- a/man/ToyModel.Rd +++ b/man/ToyModel.Rd @@ -7,8 +7,18 @@ components of a forecast: (1) predictabiltiy (2) forecast error (3) non-stationarity and (4) ensemble generation. The forecast can be computed for real observations or observations generated artifically.} \usage{ -ToyModel(alpha = 0.1, beta = 0.4, gamma = 1, sig = 1, trend = 0, - nstartd = 30, nleadt = 4, nmemb = 10, obsini = NULL, fxerr = NULL) +ToyModel( + alpha = 0.1, + beta = 0.4, + gamma = 1, + sig = 1, + trend = 0, + nstartd = 30, + nleadt = 4, + nmemb = 10, + obsini = NULL, + fxerr = NULL +) } \arguments{ \item{alpha}{Predicabiltiy of the forecast on the observed residuals @@ -125,4 +135,3 @@ History:\cr 1.1 - 2016-02 (O.Bellprat) - Include security check for parameters } \keyword{datagen} - diff --git a/man/Trend.Rd b/man/Trend.Rd index 3b7f7bfd..b4e0ba36 100644 --- a/man/Trend.Rd +++ b/man/Trend.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/Trend.R \name{Trend} -\alias{.Trend} \alias{Trend} +\alias{.Trend} \title{Computes the Trend of the Ensemble Mean} \usage{ Trend(var, posTR = 2, interval = 1, siglev = 0.95, conf = TRUE) @@ -78,4 +78,3 @@ History:\cr 2.0 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapt to veriApply() } \keyword{datagen} - diff --git a/man/UltimateBrier.Rd b/man/UltimateBrier.Rd index 46fe124c..518a60cc 100644 --- a/man/UltimateBrier.Rd +++ b/man/UltimateBrier.Rd @@ -4,9 +4,17 @@ \alias{UltimateBrier} \title{Computes Brier Scores} \usage{ -UltimateBrier(ano_exp, ano_obs, posdatasets = 1, posmemb = 2, - posdates = 3, quantile = TRUE, thr = c(5/100, 95/100), type = "BS", - decomposition = TRUE) +UltimateBrier( + ano_exp, + ano_obs, + posdatasets = 1, + posmemb = 2, + posdates = 3, + quantile = TRUE, + thr = c(5/100, 95/100), + type = "BS", + decomposition = TRUE +) } \arguments{ \item{ano_exp}{Array of forecast anomalies, as provided by \code{Ano()}. @@ -124,4 +132,3 @@ History:\cr N. Manubens, \email{nicolau.manubens@bsc.es}) - First version } \keyword{datagen} - diff --git a/man/clim.palette.Rd b/man/clim.palette.Rd index 95f8407c..e67994f8 100644 --- a/man/clim.palette.Rd +++ b/man/clim.palette.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/clim.palette.R \name{clim.palette} -\alias{clim.colors} \alias{clim.palette} +\alias{clim.colors} \title{Generate Climate Color Palettes} \usage{ clim.palette(palette = "bluered") @@ -35,4 +35,3 @@ History:\cr 0.0 - 2016-01 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Original code. } \keyword{datagen} - diff --git a/man/s2dverification.Rd b/man/s2dverification.Rd index 698fa4ed..fe175f25 100644 --- a/man/s2dverification.Rd +++ b/man/s2dverification.Rd @@ -26,6 +26,14 @@ Check an overview of the package functionalities and its modules at \url{https://earth.bsc.es/gitlab/es/s2dverification/wikis/home}. For more information load the package and check the help for each function or the documentation attached to the package. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://earth.bsc.es/gitlab/es/s2dverification/wikis/home} + \item Report bugs at \url{https://earth.bsc.es/gitlab/es/s2dverification/issues} +} + } \author{ Nicolau Manubens \email{nicolau.manubens@bsc.es} @@ -33,4 +41,3 @@ Nicolau Manubens \email{nicolau.manubens@bsc.es} \keyword{datagen} \keyword{dynamic} \keyword{package} - diff --git a/man/sampleDepthData.Rd b/man/sampleDepthData.Rd index 974fe6bd..3292f5c6 100644 --- a/man/sampleDepthData.Rd +++ b/man/sampleDepthData.Rd @@ -32,4 +32,3 @@ Its name within IC3 local database is 'i00k'. Nicolau Manubens \email{nicolau.manubens@bsc.es} } \keyword{data} - diff --git a/man/sampleMap.Rd b/man/sampleMap.Rd index d33ab829..7286b8a6 100644 --- a/man/sampleMap.Rd +++ b/man/sampleMap.Rd @@ -47,4 +47,3 @@ Check the documentation on 'Load()' in the package 's2dverification' for more in Nicolau Manubens \email{nicolau.manubens@bsc.es} } \keyword{datasets} - diff --git a/man/sampleTimeSeries.Rd b/man/sampleTimeSeries.Rd index ce2c6395..4871a928 100644 --- a/man/sampleTimeSeries.Rd +++ b/man/sampleTimeSeries.Rd @@ -51,4 +51,3 @@ Check the documentation on 'Load()' in the package 's2dverification' for more in Nicolau Manubens \email{nicolau.manubens@bsc.es} } \keyword{datasets} - -- GitLab From 691e488d27ea92c936a88ea45fd1347b1aa5494e Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 21 Oct 2020 12:35:59 +0200 Subject: [PATCH 21/23] devtools with R.3.2.0 --- DESCRIPTION | 2 +- man/ACC.Rd | 21 +++----- man/Alpha.Rd | 1 + man/AnimateMap.Rd | 33 +++--------- man/Ano.Rd | 1 + man/Ano_CrossValid.Rd | 1 + man/ArrayToNetCDF.Rd | 1 + man/BrierScore.Rd | 13 ++--- man/CDORemap.Rd | 14 ++--- man/Clim.Rd | 1 + man/Cluster.Rd | 9 ++-- man/ColorBar.Rd | 32 +++--------- man/Composite.Rd | 1 + man/ConfigApplyMatchingEntries.Rd | 21 +++----- man/ConfigEditDefinition.Rd | 9 ++-- man/ConfigEditEntry.Rd | 53 ++++++------------- man/ConfigFileOpen.Rd | 13 ++--- man/ConfigShowSimilarEntries.Rd | 27 ++++------ man/ConfigShowTable.Rd | 13 ++--- man/Consist_Trend.Rd | 1 + man/Corr.Rd | 21 +++----- man/EOF.Rd | 7 +-- man/Enlarge.Rd | 1 + man/Eno.Rd | 1 + man/EnoNew.Rd | 11 ++-- man/Filter.Rd | 1 + man/FitAcfCoef.Rd | 1 + man/FitAutocor.Rd | 1 + man/GenSeries.Rd | 1 + man/Histo2Hindcast.Rd | 1 + man/IniListDims.Rd | 1 + man/InsertDim.Rd | 1 + man/LeapYear.Rd | 1 + man/Load.Rd | 40 ++++---------- man/Mean1Dim.Rd | 1 + man/MeanListDim.Rd | 1 + man/NAO.Rd | 21 +++----- man/Plot2VarsVsLTime.Rd | 31 +++-------- man/PlotACC.Rd | 27 +++------- man/PlotAno.Rd | 31 +++-------- man/PlotBoxWhisker.Rd | 29 +++-------- man/PlotClim.Rd | 26 +++------- man/PlotEquiMap.Rd | 86 +++++++------------------------ man/PlotLayout.Rd | 73 ++++++++------------------ man/PlotMatrix.Rd | 29 +++-------- man/PlotSection.Rd | 25 ++------- man/PlotStereoMap.Rd | 61 +++++----------------- man/PlotVsLTime.Rd | 30 +++-------- man/ProbBins.Rd | 12 ++--- man/ProjectField.Rd | 7 +-- man/RMS.Rd | 15 ++---- man/RMSSS.Rd | 3 +- man/RatioRMS.Rd | 3 +- man/RatioSDRMS.Rd | 3 +- man/Regression.Rd | 1 + man/SVD.Rd | 12 ++--- man/Season.Rd | 1 + man/SelIndices.Rd | 1 + man/Smoothing.Rd | 1 + man/Spectrum.Rd | 1 + man/Spread.Rd | 1 + man/StatSeasAtlHurr.Rd | 9 ++-- man/Subset.Rd | 1 + man/ToyModel.Rd | 15 ++---- man/Trend.Rd | 3 +- man/UltimateBrier.Rd | 15 ++---- man/clim.palette.Rd | 3 +- man/s2dverification.Rd | 9 +--- man/sampleDepthData.Rd | 1 + man/sampleMap.Rd | 1 + man/sampleTimeSeries.Rd | 1 + 71 files changed, 299 insertions(+), 647 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1f0a201e..0045265c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,4 +60,4 @@ BugReports: https://earth.bsc.es/gitlab/es/s2dverification/issues LazyData: true SystemRequirements: cdo Encoding: UTF-8 -RoxygenNote: 7.0.1 +RoxygenNote: 5.0.0 diff --git a/man/ACC.Rd b/man/ACC.Rd index 61b286f2..e3db377f 100644 --- a/man/ACC.Rd +++ b/man/ACC.Rd @@ -4,16 +4,8 @@ \alias{ACC} \title{Computes Anomaly Correlation Coefficient} \usage{ -ACC( - var_exp, - var_obs, - lon = NULL, - lat = NULL, - lonlatbox = NULL, - conf = TRUE, - conftype = "parametric", - siglev = 0.95 -) +ACC(var_exp, var_obs, lon = NULL, lat = NULL, lonlatbox = NULL, + conf = TRUE, conftype = "parametric", siglev = 0.95) } \arguments{ \item{var_exp}{Array of experimental anomalies with dimensions: @@ -105,10 +97,6 @@ acc <- ACC(Mean1Dim(ano_exp, 2), Mean1Dim(ano_obs, 2)) PlotACC(acc$ACC, startDates) } } -\references{ -Joliffe and Stephenson (2012). Forecast Verification: A - Practitioner's Guide in Atmospheric Science. Wiley-Blackwell. -} \author{ History:\cr 0.1 - 2013-08 (V. Guemas, \email{virginie.guemas@bsc.es}) - Original code\cr @@ -119,4 +107,9 @@ History:\cr 1.3.1 - 2014-09 (C. Prodhomme, \email{chloe.prodhomme@bsc.es}) - Add comments and minor style changes\cr 1.3.2 - 2015-02 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Fixed ACC documentation and examples } +\references{ +Joliffe and Stephenson (2012). Forecast Verification: A + Practitioner's Guide in Atmospheric Science. Wiley-Blackwell. +} \keyword{datagen} + diff --git a/man/Alpha.Rd b/man/Alpha.Rd index 26596dc2..c2350b2a 100644 --- a/man/Alpha.Rd +++ b/man/Alpha.Rd @@ -42,3 +42,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/AnimateMap.Rd b/man/AnimateMap.Rd index 5dc756da..96074b01 100644 --- a/man/AnimateMap.Rd +++ b/man/AnimateMap.Rd @@ -4,33 +4,13 @@ \alias{AnimateMap} \title{Animate Maps of Forecast/Observed Values or Scores Over Forecast Time} \usage{ -AnimateMap( - var, - lon, - lat, - toptitle = rep("", 11), - sizetit = 1, - units = "", - monini = 1, - freq = 12, - msk95lev = FALSE, - brks = NULL, - cols = NULL, - filled.continents = FALSE, - lonmin = 0, - lonmax = 360, - latmin = -90, - latmax = 90, - intlon = 20, - intlat = 30, - drawleg = TRUE, - subsampleg = 1, - colNA = "white", - equi = TRUE, +AnimateMap(var, lon, lat, toptitle = rep("", 11), sizetit = 1, units = "", + monini = 1, freq = 12, msk95lev = FALSE, brks = NULL, cols = NULL, + filled.continents = FALSE, lonmin = 0, lonmax = 360, latmin = -90, + latmax = 90, intlon = 20, intlat = 30, drawleg = TRUE, + subsampleg = 1, colNA = "white", equi = TRUE, fileout = c("output1_animvsltime.gif", "output2_animvsltime.gif", - "output3_animvsltime.gif"), - ... -) + "output3_animvsltime.gif"), ...) } \arguments{ \item{var}{Matrix of dimensions (nltime, nlat, nlon) or @@ -214,3 +194,4 @@ History:\cr 1.2 - 2015-05 (V. Guemas, \email{virginie.guemas@bsc.es}) - Use of PlotEquiMap and PlotStereoMap } \keyword{dynamic} + diff --git a/man/Ano.Rd b/man/Ano.Rd index 6461ec77..6143be88 100644 --- a/man/Ano.Rd +++ b/man/Ano.Rd @@ -49,3 +49,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to R CRAN } \keyword{datagen} + diff --git a/man/Ano_CrossValid.Rd b/man/Ano_CrossValid.Rd index 70017492..85d1badb 100644 --- a/man/Ano_CrossValid.Rd +++ b/man/Ano_CrossValid.Rd @@ -43,3 +43,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/ArrayToNetCDF.Rd b/man/ArrayToNetCDF.Rd index 4e05d829..77cbfaf8 100644 --- a/man/ArrayToNetCDF.Rd +++ b/man/ArrayToNetCDF.Rd @@ -238,3 +238,4 @@ History:\cr 0.0 - 2017-01 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Original code. } \keyword{datagen} + diff --git a/man/BrierScore.Rd b/man/BrierScore.Rd index e802dc35..5094987c 100644 --- a/man/BrierScore.Rd +++ b/man/BrierScore.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/BrierScore.R \name{BrierScore} -\alias{BrierScore} \alias{.BrierScore} +\alias{BrierScore} \title{Compute Brier Score And Its Decomposition And Brier Skill Score} \usage{ BrierScore(obs, pred, thresholds = seq(0, 1, 0.1)) @@ -85,6 +85,11 @@ bs2 <- veriApply("BrierScore2", bins_ano_exp, Mean1Dim(bins_ano_ob,s 3), tdim = 2, ensdim = 3) } } +\author{ +History:\cr + 0.1 - 2012-04 (L. Rodrigues, \email{lrodrigues@ic3.cat}) - Original code\cr + 0.2 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() +} \references{ Wilks (2006) Statistical Methods in the Atmospheric Sciences.\cr Stephenson et al. (2008). Two extra components in the Brier score decomposition. @@ -92,9 +97,5 @@ Stephenson et al. (2008). Two extra components in the Brier score decomposition. Ferro and Fricker (2012). A bias-corrected decomposition of the BS. Quarterly Journal of the Royal Meteorological Society, DOI: 10.1002/qj.1924. } -\author{ -History:\cr - 0.1 - 2012-04 (L. Rodrigues, \email{lrodrigues@ic3.cat}) - Original code\cr - 0.2 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() -} \keyword{datagen} + diff --git a/man/CDORemap.Rd b/man/CDORemap.Rd index bae7aa55..b2d5eaa3 100644 --- a/man/CDORemap.Rd +++ b/man/CDORemap.Rd @@ -4,17 +4,8 @@ \alias{CDORemap} \title{Interpolates arrays with longitude and latitude dimensions using CDO} \usage{ -CDORemap( - data_array = NULL, - lons, - lats, - grid, - method, - avoid_writes = TRUE, - crop = TRUE, - force_remap = FALSE, - write_dir = tempdir() -) +CDORemap(data_array = NULL, lons, lats, grid, method, avoid_writes = TRUE, + crop = TRUE, force_remap = FALSE, write_dir = tempdir()) } \arguments{ \item{data_array}{Multidimensional numeric array to be interpolated. If @@ -235,3 +226,4 @@ History:\cr 0.0 - 2017-01 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Original code. } \keyword{datagen} + diff --git a/man/Clim.Rd b/man/Clim.Rd index 69f7ceb0..1ef5e3da 100644 --- a/man/Clim.Rd +++ b/man/Clim.Rd @@ -63,3 +63,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to R CRAN } \keyword{datagen} + diff --git a/man/Cluster.Rd b/man/Cluster.Rd index 782c37a4..70f22347 100644 --- a/man/Cluster.Rd +++ b/man/Cluster.Rd @@ -92,7 +92,7 @@ for (i1 in c1) { a1[i1, ] <- x1 + rnorm(4, mean = mean1, sd = sd1) } -c1p5 <- c0[!(c0 \\%in\\% c1)] +c1p5 <- c0[!(c0 \\\%in\\\% c1)] c2 <- c1p5[seq(1, length(c1p5), 2)] x2 <- c(2, 2, 4, 4) for (i2 in c2) { @@ -114,11 +114,12 @@ res2 <- Cluster(var = a1, weights = array(1, dim = dim(a1)[2])) print(res2$cluster) print(res2$centers) } -\references{ -Wilks, 2011, Statistical Methods in the Atmospheric Sciences, 3rd ed., Elsevire, pp 676. -} \author{ History:\cr 1.0 # 2014-10 (N.S. Fuckar, \email{neven.fuckar@bsc.es}) - Original code } +\references{ +Wilks, 2011, Statistical Methods in the Atmospheric Sciences, 3rd ed., Elsevire, pp 676. +} \keyword{datagen} + diff --git a/man/ColorBar.Rd b/man/ColorBar.Rd index 98c99679..71da02be 100644 --- a/man/ColorBar.Rd +++ b/man/ColorBar.Rd @@ -4,30 +4,13 @@ \alias{ColorBar} \title{Draws a Color Bar} \usage{ -ColorBar( - brks = NULL, - cols = NULL, - vertical = TRUE, - subsampleg = NULL, - bar_limits = NULL, - var_limits = NULL, - triangle_ends = NULL, - col_inf = NULL, - col_sup = NULL, - color_fun = clim.palette(), - plot = TRUE, - draw_ticks = TRUE, - draw_separators = FALSE, - triangle_ends_scale = 1, - extra_labels = NULL, - title = NULL, - title_scale = 1, - label_scale = 1, - tick_scale = 1, - extra_margin = rep(0, 4), - label_digits = 4, - ... -) +ColorBar(brks = NULL, cols = NULL, vertical = TRUE, subsampleg = NULL, + bar_limits = NULL, var_limits = NULL, triangle_ends = NULL, + col_inf = NULL, col_sup = NULL, color_fun = clim.palette(), + plot = TRUE, draw_ticks = TRUE, draw_separators = FALSE, + triangle_ends_scale = 1, extra_labels = NULL, title = NULL, + title_scale = 1, label_scale = 1, tick_scale = 1, + extra_margin = rep(0, 4), label_digits = 4, ...) } \arguments{ \item{brks}{Can be provided in two formats: @@ -202,3 +185,4 @@ History:\cr (V. Torralba, \email{veronica.torralba@bsc.es}) } \keyword{hplot} + diff --git a/man/Composite.Rd b/man/Composite.Rd index f0ce4692..b9151d82 100644 --- a/man/Composite.Rd +++ b/man/Composite.Rd @@ -90,3 +90,4 @@ History: 0.1 # 2014-08 (N.S. Fuckar, \email{neven.fuckar@bsc.es}) # Original code } \keyword{datagen} + diff --git a/man/ConfigApplyMatchingEntries.Rd b/man/ConfigApplyMatchingEntries.Rd index 74abb167..626e385d 100644 --- a/man/ConfigApplyMatchingEntries.Rd +++ b/man/ConfigApplyMatchingEntries.Rd @@ -4,14 +4,8 @@ \alias{ConfigApplyMatchingEntries} \title{Apply Matching Entries To Dataset Name And Variable Name To Find Related Info} \usage{ -ConfigApplyMatchingEntries( - configuration, - var, - exp = NULL, - obs = NULL, - show_entries = FALSE, - show_result = TRUE -) +ConfigApplyMatchingEntries(configuration, var, exp = NULL, obs = NULL, + show_entries = FALSE, show_result = TRUE) } \arguments{ \item{configuration}{Configuration object obtained from ConfigFileOpen() @@ -69,14 +63,15 @@ configuration <- ConfigEditEntry(configuration, "experiments", 1, match_info <- ConfigApplyMatchingEntries(configuration, 'tas', exp = c('ExampleExperiment2'), show_result = TRUE) } -\seealso{ -ConfigApplyMatchingEntries, ConfigEditDefinition, - ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, - ConfigShowTable -} \author{ History:\cr 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage types } +\seealso{ +ConfigApplyMatchingEntries, ConfigEditDefinition, + ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, + ConfigShowTable +} \keyword{datagen} + diff --git a/man/ConfigEditDefinition.Rd b/man/ConfigEditDefinition.Rd index a25a9c3b..b1f7c882 100644 --- a/man/ConfigEditDefinition.Rd +++ b/man/ConfigEditDefinition.Rd @@ -52,13 +52,14 @@ match_info <- ConfigApplyMatchingEntries(configuration, 'tas', exp = c('ExampleExperiment2'), show_result = TRUE) } +\author{ +History: + 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version +} \seealso{ [ConfigApplyMatchingEntries()], [ConfigEditDefinition()], [ConfigEditEntry()], [ConfigFileOpen()], [ConfigShowSimilarEntries()], [ConfigShowTable()]. } -\author{ -History: - 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version -} \keyword{datagen} + diff --git a/man/ConfigEditEntry.Rd b/man/ConfigEditEntry.Rd index 2b13d0b9..83973231 100644 --- a/man/ConfigEditEntry.Rd +++ b/man/ConfigEditEntry.Rd @@ -1,46 +1,22 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/ConfigEditEntry.R \name{ConfigEditEntry} -\alias{ConfigEditEntry} \alias{ConfigAddEntry} +\alias{ConfigEditEntry} \alias{ConfigRemoveEntry} \title{Add, Remove Or Edit Entries In The Configuration} \usage{ -ConfigEditEntry( - configuration, - dataset_type, - position, - dataset_name = NULL, - var_name = NULL, - main_path = NULL, - file_path = NULL, - nc_var_name = NULL, - suffix = NULL, - varmin = NULL, - varmax = NULL -) +ConfigEditEntry(configuration, dataset_type, position, dataset_name = NULL, + var_name = NULL, main_path = NULL, file_path = NULL, + nc_var_name = NULL, suffix = NULL, varmin = NULL, varmax = NULL) -ConfigAddEntry( - configuration, - dataset_type, - position = "last", - dataset_name = ".*", - var_name = ".*", - main_path = "*", - file_path = "*", - nc_var_name = "*", - suffix = "*", - varmin = "*", - varmax = "*" -) +ConfigAddEntry(configuration, dataset_type, position = "last", + dataset_name = ".*", var_name = ".*", main_path = "*", + file_path = "*", nc_var_name = "*", suffix = "*", varmin = "*", + varmax = "*") -ConfigRemoveEntry( - configuration, - dataset_type, - dataset_name = NULL, - var_name = NULL, - position = NULL -) +ConfigRemoveEntry(configuration, dataset_type, dataset_name = NULL, + var_name = NULL, position = NULL) } \arguments{ \item{configuration}{Configuration object obtained via ConfigFileOpen() @@ -119,13 +95,14 @@ ConfigShowTable(configuration, "experiments") # Save the configuration ConfigFileSave(configuration, config_file, confirm = FALSE) } -\seealso{ -ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, - ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable -} \author{ History:\cr 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats } +\seealso{ +ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, + ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable +} \keyword{datagen} + diff --git a/man/ConfigFileOpen.Rd b/man/ConfigFileOpen.Rd index 372ad386..cff7427e 100644 --- a/man/ConfigFileOpen.Rd +++ b/man/ConfigFileOpen.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/ConfigFileOpen.R \name{ConfigFileOpen} -\alias{ConfigFileOpen} \alias{ConfigFileCreate} +\alias{ConfigFileOpen} \alias{ConfigFileSave} \title{Functions To Create Open And Save Configuration File} \usage{ @@ -185,6 +185,11 @@ match_info <- ConfigApplyMatchingEntries(configuration, 'tas', # Finally save the configuration file. ConfigFileSave(configuration, config_file, confirm = FALSE) +} +\author{ +History: + 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version + 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats } \references{ [1] \url{https://stat.ethz.ch/R-manual/R-devel/library/base/html/regex.html}\cr @@ -194,9 +199,5 @@ ConfigFileSave(configuration, config_file, confirm = FALSE) ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable } -\author{ -History: - 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version - 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats -} \keyword{datagen} + diff --git a/man/ConfigShowSimilarEntries.Rd b/man/ConfigShowSimilarEntries.Rd index 154bcb28..312da795 100644 --- a/man/ConfigShowSimilarEntries.Rd +++ b/man/ConfigShowSimilarEntries.Rd @@ -4,18 +4,10 @@ \alias{ConfigShowSimilarEntries} \title{Find Similar Entries In Tables Of Datasets} \usage{ -ConfigShowSimilarEntries( - configuration, - dataset_name = NULL, - var_name = NULL, - main_path = NULL, - file_path = NULL, - nc_var_name = NULL, - suffix = NULL, - varmin = NULL, - varmax = NULL, - n_results = 10 -) +ConfigShowSimilarEntries(configuration, dataset_name = NULL, + var_name = NULL, main_path = NULL, file_path = NULL, + nc_var_name = NULL, suffix = NULL, varmin = NULL, varmax = NULL, + n_results = 10) } \arguments{ \item{configuration}{Configuration object obtained either from @@ -79,6 +71,11 @@ ConfigShowSimilarEntries(configuration, dataset_name = "Exper", var_name = "Vari") } +\author{ +History:\cr + 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr + 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats +} \references{ [1] Simon White, string seamness: \url{http://www.catalysoft.com/articles/StrikeAMatch.html} @@ -87,9 +84,5 @@ ConfigShowSimilarEntries(configuration, dataset_name = "Exper", ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable } -\author{ -History:\cr - 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr - 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats -} \keyword{datagen} + diff --git a/man/ConfigShowTable.Rd b/man/ConfigShowTable.Rd index 56649156..a06b643e 100644 --- a/man/ConfigShowTable.Rd +++ b/man/ConfigShowTable.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/ConfigShowTable.R \name{ConfigShowTable} -\alias{ConfigShowTable} \alias{ConfigShowDefinitions} +\alias{ConfigShowTable} \title{Show Configuration Tables And Definitions} \usage{ ConfigShowTable(configuration, dataset_type, line_numbers = NULL) @@ -48,15 +48,16 @@ configuration <- ConfigEditEntry(configuration, "experiments", 1, ConfigShowTable(configuration, 'experiments') ConfigShowDefinitions(configuration) -} -\seealso{ -[ConfigApplyMatchingEntries()], [ConfigEditDefinition()], - [ConfigEditEntry()], [ConfigFileOpen()], [ConfigShowSimilarEntries()], - [ConfigShowTable()]. } \author{ History:\cr 0.1 - 2015-05 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - First version\cr 1.0 - 2015-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Removed grid column and storage formats } +\seealso{ +[ConfigApplyMatchingEntries()], [ConfigEditDefinition()], + [ConfigEditEntry()], [ConfigFileOpen()], [ConfigShowSimilarEntries()], + [ConfigShowTable()]. +} \keyword{datagen} + diff --git a/man/Consist_Trend.Rd b/man/Consist_Trend.Rd index 124e5e3d..d067dcd7 100644 --- a/man/Consist_Trend.Rd +++ b/man/Consist_Trend.Rd @@ -80,3 +80,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to R CRAN } \keyword{datagen} + diff --git a/man/Corr.Rd b/man/Corr.Rd index 11a40d79..e311813d 100644 --- a/man/Corr.Rd +++ b/man/Corr.Rd @@ -1,24 +1,16 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/Corr.R \name{Corr} -\alias{Corr} \alias{.Corr} +\alias{Corr} \title{Computes the correlation coefficient between an array of forecasts and their corresponding observations} \usage{ -Corr( - var_exp, - var_obs, - posloop = 1, - poscor = 2, - compROW = NULL, - limits = NULL, - siglev = 0.95, - method = "pearson", - conf = TRUE, - pval = TRUE -) +Corr(var_exp, var_obs, posloop = 1, poscor = 2, compROW = NULL, + limits = NULL, siglev = 0.95, method = "pearson", conf = TRUE, + pval = TRUE) -.Corr(exp, obs, siglev = 0.95, method = "pearson", conf = TRUE, pval = TRUE) +.Corr(exp, obs, siglev = 0.95, method = "pearson", conf = TRUE, + pval = TRUE) } \arguments{ \item{var_exp}{Array of experimental data.} @@ -139,3 +131,4 @@ History:\cr 1.3 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} + diff --git a/man/EOF.Rd b/man/EOF.Rd index 25934f52..bd0b31e4 100644 --- a/man/EOF.Rd +++ b/man/EOF.Rd @@ -82,9 +82,6 @@ ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) eof <- EOF(Mean1Dim(ano$ano_exp, 2)[1, , 1, , ], sampleData$lon, sampleData$lat) PlotEquiMap(eof$EOFs[1, , ], sampleData$lon, sampleData$lat) -} -\seealso{ -ProjectField, NAO, PlotBoxWhisker } \author{ History:\cr @@ -118,4 +115,8 @@ weighted by cos(lat)\cr EOF * PC\cr 1.0 - 2016-03 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatting to R CRAN } +\seealso{ +ProjectField, NAO, PlotBoxWhisker +} \keyword{datagen} + diff --git a/man/Enlarge.Rd b/man/Enlarge.Rd index 47aed320..76f5cccf 100644 --- a/man/Enlarge.Rd +++ b/man/Enlarge.Rd @@ -29,3 +29,4 @@ History:\cr 1.1 - 2015-03 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Improved\cr } \keyword{datagen} + diff --git a/man/Eno.Rd b/man/Eno.Rd index ea70bc5e..ba4f2088 100644 --- a/man/Eno.Rd +++ b/man/Eno.Rd @@ -60,3 +60,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens at ic3.cat}) - Formatting to R CRAN } \keyword{datagen} + diff --git a/man/EnoNew.Rd b/man/EnoNew.Rd index 32bf55fd..cc2de760 100644 --- a/man/EnoNew.Rd +++ b/man/EnoNew.Rd @@ -55,15 +55,16 @@ sampleData <- s2dverification:::.LoadSampleData('tos', c('experiment'), eno <- EnoNew(sampleData$mod[1, 1, , 1, 2, 3]) print(eno) -} -\references{ -Guemas V, Auger L, Doblas-Reyes FJ, Rust H, Ribes A, 2014, Dependencies in - Statistical Hypothesis Tests for Climate Time Series. Bulletin of the - American Meteorological Society, 95 (11), 1666-1667. } \author{ History:\cr 0.1 - 2012-06 (V. Guemas, \email{virginie.guemas at ic3.cat}) - Original code\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens at ic3.cat}) - Formatting to CRAN } +\references{ +Guemas V, Auger L, Doblas-Reyes FJ, Rust H, Ribes A, 2014, Dependencies in + Statistical Hypothesis Tests for Climate Time Series. Bulletin of the + American Meteorological Society, 95 (11), 1666-1667. +} \keyword{datagen} + diff --git a/man/Filter.Rd b/man/Filter.Rd index 21807f5d..3e40f105 100644 --- a/man/Filter.Rd +++ b/man/Filter.Rd @@ -48,3 +48,4 @@ History:\cr 1.0 - 2012-02 (N. Manubens, \email{nicolau.manubens at ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/FitAcfCoef.Rd b/man/FitAcfCoef.Rd index 6de266e5..6ca51444 100644 --- a/man/FitAcfCoef.Rd +++ b/man/FitAcfCoef.Rd @@ -38,3 +38,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/FitAutocor.Rd b/man/FitAutocor.Rd index 2d623603..ff3ab943 100644 --- a/man/FitAutocor.Rd +++ b/man/FitAutocor.Rd @@ -35,3 +35,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/GenSeries.Rd b/man/GenSeries.Rd index 549b259e..9a49ed9d 100644 --- a/man/GenSeries.Rd +++ b/man/GenSeries.Rd @@ -34,3 +34,4 @@ History:\cr 1.0 - 2012-04 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/Histo2Hindcast.Rd b/man/Histo2Hindcast.Rd index 0f9bd18b..7000628a 100644 --- a/man/Histo2Hindcast.Rd +++ b/man/Histo2Hindcast.Rd @@ -79,3 +79,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/IniListDims.Rd b/man/IniListDims.Rd index 71369945..422a4c76 100644 --- a/man/IniListDims.Rd +++ b/man/IniListDims.Rd @@ -39,3 +39,4 @@ History:\cr 1.1 - 2015-03 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Improved } \keyword{datagen} + diff --git a/man/InsertDim.Rd b/man/InsertDim.Rd index e7e50d14..4cdc5377 100644 --- a/man/InsertDim.Rd +++ b/man/InsertDim.Rd @@ -34,3 +34,4 @@ History:\cr 1.1 - 2015-03 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Improvements } \keyword{datagen} + diff --git a/man/LeapYear.Rd b/man/LeapYear.Rd index 7504a27e..12b02b49 100644 --- a/man/LeapYear.Rd +++ b/man/LeapYear.Rd @@ -27,3 +27,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/Load.Rd b/man/Load.Rd index 6554f58b..c721e613 100644 --- a/man/Load.Rd +++ b/man/Load.Rd @@ -4,36 +4,15 @@ \alias{Load} \title{Loads Experimental And Observational Data} \usage{ -Load( - var, - exp = NULL, - obs = NULL, - sdates, - nmember = NULL, - nmemberobs = NULL, - nleadtime = NULL, - leadtimemin = 1, - leadtimemax = NULL, - storefreq = "monthly", - sampleperiod = 1, - lonmin = 0, - lonmax = 360, - latmin = -90, - latmax = 90, - output = "areave", - method = "conservative", - grid = NULL, - maskmod = vector("list", 15), - maskobs = vector("list", 15), - configfile = NULL, - varmin = NULL, - varmax = NULL, - silent = FALSE, - nprocs = NULL, - dimnames = NULL, - remapcells = 2, - path_glob_permissive = "partial" -) +Load(var, exp = NULL, obs = NULL, sdates, nmember = NULL, + nmemberobs = NULL, nleadtime = NULL, leadtimemin = 1, + leadtimemax = NULL, storefreq = "monthly", sampleperiod = 1, + lonmin = 0, lonmax = 360, latmin = -90, latmax = 90, + output = "areave", method = "conservative", grid = NULL, + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, silent = FALSE, + nprocs = NULL, dimnames = NULL, remapcells = 2, + path_glob_permissive = "partial") } \arguments{ \item{var}{Short name of the variable to load. It should coincide with the @@ -904,3 +883,4 @@ History:\cr 1.4 - 2016-01 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Added subsetting capabilities } \keyword{datagen} + diff --git a/man/Mean1Dim.Rd b/man/Mean1Dim.Rd index 6b45e1a7..613fc468 100644 --- a/man/Mean1Dim.Rd +++ b/man/Mean1Dim.Rd @@ -36,3 +36,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to R CRAN } \keyword{datagen} + diff --git a/man/MeanListDim.Rd b/man/MeanListDim.Rd index 2fdf8981..98e07c8e 100644 --- a/man/MeanListDim.Rd +++ b/man/MeanListDim.Rd @@ -33,3 +33,4 @@ History:\cr 1.1 - 2015-03 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Improved memory usage } \keyword{datagen} + diff --git a/man/NAO.Rd b/man/NAO.Rd index 34f36339..24d58830 100644 --- a/man/NAO.Rd +++ b/man/NAO.Rd @@ -4,14 +4,8 @@ \alias{NAO} \title{Computes the North Atlantic Oscillation (NAO) Index} \usage{ -NAO( - ano_exp = NULL, - ano_obs = NULL, - lon, - lat, - ftime_average = 2:4, - obsproj = TRUE -) +NAO(ano_exp = NULL, ano_obs = NULL, lon, lat, ftime_average = 2:4, + obsproj = TRUE) } \arguments{ \item{ano_exp}{Array of North Atlantic SLP (20N-80N, 80W-40E) forecast @@ -119,11 +113,6 @@ PlotBoxWhisker(nao$NAO_exp, nao$NAO_obs, "NAO index, DJF", "NAO index (PC1) TOS" } } -\references{ -Doblas-Reyes, F.J., Pavan, V. and Stephenson, D. (2003). The skill of - multi-model seasonal forecasts of the wintertime North Atlantic Oscillation. - Climate Dynamics, 21, 501-514. DOI: 10.1007/s00382-003-0350-4 -} \author{ History:\cr 0.1 - 2013-08 (F. Lienert, \email{flienert@ic3.cat}) - Original code\cr @@ -138,4 +127,10 @@ History:\cr 1.0 - 2016-03 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatted to CRAN } +\references{ +Doblas-Reyes, F.J., Pavan, V. and Stephenson, D. (2003). The skill of + multi-model seasonal forecasts of the wintertime North Atlantic Oscillation. + Climate Dynamics, 21, 501-514. DOI: 10.1007/s00382-003-0350-4 +} \keyword{datagen} + diff --git a/man/Plot2VarsVsLTime.Rd b/man/Plot2VarsVsLTime.Rd index 11af98a7..8ba44e4e 100644 --- a/man/Plot2VarsVsLTime.Rd +++ b/man/Plot2VarsVsLTime.Rd @@ -4,30 +4,12 @@ \alias{Plot2VarsVsLTime} \title{Plot Two Scores With Confidence Intervals In A Common Plot} \usage{ -Plot2VarsVsLTime( - var1, - var2, - toptitle = "", - ytitle = "", - monini = 1, - freq = 12, - nticks = NULL, - limits = NULL, - listexp = c("exp1", "exp2", "exp3"), - listvars = c("var1", "var2"), - biglab = FALSE, - hlines = NULL, - leg = TRUE, - siglev = FALSE, - sizetit = 1, - show_conf = TRUE, - fileout = "output_plot2varsvsltime.eps", - width = 8, - height = 5, - size_units = "in", - res = 100, - ... -) +Plot2VarsVsLTime(var1, var2, toptitle = "", ytitle = "", monini = 1, + freq = 12, nticks = NULL, limits = NULL, listexp = c("exp1", "exp2", + "exp3"), listvars = c("var1", "var2"), biglab = FALSE, hlines = NULL, + leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, + fileout = "output_plot2varsvsltime.eps", width = 8, height = 5, + size_units = "in", res = 100, ...) } \arguments{ \item{var1}{Matrix of dimensions (nexp/nmod, nltime).} @@ -138,3 +120,4 @@ History:\cr - Original code } \keyword{dynamic} + diff --git a/man/PlotACC.Rd b/man/PlotACC.Rd index 289fbf17..fc66200a 100644 --- a/man/PlotACC.Rd +++ b/man/PlotACC.Rd @@ -4,27 +4,11 @@ \alias{PlotACC} \title{Plot Plumes/Timeseries Of Anomaly Correlation Coefficients} \usage{ -PlotACC( - ACC, - sdates, - toptitle = "", - sizetit = 1, - ytitle = "", - limits = NULL, - legends = NULL, - freq = 12, - biglab = FALSE, - fill = FALSE, - linezero = FALSE, - points = TRUE, - vlines = NULL, - fileout = "output_PlotACC.eps", - width = 8, - height = 5, - size_units = "in", - res = 100, - ... -) +PlotACC(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", + limits = NULL, legends = NULL, freq = 12, biglab = FALSE, + fill = FALSE, linezero = FALSE, points = TRUE, vlines = NULL, + fileout = "output_PlotACC.eps", width = 8, height = 5, + size_units = "in", res = 100, ...) } \arguments{ \item{ACC}{ACC matrix with with dimensions:\cr @@ -138,3 +122,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{dynamic} + diff --git a/man/PlotAno.Rd b/man/PlotAno.Rd index 2ff2c46c..dd059310 100644 --- a/man/PlotAno.Rd +++ b/man/PlotAno.Rd @@ -4,30 +4,12 @@ \alias{PlotAno} \title{Plot Raw Or Smoothed Anomalies} \usage{ -PlotAno( - exp_ano, - obs_ano = NULL, - sdates, - toptitle = rep("", 15), - ytitle = rep("", 15), - limits = NULL, - legends = NULL, - freq = 12, - biglab = FALSE, - fill = TRUE, - memb = TRUE, - ensmean = TRUE, - linezero = FALSE, - points = FALSE, - vlines = NULL, - sizetit = 1, - fileout = paste0("output", 1:5, "_plotano.eps"), - width = 8, - height = 5, - size_units = "in", - res = 100, - ... -) +PlotAno(exp_ano, obs_ano = NULL, sdates, toptitle = rep("", 15), + ytitle = rep("", 15), limits = NULL, legends = NULL, freq = 12, + biglab = FALSE, fill = TRUE, memb = TRUE, ensmean = TRUE, + linezero = FALSE, points = FALSE, vlines = NULL, sizetit = 1, + fileout = paste0("output", 1:5, "_plotano.eps"), width = 8, height = 5, + size_units = "in", res = 100, ...) } \arguments{ \item{exp_ano}{Array containing the experimental data:\cr @@ -127,3 +109,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{dynamic} + diff --git a/man/PlotBoxWhisker.Rd b/man/PlotBoxWhisker.Rd index 9d602103..a536686b 100644 --- a/man/PlotBoxWhisker.Rd +++ b/man/PlotBoxWhisker.Rd @@ -4,24 +4,10 @@ \alias{PlotBoxWhisker} \title{Box-And-Whisker Plot of Time Series with Ensemble Distribution} \usage{ -PlotBoxWhisker( - exp, - obs, - toptitle = "", - ytitle = "", - monini = 1, - yearini = 0, - freq = 1, - expname = "exp 1", - obsname = "obs 1", - drawleg = TRUE, - fileout = "output_PlotBoxWhisker.ps", - width = 8, - height = 5, - size_units = "in", - res = 100, - ... -) +PlotBoxWhisker(exp, obs, toptitle = "", ytitle = "", monini = 1, + yearini = 0, freq = 1, expname = "exp 1", obsname = "obs 1", + drawleg = TRUE, fileout = "output_PlotBoxWhisker.ps", width = 8, + height = 5, size_units = "in", res = 100, ...) } \arguments{ \item{exp}{Forecast array of multi-member time series, e.g., the NAO index @@ -133,9 +119,6 @@ PlotBoxWhisker(nao$NAO_exp, nao$NAO_obs, "NAO index, DJF", "NAO index (PC1) TOS" monini = 12, yearini = 1985, freq = 1, "Exp. A", "Obs. X") } -} -\seealso{ -EOF, ProjectField, NAO } \author{ History:\cr @@ -144,4 +127,8 @@ History:\cr normalization for sake of clarity. 1.0 - 2016-03 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatting to R CRAN } +\seealso{ +EOF, ProjectField, NAO +} \keyword{datagen} + diff --git a/man/PlotClim.Rd b/man/PlotClim.Rd index f4fd7e1a..7ee001ee 100644 --- a/man/PlotClim.Rd +++ b/man/PlotClim.Rd @@ -4,26 +4,11 @@ \alias{PlotClim} \title{Plots Climatologies} \usage{ -PlotClim( - exp_clim, - obs_clim = NULL, - toptitle = "", - ytitle = "", - monini = 1, - freq = 12, - limits = NULL, - listexp = c("exp1", "exp2", "exp3"), - listobs = c("obs1", "obs2", "obs3"), - biglab = FALSE, - leg = TRUE, - sizetit = 1, - fileout = "output_plotclim.eps", - width = 8, - height = 5, - size_units = "in", - res = 100, - ... -) +PlotClim(exp_clim, obs_clim = NULL, toptitle = "", ytitle = "", + monini = 1, freq = 12, limits = NULL, listexp = c("exp1", "exp2", + "exp3"), listobs = c("obs1", "obs2", "obs3"), biglab = FALSE, + leg = TRUE, sizetit = 1, fileout = "output_plotclim.eps", width = 8, + height = 5, size_units = "in", res = 100, ...) } \arguments{ \item{exp_clim}{Matrix containing the experimental data with dimensions:\cr @@ -102,3 +87,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index c9db45b5..cb33fc60 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -4,72 +4,25 @@ \alias{PlotEquiMap} \title{Maps A Two-Dimensional Variable On A Cylindrical Equidistant Projection} \usage{ -PlotEquiMap( - var, - lon, - lat, - varu = NULL, - varv = NULL, - toptitle = NULL, - sizetit = NULL, - units = NULL, - brks = NULL, - cols = NULL, - bar_limits = NULL, - triangle_ends = NULL, - col_inf = NULL, - col_sup = NULL, - colNA = NULL, - color_fun = clim.palette(), - square = TRUE, - filled.continents = NULL, - coast_color = NULL, - coast_width = 1, - contours = NULL, - brks2 = NULL, - contour_lwd = 0.5, - contour_color = "black", - contour_lty = 1, - contour_label_scale = 1, - dots = NULL, - dot_symbol = 4, - dot_size = 1, - arr_subsamp = floor(length(lon)/30), - arr_scale = 1, - arr_ref_len = 15, - arr_units = "m/s", - arr_scale_shaft = 1, - arr_scale_shaft_angle = 1, - axelab = TRUE, - labW = FALSE, - intylat = 20, - intxlon = 20, - axes_tick_scale = 1, - axes_label_scale = 1, - drawleg = TRUE, - subsampleg = NULL, - bar_extra_labels = NULL, - draw_bar_ticks = TRUE, - draw_separators = FALSE, - triangle_ends_scale = 1, - bar_label_digits = 4, - bar_label_scale = 1, - units_scale = 1, - bar_tick_scale = 1, - bar_extra_margin = rep(0, 4), - boxlim = NULL, - boxcol = "purple2", - boxlwd = 5, - margin_scale = rep(1, 4), - title_scale = 1, - numbfig = NULL, - fileout = NULL, - width = 8, - height = 5, - size_units = "in", - res = 100, - ... -) +PlotEquiMap(var, lon, lat, varu = NULL, varv = NULL, toptitle = NULL, + sizetit = NULL, units = NULL, brks = NULL, cols = NULL, + bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, + col_sup = NULL, colNA = NULL, color_fun = clim.palette(), + square = TRUE, filled.continents = NULL, coast_color = NULL, + coast_width = 1, contours = NULL, brks2 = NULL, contour_lwd = 0.5, + contour_color = "black", contour_lty = 1, contour_label_scale = 1, + dots = NULL, dot_symbol = 4, dot_size = 1, + arr_subsamp = floor(length(lon)/30), arr_scale = 1, arr_ref_len = 15, + arr_units = "m/s", arr_scale_shaft = 1, arr_scale_shaft_angle = 1, + axelab = TRUE, labW = FALSE, intylat = 20, intxlon = 20, + axes_tick_scale = 1, axes_label_scale = 1, drawleg = TRUE, + subsampleg = NULL, bar_extra_labels = NULL, draw_bar_ticks = TRUE, + draw_separators = FALSE, triangle_ends_scale = 1, bar_label_digits = 4, + bar_label_scale = 1, units_scale = 1, bar_tick_scale = 1, + bar_extra_margin = rep(0, 4), boxlim = NULL, boxcol = "purple2", + boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, numbfig = NULL, + fileout = NULL, width = 8, height = 5, size_units = "in", res = 100, + ...) } \arguments{ \item{var}{Array with the values at each cell of a grid on a regular @@ -335,3 +288,4 @@ History:\cr and adapted to new ColorBar. } \keyword{dynamic} + diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index 3cb81d15..e4cf4ecf 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -4,52 +4,20 @@ \alias{PlotLayout} \title{Arrange and Fill Multi-Pannel Layouts With Optional Colour Bar} \usage{ -PlotLayout( - fun, - plot_dims, - var, - ..., - special_args = NULL, - nrow = NULL, - ncol = NULL, - toptitle = NULL, - row_titles = NULL, - col_titles = NULL, - bar_scale = 1, - title_scale = 1, - title_margin_scale = 1, - title_left_shift_scale = 1, - subtitle_scale = 1, - subtitle_margin_scale = 1, - brks = NULL, - cols = NULL, - drawleg = "S", - titles = NULL, - subsampleg = NULL, - bar_limits = NULL, - triangle_ends = NULL, - col_inf = NULL, - col_sup = NULL, - color_fun = clim.colors, - draw_bar_ticks = TRUE, - draw_separators = FALSE, - triangle_ends_scale = 1, - bar_extra_labels = NULL, - units = NULL, - units_scale = 1, - bar_label_scale = 1, - bar_tick_scale = 1, - bar_extra_margin = rep(0, 4), - bar_left_shift_scale = 1, - bar_label_digits = 4, - extra_margin = rep(0, 4), - fileout = NULL, - width = NULL, - height = NULL, - size_units = "in", - res = 100, - close_device = TRUE -) +PlotLayout(fun, plot_dims, var, ..., special_args = NULL, nrow = NULL, + ncol = NULL, toptitle = NULL, row_titles = NULL, col_titles = NULL, + bar_scale = 1, title_scale = 1, title_margin_scale = 1, + title_left_shift_scale = 1, subtitle_scale = 1, + subtitle_margin_scale = 1, brks = NULL, cols = NULL, drawleg = "S", + titles = NULL, subsampleg = NULL, bar_limits = NULL, + triangle_ends = NULL, col_inf = NULL, col_sup = NULL, + color_fun = clim.colors, draw_bar_ticks = TRUE, draw_separators = FALSE, + triangle_ends_scale = 1, bar_extra_labels = NULL, units = NULL, + units_scale = 1, bar_label_scale = 1, bar_tick_scale = 1, + bar_extra_margin = rep(0, 4), bar_left_shift_scale = 1, + bar_label_digits = 4, extra_margin = rep(0, 4), fileout = NULL, + width = NULL, height = NULL, size_units = "in", res = 100, + close_device = TRUE) } \arguments{ \item{fun}{Plot function (or name of the function) to be called on the @@ -80,12 +48,6 @@ applied to each of them. NAs can be passed to the list: a NA will yield a blank cell in the layout, which can be populated after (see .SwitchToFigure).} -\item{\dots}{Parameters to be sent to the plotting function 'fun'. If -multiple arrays are provided in 'var' and multiple functions are provided -in 'fun', the parameters provided through \dots will be sent to all the -plot functions, as common parameters. To specify concrete arguments for -each of the plot functions see parameter 'special_args'.} - \item{special_args}{List of sub-lists, each sub-list having specific extra arguments for each of the plot functions provided in 'fun'. If you want to fix a different value for each plot in the layout you can do so by @@ -202,6 +164,12 @@ the layout and a 'fileout' has been specified. This is useful to avoid closing the device when saving the layout into a file and willing to add extra elements or figures. Takes TRUE by default. Disregarded if no 'fileout' has been specified.} + +\item{\dots}{Parameters to be sent to the plotting function 'fun'. If +multiple arrays are provided in 'var' and multiple functions are provided +in 'fun', the parameters provided through \dots will be sent to all the +plot functions, as common parameters. To specify concrete arguments for +each of the plot functions see parameter 'special_args'.} } \value{ \item{brks}{ @@ -281,3 +249,4 @@ History:\cr 0.1 - 2016-08 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Original code } \keyword{dynamic} + diff --git a/man/PlotMatrix.Rd b/man/PlotMatrix.Rd index 88458856..70c1211e 100644 --- a/man/PlotMatrix.Rd +++ b/man/PlotMatrix.Rd @@ -4,28 +4,12 @@ \alias{PlotMatrix} \title{Function to convert any numerical table to a grid of coloured squares.} \usage{ -PlotMatrix( - var, - brks = NULL, - cols = NULL, - toptitle = NULL, - title.color = "royalblue4", - xtitle = NULL, - ytitle = NULL, - xlabels = NULL, - xvert = FALSE, - ylabels = NULL, - line = 3, - figure.width = 1, - legend = TRUE, - legend.width = 0.15, - xlab_dist = NULL, - ylab_dist = NULL, - fileout = NULL, - size_units = "px", - res = 100, - ... -) +PlotMatrix(var, brks = NULL, cols = NULL, toptitle = NULL, + title.color = "royalblue4", xtitle = NULL, ytitle = NULL, + xlabels = NULL, xvert = FALSE, ylabels = NULL, line = 3, + figure.width = 1, legend = TRUE, legend.width = 0.15, + xlab_dist = NULL, ylab_dist = NULL, fileout = NULL, size_units = "px", + res = 100, ...) } \arguments{ \item{var}{A numerical matrix containing the values to be displayed in a @@ -109,3 +93,4 @@ PlotMatrix(var = matrix(rnorm(n = 120, mean = 0.3), 10, 12), xlabels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) } + diff --git a/man/PlotSection.Rd b/man/PlotSection.Rd index 3dbe4fa1..f7447319 100644 --- a/man/PlotSection.Rd +++ b/man/PlotSection.Rd @@ -4,26 +4,10 @@ \alias{PlotSection} \title{Plots A Vertical Section} \usage{ -PlotSection( - var, - horiz, - depth, - toptitle = "", - sizetit = 1, - units = "", - brks = NULL, - cols = NULL, - axelab = TRUE, - intydep = 200, - intxhoriz = 20, - drawleg = TRUE, - fileout = NULL, - width = 8, - height = 5, - size_units = "in", - res = 100, - ... -) +PlotSection(var, horiz, depth, toptitle = "", sizetit = 1, units = "", + brks = NULL, cols = NULL, axelab = TRUE, intydep = 200, + intxhoriz = 20, drawleg = TRUE, fileout = NULL, width = 8, + height = 5, size_units = "in", res = 100, ...) } \arguments{ \item{var}{Matrix to plot with (longitude/latitude, depth) dimensions.} @@ -91,3 +75,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{dynamic} + diff --git a/man/PlotStereoMap.Rd b/man/PlotStereoMap.Rd index 7559f6f7..3bf2f69c 100644 --- a/man/PlotStereoMap.Rd +++ b/man/PlotStereoMap.Rd @@ -4,53 +4,19 @@ \alias{PlotStereoMap} \title{Maps A Two-Dimensional Variable On A Polar Stereographic Projection} \usage{ -PlotStereoMap( - var, - lon, - lat, - latlims = c(60, 90), - toptitle = NULL, - sizetit = NULL, - units = NULL, - brks = NULL, - cols = NULL, - bar_limits = NULL, - triangle_ends = NULL, - col_inf = NULL, - col_sup = NULL, - colNA = NULL, - color_fun = clim.palette(), - filled.continents = FALSE, - coast_color = NULL, - coast_width = 1, - dots = NULL, - dot_symbol = 4, - dot_size = 0.8, - intlat = 10, - drawleg = TRUE, - subsampleg = NULL, - bar_extra_labels = NULL, - draw_bar_ticks = TRUE, - draw_separators = FALSE, - triangle_ends_scale = 1, - bar_label_digits = 4, - bar_label_scale = 1, - units_scale = 1, - bar_tick_scale = 1, - bar_extra_margin = rep(0, 4), - boxlim = NULL, - boxcol = "purple2", - boxlwd = 5, - margin_scale = rep(1, 4), - title_scale = 1, - numbfig = NULL, - fileout = NULL, - width = 6, - height = 5, - size_units = "in", - res = 100, - ... -) +PlotStereoMap(var, lon, lat, latlims = c(60, 90), toptitle = NULL, + sizetit = NULL, units = NULL, brks = NULL, cols = NULL, + bar_limits = NULL, triangle_ends = NULL, col_inf = NULL, + col_sup = NULL, colNA = NULL, color_fun = clim.palette(), + filled.continents = FALSE, coast_color = NULL, coast_width = 1, + dots = NULL, dot_symbol = 4, dot_size = 0.8, intlat = 10, + drawleg = TRUE, subsampleg = NULL, bar_extra_labels = NULL, + draw_bar_ticks = TRUE, draw_separators = FALSE, triangle_ends_scale = 1, + bar_label_digits = 4, bar_label_scale = 1, units_scale = 1, + bar_tick_scale = 1, bar_extra_margin = rep(0, 4), boxlim = NULL, + boxcol = "purple2", boxlwd = 5, margin_scale = rep(1, 4), + title_scale = 1, numbfig = NULL, fileout = NULL, width = 6, + height = 5, size_units = "in", res = 100, ...) } \arguments{ \item{var}{Array with the values at each cell of a grid on a regular @@ -226,3 +192,4 @@ History:\cr border and Constantin boxes. } \keyword{dynamic} + diff --git a/man/PlotVsLTime.Rd b/man/PlotVsLTime.Rd index 402414d1..2c71e9fa 100644 --- a/man/PlotVsLTime.Rd +++ b/man/PlotVsLTime.Rd @@ -4,29 +4,12 @@ \alias{PlotVsLTime} \title{Plots A Score Along The Forecast Time With Its Confidence Interval} \usage{ -PlotVsLTime( - var, - toptitle = "", - ytitle = "", - monini = 1, - freq = 12, - nticks = NULL, - limits = NULL, - listexp = c("exp1", "exp2", "exp3"), - listobs = c("obs1", "obs2", "obs3"), - biglab = FALSE, - hlines = NULL, - leg = TRUE, - siglev = FALSE, - sizetit = 1, - show_conf = TRUE, - fileout = "output_plotvsltime.eps", - width = 8, - height = 5, - size_units = "in", - res = 100, - ... -) +PlotVsLTime(var, toptitle = "", ytitle = "", monini = 1, freq = 12, + nticks = NULL, limits = NULL, listexp = c("exp1", "exp2", "exp3"), + listobs = c("obs1", "obs2", "obs3"), biglab = FALSE, hlines = NULL, + leg = TRUE, siglev = FALSE, sizetit = 1, show_conf = TRUE, + fileout = "output_plotvsltime.eps", width = 8, height = 5, + size_units = "in", res = 100, ...) } \arguments{ \item{var}{Matrix containing any Prediction Score with dimensions:\cr @@ -150,3 +133,4 @@ History:\cr 1.0 - 2013-11 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{dynamic} + diff --git a/man/ProbBins.Rd b/man/ProbBins.Rd index 56cf0511..6df49cc2 100644 --- a/man/ProbBins.Rd +++ b/man/ProbBins.Rd @@ -4,15 +4,8 @@ \alias{ProbBins} \title{Computes Probabilistic Information of a Forecast Relative to a Threshold or a Quantile} \usage{ -ProbBins( - ano, - fcyr = "all", - thr, - quantile = TRUE, - posdates = 3, - posdim = 2, - compPeriod = "Full period" -) +ProbBins(ano, fcyr = "all", thr, quantile = TRUE, posdates = 3, + posdim = 2, compPeriod = "Full period") } \arguments{ \item{ano}{Array of anomalies from Ano().\cr @@ -93,3 +86,4 @@ History:\cr 2.1 - 2017-02 (V. Torralba and N. Manubens, \email{veronica.torralba@bsc.es}) - Fix bug with cross-validation } \keyword{datagen} + diff --git a/man/ProjectField.Rd b/man/ProjectField.Rd index 7dd77123..7b2e9e93 100644 --- a/man/ProjectField.Rd +++ b/man/ProjectField.Rd @@ -74,9 +74,6 @@ for (i in 1:dim(sampleData$mod)[2]) { ylim = c(-15000, 15000)) } -} -\seealso{ -EOF, NAO, PlotBoxWhisker } \author{ History:\cr @@ -108,4 +105,8 @@ multiplied by W. Getting input dimensions. 1.0 - 2016-03 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatting to R CRAN\cr (J.-P. Baudouin, \email{jean.baudouin@bsc.es}) - Example code and testing } +\seealso{ +EOF, NAO, PlotBoxWhisker +} \keyword{datagen} + diff --git a/man/RMS.Rd b/man/RMS.Rd index 877300fa..715f84d1 100644 --- a/man/RMS.Rd +++ b/man/RMS.Rd @@ -1,20 +1,12 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/RMS.R \name{RMS} -\alias{RMS} \alias{.RMS} +\alias{RMS} \title{Computes Root Mean Square Error} \usage{ -RMS( - var_exp, - var_obs, - posloop = 1, - posRMS = 2, - compROW = NULL, - limits = NULL, - siglev = 0.95, - conf = TRUE -) +RMS(var_exp, var_obs, posloop = 1, posRMS = 2, compROW = NULL, + limits = NULL, siglev = 0.95, conf = TRUE) .RMS(exp, obs, siglev = 0.95, conf = TRUE) } @@ -127,3 +119,4 @@ History:\cr 1.1 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} + diff --git a/man/RMSSS.Rd b/man/RMSSS.Rd index 8bc0d803..f602702b 100644 --- a/man/RMSSS.Rd +++ b/man/RMSSS.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/RMSSS.R \name{RMSSS} -\alias{RMSSS} \alias{.RMSSS} +\alias{RMSSS} \title{Computes Root Mean Square Skill Score} \usage{ RMSSS(var_exp, var_obs, posloop = 1, posRMS = 2, pval = TRUE) @@ -93,3 +93,4 @@ History:\cr 1.1 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} + diff --git a/man/RatioRMS.Rd b/man/RatioRMS.Rd index b1abbca1..44d13dbb 100644 --- a/man/RatioRMS.Rd +++ b/man/RatioRMS.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/RatioRMS.R \name{RatioRMS} -\alias{RatioRMS} \alias{.RatioRMS} +\alias{RatioRMS} \title{Computes the Ratio Between The RMSE of Two Experiments} \usage{ RatioRMS(var_exp1, var_exp2, var_obs, posRMS = 1, pval = TRUE) @@ -121,3 +121,4 @@ History:\cr 1.1 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} + diff --git a/man/RatioSDRMS.Rd b/man/RatioSDRMS.Rd index 97efe6da..09484740 100644 --- a/man/RatioSDRMS.Rd +++ b/man/RatioSDRMS.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/RatioSDRMS.R \name{RatioSDRMS} -\alias{RatioSDRMS} \alias{.RatioSDRMS} +\alias{RatioSDRMS} \title{Computes the ratio between the ensemble spread and RMSE} \usage{ RatioSDRMS(var_exp, var_obs, pval = TRUE) @@ -86,3 +86,4 @@ History:\cr 1.1 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapted to veriApply() } \keyword{datagen} + diff --git a/man/Regression.Rd b/man/Regression.Rd index a3763150..55646576 100644 --- a/man/Regression.Rd +++ b/man/Regression.Rd @@ -73,3 +73,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/SVD.Rd b/man/SVD.Rd index bbbcaa49..698df952 100644 --- a/man/SVD.Rd +++ b/man/SVD.Rd @@ -4,15 +4,8 @@ \alias{SVD} \title{Single Value Decomposition (Maximum Covariance Analysis)} \usage{ -SVD( - vary, - varx, - laty = NULL, - latx = NULL, - nmodes = 15, - corr = FALSE, - weight = TRUE -) +SVD(vary, varx, laty = NULL, latx = NULL, nmodes = 15, corr = FALSE, + weight = TRUE) } \arguments{ \item{vary}{Array containing the anomalies field for the predictor. The @@ -124,3 +117,4 @@ History:\cr 1.0 - 2016-04 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Formatting to R CRAN } \keyword{datagen} + diff --git a/man/Season.Rd b/man/Season.Rd index 76f64053..cc97941c 100644 --- a/man/Season.Rd +++ b/man/Season.Rd @@ -54,3 +54,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/SelIndices.Rd b/man/SelIndices.Rd index ab3ca88e..dbf34da2 100644 --- a/man/SelIndices.Rd +++ b/man/SelIndices.Rd @@ -37,3 +37,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/Smoothing.Rd b/man/Smoothing.Rd index 492370e9..4fa9c596 100644 --- a/man/Smoothing.Rd +++ b/man/Smoothing.Rd @@ -47,3 +47,4 @@ History:\cr making it able to work on arrays of any number of dimensions. } \keyword{datagen} + diff --git a/man/Spectrum.Rd b/man/Spectrum.Rd index a3fce568..de5a2e5e 100644 --- a/man/Spectrum.Rd +++ b/man/Spectrum.Rd @@ -48,3 +48,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/Spread.Rd b/man/Spread.Rd index a9f3125b..f84cecf3 100644 --- a/man/Spread.Rd +++ b/man/Spread.Rd @@ -93,3 +93,4 @@ History:\cr 1.0 - 2013-09 (N. Manubens, \email{nicolau.manubens@ic3.cat}) - Formatting to CRAN } \keyword{datagen} + diff --git a/man/StatSeasAtlHurr.Rd b/man/StatSeasAtlHurr.Rd index 053698f7..9822eb90 100644 --- a/man/StatSeasAtlHurr.Rd +++ b/man/StatSeasAtlHurr.Rd @@ -66,6 +66,10 @@ hr_count <- StatSeasAtlHurr(atlano = AtlAno, hrvar = 'HR') print(hr_count$mean) +} +\author{ +History:\cr +0.1 - 2015-11 (Louis-Philippe Caron, \email{louis-philippe.caron@bsc.es}) - Original code } \references{ Villarini et al. (2010) Mon Wea Rev, 138, 2681-2705.\cr @@ -77,8 +81,5 @@ Caron, L.-P. et al. (2014) Multi-year prediction skill of Atlantic hurricane activity in CMIP5 decadal hindcasts. Climate Dynamics, 42, 2675-2690. doi:10.1007/s00382-013-1773-1. } -\author{ -History:\cr -0.1 - 2015-11 (Louis-Philippe Caron, \email{louis-philippe.caron@bsc.es}) - Original code -} \keyword{datagen} + diff --git a/man/Subset.Rd b/man/Subset.Rd index 570cd732..bccec4ac 100644 --- a/man/Subset.Rd +++ b/man/Subset.Rd @@ -45,3 +45,4 @@ PlotLayout(PlotEquiMap, c('lat', 'lon'), subset, } \keyword{datagen} + diff --git a/man/ToyModel.Rd b/man/ToyModel.Rd index 5eee0393..ca47b449 100644 --- a/man/ToyModel.Rd +++ b/man/ToyModel.Rd @@ -7,18 +7,8 @@ components of a forecast: (1) predictabiltiy (2) forecast error (3) non-stationarity and (4) ensemble generation. The forecast can be computed for real observations or observations generated artifically.} \usage{ -ToyModel( - alpha = 0.1, - beta = 0.4, - gamma = 1, - sig = 1, - trend = 0, - nstartd = 30, - nleadt = 4, - nmemb = 10, - obsini = NULL, - fxerr = NULL -) +ToyModel(alpha = 0.1, beta = 0.4, gamma = 1, sig = 1, trend = 0, + nstartd = 30, nleadt = 4, nmemb = 10, obsini = NULL, fxerr = NULL) } \arguments{ \item{alpha}{Predicabiltiy of the forecast on the observed residuals @@ -135,3 +125,4 @@ History:\cr 1.1 - 2016-02 (O.Bellprat) - Include security check for parameters } \keyword{datagen} + diff --git a/man/Trend.Rd b/man/Trend.Rd index b4e0ba36..3b7f7bfd 100644 --- a/man/Trend.Rd +++ b/man/Trend.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/Trend.R \name{Trend} -\alias{Trend} \alias{.Trend} +\alias{Trend} \title{Computes the Trend of the Ensemble Mean} \usage{ Trend(var, posTR = 2, interval = 1, siglev = 0.95, conf = TRUE) @@ -78,3 +78,4 @@ History:\cr 2.0 - 2017-02 (A. Hunter, \email{alasdair.hunter@bsc.es}) - Adapt to veriApply() } \keyword{datagen} + diff --git a/man/UltimateBrier.Rd b/man/UltimateBrier.Rd index 518a60cc..46fe124c 100644 --- a/man/UltimateBrier.Rd +++ b/man/UltimateBrier.Rd @@ -4,17 +4,9 @@ \alias{UltimateBrier} \title{Computes Brier Scores} \usage{ -UltimateBrier( - ano_exp, - ano_obs, - posdatasets = 1, - posmemb = 2, - posdates = 3, - quantile = TRUE, - thr = c(5/100, 95/100), - type = "BS", - decomposition = TRUE -) +UltimateBrier(ano_exp, ano_obs, posdatasets = 1, posmemb = 2, + posdates = 3, quantile = TRUE, thr = c(5/100, 95/100), type = "BS", + decomposition = TRUE) } \arguments{ \item{ano_exp}{Array of forecast anomalies, as provided by \code{Ano()}. @@ -132,3 +124,4 @@ History:\cr N. Manubens, \email{nicolau.manubens@bsc.es}) - First version } \keyword{datagen} + diff --git a/man/clim.palette.Rd b/man/clim.palette.Rd index e67994f8..95f8407c 100644 --- a/man/clim.palette.Rd +++ b/man/clim.palette.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/clim.palette.R \name{clim.palette} -\alias{clim.palette} \alias{clim.colors} +\alias{clim.palette} \title{Generate Climate Color Palettes} \usage{ clim.palette(palette = "bluered") @@ -35,3 +35,4 @@ History:\cr 0.0 - 2016-01 (N. Manubens, \email{nicolau.manubens@bsc.es}) - Original code. } \keyword{datagen} + diff --git a/man/s2dverification.Rd b/man/s2dverification.Rd index fe175f25..698fa4ed 100644 --- a/man/s2dverification.Rd +++ b/man/s2dverification.Rd @@ -26,14 +26,6 @@ Check an overview of the package functionalities and its modules at \url{https://earth.bsc.es/gitlab/es/s2dverification/wikis/home}. For more information load the package and check the help for each function or the documentation attached to the package. -} -\seealso{ -Useful links: -\itemize{ - \item \url{https://earth.bsc.es/gitlab/es/s2dverification/wikis/home} - \item Report bugs at \url{https://earth.bsc.es/gitlab/es/s2dverification/issues} -} - } \author{ Nicolau Manubens \email{nicolau.manubens@bsc.es} @@ -41,3 +33,4 @@ Nicolau Manubens \email{nicolau.manubens@bsc.es} \keyword{datagen} \keyword{dynamic} \keyword{package} + diff --git a/man/sampleDepthData.Rd b/man/sampleDepthData.Rd index 3292f5c6..974fe6bd 100644 --- a/man/sampleDepthData.Rd +++ b/man/sampleDepthData.Rd @@ -32,3 +32,4 @@ Its name within IC3 local database is 'i00k'. Nicolau Manubens \email{nicolau.manubens@bsc.es} } \keyword{data} + diff --git a/man/sampleMap.Rd b/man/sampleMap.Rd index 7286b8a6..d33ab829 100644 --- a/man/sampleMap.Rd +++ b/man/sampleMap.Rd @@ -47,3 +47,4 @@ Check the documentation on 'Load()' in the package 's2dverification' for more in Nicolau Manubens \email{nicolau.manubens@bsc.es} } \keyword{datasets} + diff --git a/man/sampleTimeSeries.Rd b/man/sampleTimeSeries.Rd index 4871a928..ce2c6395 100644 --- a/man/sampleTimeSeries.Rd +++ b/man/sampleTimeSeries.Rd @@ -51,3 +51,4 @@ Check the documentation on 'Load()' in the package 's2dverification' for more in Nicolau Manubens \email{nicolau.manubens@bsc.es} } \keyword{datasets} + -- GitLab From fef8ff4adc6a516fba4f6c5e14ba9ad641cdaf3e Mon Sep 17 00:00:00 2001 From: nperez Date: Wed, 21 Oct 2020 20:36:08 +0200 Subject: [PATCH 22/23] Uses the first expas reference --- R/Load.R | 105 ++++++++++++++++++++++------------ tests/testthat/test-Load.R | 114 ++++++++++++++++++++++--------------- 2 files changed, 138 insertions(+), 81 deletions(-) diff --git a/R/Load.R b/R/Load.R index edb55eab..eec1e3a7 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1443,6 +1443,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, looking_time <- .LoadDataFile(work_piecetime, explore_dims = TRUE, silent = silent) first_time_step_list <- c(first_time_step_list, list(looking_time$time_dim)) + print(first_time_step_list) } # If the dimensions of the output matrices are still to define, we try to read # the metadata of the data file that corresponds to the current iteration @@ -1538,6 +1539,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, jmember <- jmember + 1 } } else { + print("HERE") work_piece <- list(filename = .ConfigReplaceVariablesInString(quasi_final_path, replace_values), namevar = namevar, indices = c(1, 1, jsdate, jmod), nmember = nmember[jmod], leadtimes = leadtimes, mask = maskmod[[jmod]], @@ -1590,6 +1592,10 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, leadtimes <- seq(leadtimemin, leadtimemax, sampleperiod) } # If there are differences in the first time stamp in exp files: + print("INFO") + print(exp_work_pieces) + print("details") + print(leadtimemax) if (!is.null(exp)) { in_date <- lapply(first_time_step_list, function(x) { origin <- as.POSIXct( @@ -1612,7 +1618,34 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (max(unlist(in_date)) > 1) { leadtimes <- seq(exp_first_time_step, leadtimemax + max(unlist(in_date)) - 1, sampleperiod) - } + } + if (leadtimemin > 1 & length(in_date) > 1) { + lags <- lapply(in_date, function(x) {x - in_date[[1]]}) + new_leadtimemin <- lapply(lags, function(x) {leadtimemin - x}) + new_leadtimemax <- lapply(lags, function(x) {leadtimemax - x}) + jmod <- 2 + npieces <- length(exp_work_pieces)/nmod + while (jmod <= nmod) { + jpiece <- 1 + while (jpiece <= npieces) { + print(npieces * (jmod - 1) + jpiece) + exp_work_pieces[[npieces * (jmod - 1) + jpiece]]$leadtime <- + seq(new_leadtime[[jmod]], new_leadtimemax, sampleperiod) + } + } + } + print(exp_work_pieces) + lag <- 1 - in_date[[1]] + print(lag) + print(leadtimemin) + print(leadtimemax) + print(in_date) + leadtimes <- seq(leadtimemin - lag, leadtimemax #+ max(unlist(in_date)) + lag, + - lag, + sampleperiod) + exp_first_time_step <- leadtimemin - lag + print(leadtimes) + print(exp_first_time_step) } # Now we start iterating over observations. We try to find the output matrix # dimensions and we build anyway the work pieces corresponding to the observational @@ -1778,13 +1811,13 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, ## The first time step in exp could be different from sdate: if (jleadtime == 1 & !is.null(exp)) { - if (is.null(first_time_step_list[[1]])) { + if (is.null(first_time_step_list[[1]])) { stop("Check 'time' variable in the experimental files ", "since not units or first time step have been found.") } else { - if (exp_first_time_step > 1) { - day <- exp_first_time_step - } + if (in_date[[1]] > 1) { + day <- leadtimes[1] + } } } obs_file_indices <- seq(day, min(days_in_month, @@ -2230,37 +2263,37 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) number_ftime <- dim_obs[["ftime"]] } } - if (!is.null(exp)) { - if (any(in_date > 1) & length(in_date) > 1 & in_date[[1]] > 1) { - .warning(paste("There is at least one experiment with first timestamp in ", - "file one or more days ahead from the start date. The data ", - "could containg missing values.")) - pos_max <- max(unlist(in_date)) - 1 - empty_slice <- array(NA, c(ftime = 1, dim(mod_data[1,,,1,,]))) - empty_slice <- .aperm2(empty_slice, c(2, 3, 1, 4, 5)) - new_data <- lapply(1:length(in_date), function(x) { - pos <- in_date[[x]] - 1 - res <- mod_data[x,,,,,] - if (pos > 0) { - while (pos > 0) { - res <- abind(empty_slice, res, along = 3) - pos <- pos - 1 - } - } else { - while(pos < pos_max) { - res <- abind(res, empty_slice, along = 3) - pos <- pos + 1 - } - } - return(res) - }) - new_data <- abind(new_data, along = 6) - mod_data <- .aperm2(new_data, c(6,1,2,3,4,5)) - names(dim(mod_data)) <- names(dim_exp) - attr(mod_data, 'dimensions') <- names(dim_exp) - number_ftime <- dim(mod_data)[["ftime"]] - } - } + #if (!is.null(exp)) { + # if (any(in_date > 1) & length(in_date) > 1 & in_date[[1]] > 1) { + # .warning(paste("There is at least one experiment with first timestamp in ", + # "file one or more days ahead from the start date. The data ", + # "could containg missing values.")) + # pos_max <- max(unlist(in_date)) - 1 + # empty_slice <- array(NA, c(ftime = 1, dim(mod_data[1,,,1,,]))) + # empty_slice <- .aperm2(empty_slice, c(2, 3, 1, 4, 5)) + # new_data <- lapply(1:length(in_date), function(x) { + # pos <- in_date[[x]] - 1 + # res <- mod_data[x,,,,,] + # if (pos > 0) { + # while (pos > 0) { + # res <- abind(empty_slice, res, along = 3) + # pos <- pos - 1 + # } + # } else { + # while(pos < pos_max) { + # res <- abind(res, empty_slice, along = 3) + # pos <- pos + 1 + # } + # } + # return(res) + # }) + # new_data <- abind(new_data, along = 6) + # mod_data <- .aperm2(new_data, c(6,1,2,3,4,5)) + # names(dim(mod_data)) <- names(dim_exp) + # attr(mod_data, 'dimensions') <- names(dim_exp) + # number_ftime <- dim(mod_data)[["ftime"]] + # } + # } if (is.null(latitudes)) { lat <- 0 attr(lat, 'cdo_grid_name') <- 'none' diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index 57f62b0a..ce71f5b0 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -1,5 +1,19 @@ context("Testing Load with ECMWF System5c3s daily data") test_that("First time step is correctly interpreted:", { + s2dv_system5 <- s2dv::Load(var = 'prlr', + exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 5,leadtimemin = 1, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) system5 <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') @@ -14,7 +28,7 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - + expect_equal(system5$mod, s2dv_system5$mod) data <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), @@ -53,11 +67,11 @@ test_that("First time step is correctly interpreted:", { expect_equal(data$mod, system5$mod) - obs <- Load(var = 'prlr', exp = NULL, + era5 <- Load(var = 'prlr', exp = NULL, obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), sdates = c('19931101', '19941101'), nmember = 1, leadtimemin = 1, - leadtimemax = 2, + leadtimemax = 215, storefreq = "daily", sampleperiod = 1, latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, output = 'lonlat', nprocs = 1, @@ -68,8 +82,8 @@ test_that("First time step is correctly interpreted:", { remapcells = 2, path_glob_permissive = 'partial', nmemberobs = 1, nleadtime = NULL) # The values of observation when loading exp and obs simultaneously corresponds to the second day of the observations in the file: - expect_equal(data$obs[1,1,1,1,,], obs$obs[1,1,1,2,,]) - expect_equal(data$obs[1,1,2,1,,], obs$obs[1,1,2,2,,]) + expect_equal(data$obs[1,1,1,,,], era5$obs[1,1,1,2:215,,]) + expect_equal(data$obs[1,1,2,,,], era5$obs[1,1,2,2:215,,]) # Test when 2 observational datasets are requested: @@ -77,7 +91,7 @@ test_that("First time step is correctly interpreted:", { exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc'), list(name = 'erainterim')), sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') - nmember = 5,leadtimemin = 1, + nmember = 5, leadtimemin = 1, leadtimemax = NULL, storefreq = "daily", sampleperiod = 1, latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, @@ -88,15 +102,19 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - - expect_equal(data$obs[1,1,1,1,,], obs$obs[1,1,1,2,,]) - expect_equal(data$obs[1,1,2,1,,], obs$obs[1,1,2,2,,]) + expect_equal(dim(data$obs), c(dataset = 2, member = 1, sdate = 2, ftime = 214, + lat = 8, lon = 8)) + expect_equal(dim(data$mod), c(dataset = 1, member = 5, sdate = 2, ftime = 214, + lat = 8, lon = 8)) + expect_equal(sum(is.na(data$mod)), 0) + expect_equal(sum(is.na(data$obs)), 0) + expect_equal(data$obs[1,1,,,,], era5$obs[1,1,,2:215,,]) expect_equal(system5$mod, data$mod) eraint <- Load(var = 'prlr', exp = NULL, obs = list(list(name = 'erainterim')), sdates = c('19931101', '19941101'), nmember = 1, leadtimemin = 1, - leadtimemax = 2, + leadtimemax = 215, storefreq = "daily", sampleperiod = 1, latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, output = 'lonlat', nprocs = 1, @@ -106,8 +124,7 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = 1, nleadtime = NULL) - expect_equal(data$obs[2,1,1,1,,], eraint$obs[1,1,1,2,,]) - expect_equal(data$obs[2,1,2,1,,], eraint$obs[1,1,2,2,,]) + expect_equal(data$obs[2,1,,,,], eraint$obs[1,1,,2:215,,]) # Test for 2 experimental datasets data <- Load(var = 'prlr', @@ -126,49 +143,31 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - + expect_equal(dim(data$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 214, + lat = 8, lon = 8)) + expect_equal(dim(data$mod), c(dataset = 2, member = 5, sdate = 2, ftime = 214, + lat = 8, lon = 8)) expect_equal(sum(is.na(data$obs)), 0) - expect_equal(sum(is.na(data$mod[1,,,-1,,])), 0) - expect_equal(sum(is.na(data$mod[2,,,-215,,])), 0) - expect_equal(sum(is.na(data$mod[1,,,1,,])), 640) - expect_equal(sum(is.na(data$mod[2,,,215,,])), 640) - dates <- c(seq(as.POSIXct("1993-11-01", tz = 'UTC'), + expect_equal(sum(is.na(data$mod)), 0) + dates <- c(seq(as.POSIXct("1993-11-02", tz = 'UTC'), as.POSIXct("1994-06-03", tz = 'UTC'), "d"), - seq(as.POSIXct("1994-11-01", tz = 'UTC'), + seq(as.POSIXct("1994-11-02", tz = 'UTC'), as.POSIXct("1995-06-03", tz = 'UTC'), "d")) attributes(dates)$tzone <- 'UTC' expect_equal(data$Dates$start, dates) - dates <- c(seq(as.POSIXct("1993-11-02", tz = 'UTC'), + dates <- c(seq(as.POSIXct("1993-11-03", tz = 'UTC'), as.POSIXct("1994-06-04", tz = 'UTC'), "d"), - seq(as.POSIXct("1994-11-02", tz = 'UTC'), + seq(as.POSIXct("1994-11-03", tz = 'UTC'), as.POSIXct("1995-06-04", tz = 'UTC'), "d")) attributes(dates)$tzone <- 'UTC' expect_equal(data$Dates$end, dates) - - obs <- Load(var = 'prlr', exp = NULL, - obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), - sdates = c('19931101', '19941101'), - nmember = 1, leadtimemin = 1, - leadtimemax = 215, - storefreq = "daily", sampleperiod = 1, - latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, - output = 'lonlat', nprocs = 1, - method = 'conservative', grid = 'r360x181', - maskmod = vector("list", 15), maskobs = vector("list", 15), - configfile = NULL, varmin = NULL, varmax = NULL, - silent = FALSE, dimnames = NULL, - remapcells = 2, path_glob_permissive = 'partial', - nmemberobs = 1, nleadtime = NULL) - - expect_equal(dim(obs$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 215, - lat = 8, lon = 8)) - expect_equal(obs$obs, data$obs) - expect_equal(system5$exp, data$exp[1,,,-1,,]) + expect_equal(data$obs[,,,,,], era5$obs[,,,2:215,,]) + expect_equal(system5$exp, data$exp[1,,,,,]) system4 <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS4', path = "/esarchive/exp/ecmwf/system4_m1/$STORE_FREQ$/$VAR_NAME$/$VAR_NAME$_$START_DATE$.nc")), sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') - nmember = 5,leadtimemin = 1, + nmember = 1, leadtimemin = 1, leadtimemax = NULL, storefreq = "daily", sampleperiod = 1, latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, @@ -180,8 +179,8 @@ test_that("First time step is correctly interpreted:", { remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - expect_equal(system4$exp, data$exp[2,,,-215,,]) - expect_equal(system4$Dates$start, data$Dates$start) + expect_equal(system4$exp, data$exp[2,,,,,]) + expect_equal(system4$Dates$start[c(-1,-216)], data$Dates$start) # Test for 2 experimental datasets oposite order @@ -203,9 +202,13 @@ test_that("First time step is correctly interpreted:", { nmemberobs = NULL, nleadtime = NULL) expect_equal(dim(data$mod), c(dataset = 2, member = 5, sdate = 2, ftime = 215, lat = 8, lon = 8)) + expect_equal(dim(data$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 215, + lat = 8, lon = 8)) expect_equal(sum(is.na(data$mod[1,,,,,])), 0) + expect_equal(sum(is.na(data$mod[2,,,-215,,])),0) + expect_equal(sum(is.na(data$mod[2,,,215,,])), 640) expect_equal(data$Dates$start, system4$Dates$start) - + expect_equal(data$obs, era5$obs) # Test leadtimemin > 1 data <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc"), @@ -225,4 +228,25 @@ test_that("First time step is correctly interpreted:", { nmemberobs = NULL, nleadtime = NULL) expect_equal(system4$mod[1,1,1,2:214,,], data$mod[2,1,1,1:213,,]) expect_equal(system5$mod[1,1,1,2:214,,], data$mod[1,1,1,2:214,,]) + + + data <- Load(var = 'prlr', + exp = list(list(name = 'ecmwfS4', path = "/esarchive/exp/ecmwf/system4_m1/$STORE_FREQ$/$VAR_NAME$/$VAR_NAME$_$START_DATE$.nc"), + list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), + obs = list(list(name = 'era5', path = '/esarchive/recon/ecmwf/era5/$STORE_FREQ$_mean/$VAR_NAME$_f1h-r1440x721cds/$VAR_NAME$_$YEAR$$MONTH$.nc')), + sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') + nmember = 5,leadtimemin = 2, + leadtimemax = NULL, + storefreq = "daily", sampleperiod = 1, + latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, + output = 'lonlat', nprocs = 1, + method = 'conservative', grid = 'r360x181', + maskmod = vector("list", 15), maskobs = vector("list", 15), + configfile = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, dimnames = NULL, + remapcells = 2, path_glob_permissive = 'partial', + nmemberobs = NULL, nleadtime = NULL) + expect_equal(system4$mod[1,1,1,2:215,,], data$mod[1,1,1,1:214,,]) + expect_equal(system5$mod[1,1,1,1:214,,], data$mod[2,1,1,1:24,,]) + }) -- GitLab From c2eb834e6db3fd07cd50e296669b953fbdc78bbb Mon Sep 17 00:00:00 2001 From: nperez Date: Thu, 22 Oct 2020 16:33:48 +0200 Subject: [PATCH 23/23] all tests completed --- R/Load.R | 63 +++++------------------------------ tests/testthat/test-Load.R | 68 +++++++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 77 deletions(-) diff --git a/R/Load.R b/R/Load.R index eec1e3a7..b5600af2 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1443,7 +1443,6 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, looking_time <- .LoadDataFile(work_piecetime, explore_dims = TRUE, silent = silent) first_time_step_list <- c(first_time_step_list, list(looking_time$time_dim)) - print(first_time_step_list) } # If the dimensions of the output matrices are still to define, we try to read # the metadata of the data file that corresponds to the current iteration @@ -1539,7 +1538,6 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, jmember <- jmember + 1 } } else { - print("HERE") work_piece <- list(filename = .ConfigReplaceVariablesInString(quasi_final_path, replace_values), namevar = namevar, indices = c(1, 1, jsdate, jmod), nmember = nmember[jmod], leadtimes = leadtimes, mask = maskmod[[jmod]], @@ -1592,10 +1590,6 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, leadtimes <- seq(leadtimemin, leadtimemax, sampleperiod) } # If there are differences in the first time stamp in exp files: - print("INFO") - print(exp_work_pieces) - print("details") - print(leadtimemax) if (!is.null(exp)) { in_date <- lapply(first_time_step_list, function(x) { origin <- as.POSIXct( @@ -1628,24 +1622,18 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, while (jmod <= nmod) { jpiece <- 1 while (jpiece <= npieces) { - print(npieces * (jmod - 1) + jpiece) - exp_work_pieces[[npieces * (jmod - 1) + jpiece]]$leadtime <- - seq(new_leadtime[[jmod]], new_leadtimemax, sampleperiod) + exp_work_pieces[[npieces * (jmod - 1) + jpiece]]$leadtimes <- + seq(new_leadtimemin[[jmod]], new_leadtimemax[[jmod]], sampleperiod) + jpiece <- jpiece + 1 } + jmod <- jmod + 1 } } - print(exp_work_pieces) lag <- 1 - in_date[[1]] - print(lag) - print(leadtimemin) - print(leadtimemax) - print(in_date) leadtimes <- seq(leadtimemin - lag, leadtimemax #+ max(unlist(in_date)) + lag, - lag, sampleperiod) exp_first_time_step <- leadtimemin - lag - print(leadtimes) - print(exp_first_time_step) } # Now we start iterating over observations. We try to find the output matrix # dimensions and we build anyway the work pieces corresponding to the observational @@ -1815,9 +1803,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, stop("Check 'time' variable in the experimental files ", "since not units or first time step have been found.") } else { - if (in_date[[1]] > 1) { day <- leadtimes[1] - } } } obs_file_indices <- seq(day, min(days_in_month, @@ -1917,8 +1903,8 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, } if (storefreq == 'daily') { - #startdate <- startdate + 86400 * sampleperiod * length(obs_file_indices) -startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) + startdate <- startdate + 86400 * sampleperiod * + max(obs_file_indices) year <- as.integer(substr(startdate, 1, 4)) month <- as.integer(substr(startdate, 6, 7)) day <- as.integer(substr(startdate, 9, 10)) @@ -2263,37 +2249,6 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) number_ftime <- dim_obs[["ftime"]] } } - #if (!is.null(exp)) { - # if (any(in_date > 1) & length(in_date) > 1 & in_date[[1]] > 1) { - # .warning(paste("There is at least one experiment with first timestamp in ", - # "file one or more days ahead from the start date. The data ", - # "could containg missing values.")) - # pos_max <- max(unlist(in_date)) - 1 - # empty_slice <- array(NA, c(ftime = 1, dim(mod_data[1,,,1,,]))) - # empty_slice <- .aperm2(empty_slice, c(2, 3, 1, 4, 5)) - # new_data <- lapply(1:length(in_date), function(x) { - # pos <- in_date[[x]] - 1 - # res <- mod_data[x,,,,,] - # if (pos > 0) { - # while (pos > 0) { - # res <- abind(empty_slice, res, along = 3) - # pos <- pos - 1 - # } - # } else { - # while(pos < pos_max) { - # res <- abind(res, empty_slice, along = 3) - # pos <- pos + 1 - # } - # } - # return(res) - # }) - # new_data <- abind(new_data, along = 6) - # mod_data <- .aperm2(new_data, c(6,1,2,3,4,5)) - # names(dim(mod_data)) <- names(dim_exp) - # attr(mod_data, 'dimensions') <- names(dim_exp) - # number_ftime <- dim(mod_data)[["ftime"]] - # } - # } if (is.null(latitudes)) { lat <- 0 attr(lat, 'cdo_grid_name') <- 'none' @@ -2353,8 +2308,9 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) # Each component is a vector of the initial POSIXct date of each # forecast time step if (!is.null(exp)) { - if (storefreq == 'daily' & exp_first_time_step > 1) { - origin <- exp_first_time_step - 1 + if (storefreq == 'daily' & leadtimes[[1]] > 1) { + origin <- leadtimes[[1]] - 1 + leadtimemin <- 1 } else { origin <- 0 } @@ -2369,7 +2325,6 @@ startdate <- startdate + 86400 * sampleperiod * max(obs_file_indices) })) })) attr(dates[["start"]], "tzone") <- "UTC" - # end is similar to start, but contains the end dates of each forecast # time step dates[["end"]] <- do.call(c, lapply(dates[["start"]], diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index ce71f5b0..645ceaae 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -1,19 +1,5 @@ context("Testing Load with ECMWF System5c3s daily data") test_that("First time step is correctly interpreted:", { - s2dv_system5 <- s2dv::Load(var = 'prlr', - exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), - sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') - nmember = 5,leadtimemin = 1, - leadtimemax = NULL, - storefreq = "daily", sampleperiod = 1, - latmin = 42, latmax = 49, lonmin = 4, lonmax = 11, - output = 'lonlat', nprocs = 1, - method = 'conservative', grid = 'r360x181', - maskmod = vector("list", 15), maskobs = vector("list", 15), - configfile = NULL, varmin = NULL, varmax = NULL, - silent = FALSE, dimnames = NULL, - remapcells = 2, path_glob_permissive = 'partial', - nmemberobs = NULL, nleadtime = NULL) system5 <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), sdates = c('19931101', '19941101'), #paste0(1993:2018, '1101') @@ -28,7 +14,7 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - expect_equal(system5$mod, s2dv_system5$mod) + data <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS5', path = "/esarchive/exp/ecmwf/system5c3s/$STORE_FREQ$_mean/$VAR_NAME$_s0-24h/$VAR_NAME$_$START_DATE$.nc")), @@ -46,7 +32,7 @@ test_that("First time step is correctly interpreted:", { remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - expect_equal(dim(data$mod), c(dataset = 1, member = 5, sdate = 2, ftime = 214, + expect_equal(dim(data$mod), c(dataset = 1, member = 5, sdate = 2, ftime = 214, lat = 8, lon = 8)) expect_equal(dim(data$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 214, lat = 8, lon = 8)) @@ -84,7 +70,6 @@ test_that("First time step is correctly interpreted:", { # The values of observation when loading exp and obs simultaneously corresponds to the second day of the observations in the file: expect_equal(data$obs[1,1,1,,,], era5$obs[1,1,1,2:215,,]) expect_equal(data$obs[1,1,2,,,], era5$obs[1,1,2,2:215,,]) - # Test when 2 observational datasets are requested: data <- Load(var = 'prlr', @@ -110,6 +95,19 @@ test_that("First time step is correctly interpreted:", { expect_equal(sum(is.na(data$obs)), 0) expect_equal(data$obs[1,1,,,,], era5$obs[1,1,,2:215,,]) expect_equal(system5$mod, data$mod) + dates <- c(seq(as.POSIXct("1993-11-02", tz = 'UTC'), + as.POSIXct("1994-06-03", tz = 'UTC'), "d"), + seq(as.POSIXct("1994-11-02", tz = 'UTC'), + as.POSIXct("1995-06-03", tz = 'UTC'), "d")) + attributes(dates)$tzone <- 'UTC' + expect_equal(dates, data$Dates$start) + dates <- c(seq(as.POSIXct("1993-11-03", tz = 'UTC'), + as.POSIXct("1994-06-04", tz = 'UTC'), "d"), + seq(as.POSIXct("1994-11-03", tz = 'UTC'), + as.POSIXct("1995-06-04", tz = 'UTC'), "d")) + attributes(dates)$tzone <- 'UTC' + expect_equal(dates, data$Dates$end) + eraint <- Load(var = 'prlr', exp = NULL, obs = list(list(name = 'erainterim')), sdates = c('19931101', '19941101'), @@ -226,9 +224,21 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - expect_equal(system4$mod[1,1,1,2:214,,], data$mod[2,1,1,1:213,,]) - expect_equal(system5$mod[1,1,1,2:214,,], data$mod[1,1,1,2:214,,]) - + expect_equal(dim(data$mod), c(dataset = 2, member = 5, sdate = 2, ftime = 213, + lat = 8, lon = 8)) + expect_equal(dim(data$obs), c(dataset = 1, member = 1, sdate = 2,ftime = 213, + lat = 8, lon = 8)) + expect_equal(sum(is.na(data$mod)), 0) + expect_equal(sum(is.na(data$obs)), 0) + expect_equal(system4$mod[,1,,3:215,,], data$mod[2,1,,,,]) + expect_equal(system5$mod[,,,2:214,,], data$mod[1,,,,,]) + expect_equal(era5$obs[,,,3:215,,], data$obs[1,,,,,], tolerance = 0.001) + dates <- c(seq(as.POSIXct("1993-11-03", tz = 'UTC'), + as.POSIXct("1994-06-03", tz = 'UTC'), "d"), + seq(as.POSIXct("1994-11-03", tz = 'UTC'), + as.POSIXct("1995-06-03", tz = 'UTC'), "d")) + attributes(dates)$tzone <- 'UTC' + expect_equal(data$Dates$start, dates) data <- Load(var = 'prlr', exp = list(list(name = 'ecmwfS4', path = "/esarchive/exp/ecmwf/system4_m1/$STORE_FREQ$/$VAR_NAME$/$VAR_NAME$_$START_DATE$.nc"), @@ -246,7 +256,19 @@ test_that("First time step is correctly interpreted:", { silent = FALSE, dimnames = NULL, remapcells = 2, path_glob_permissive = 'partial', nmemberobs = NULL, nleadtime = NULL) - expect_equal(system4$mod[1,1,1,2:215,,], data$mod[1,1,1,1:214,,]) - expect_equal(system5$mod[1,1,1,1:214,,], data$mod[2,1,1,1:24,,]) - + expect_equal(system4$mod[1,1,,2:215,,], data$mod[1,1,,1:214,,]) + expect_equal(system5$mod[1,1,,1:214,,], data$mod[2,1,,1:214,,]) + expect_equal(dim(data$obs), c(dataset = 1, member = 1, sdate = 2, ftime = 214, + lat = 8, lon = 8)) + expect_equal(dim(data$mod), c(dataset = 2, member = 5, sdate = 2, ftime = 214, + lat = 8, lon = 8)) + expect_equal(sum(is.na(data$obs)), 0) + expect_equal(sum(is.na(data$mod)), 0) + expect_equal(data$obs[,,,1,,], era5$obs[,,,2,,]) + dates <- c(seq(as.POSIXct("1993-11-02", tz = 'UTC'), + as.POSIXct("1994-06-03", tz = 'UTC'), "d"), + seq(as.POSIXct("1994-11-02", tz = 'UTC'), + as.POSIXct("1995-06-03", tz = 'UTC'), "d")) + attributes(dates)$tzone <- 'UTC' + expect_equal(data$Dates$start, dates) }) -- GitLab