From ae0742160439860d752d1a788e02ca3974a42b76 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Tue, 13 Sep 2016 17:04:06 +0200 Subject: [PATCH 01/13] Fix in configuration file. --- inst/config/BSC.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/config/BSC.conf b/inst/config/BSC.conf index 8ebcec9e..2121c0b2 100644 --- a/inst/config/BSC.conf +++ b/inst/config/BSC.conf @@ -83,7 +83,7 @@ $RECON_LIST$, .*, /es*/recon/*/$OBS_NAME$/, *, *, *, *, * ", sies, *, $STORE_FREQ$_mean/ice/ice_hadisst_S.nc, sie, *, *, * ", sias, *, ", sia, *, *, * ", si(a|e|v)_.*, *, $STORE_FREQ$_mean/ice/siasie_HadISST.nc,*, *, *, * -(nasa/)?nsidc-nasa, sien, *, $STORE_FREQ$_mean/ice/ice_nsidc_N.nc, sie, *, *, * +(nasa/)?nsidc-siasie, sien, *, $STORE_FREQ$_mean/ice/ice_nsidc_N.nc, sie, *, *, * ", sian, *, ", sia, *, *, * ", sies, *, $STORE_FREQ$_mean/ice/ice_nsidc_S.nc, sie, *, *, * ", sias, *, ", sia, *, *, * -- GitLab From 6830fc60f2ecdfa2c1af3f8e1cc31441bb1a00a0 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Mon, 19 Sep 2016 13:31:33 +0200 Subject: [PATCH 02/13] Some enhancements in plot_timeseries.R --- inst/doc/plot_timeseries.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/inst/doc/plot_timeseries.R b/inst/doc/plot_timeseries.R index 2012797d..092cc5bf 100755 --- a/inst/doc/plot_timeseries.R +++ b/inst/doc/plot_timeseries.R @@ -59,9 +59,14 @@ for (expid in lstexpid ) { savename <- paste(savename, '_', expid, sep = '') } if (file.exists(paste(savename, '.sav', sep = ''))) { + cat(paste0("Loading existing data from backup file ", savename, "...\n")) load(paste(savename, '.sav', sep = '')) + if (is.null(toto1$mod) || is.null(toto1$obs)) { + stop("Missing experimental or observational data in backup file. Remove the backup to try retrieving again.") + } } else { if (var == 'prlr' | var == 'tos' ) { + cat("Retrieving mask files...\n") fnc <- nc_open(paste('/esnas/exp/ecearth/constant/land_sea_mask_', grid, '.nc', sep = '')) mask <- ncvar_get(fnc, 'LSM') @@ -116,10 +121,16 @@ if (file.exists(paste(savename, '.sav', sep = ''))) { latmax = latbnd[2], nleadtime = nltimemax, leadtimemax = nltimeout, maskmod = lstmask, maskobs = lstmaskobs) + if (is.null(toto1$mod) || is.null(toto1$obs)) { + stop("Failed retrieving data for all the experiments or observations.") + } if (is.na(match('b02p', lstexpid)) == FALSE) { toto1bis <- Load(varname, 'b02p', obs = NULL, '19501101', latmin = latbnd[1], latmax = latbnd[2], maskmod = lstmask, maskobs = lstmaskobs) + if (is.null(toto1bis$mod)) { + stop("Failed retrieving data for b02p.") + } toto1ter <- Histo2Hindcast(toto1bis$mod, '19501101', sdates, nleadtimesout = nltimeout) toto1beta <- array(dim = c(dim(toto1$mod)[1] + dim(toto1ter)[1], -- GitLab From bce55d834d337c100d7a23c901abb05bcc617d24 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Mon, 19 Sep 2016 18:57:38 +0200 Subject: [PATCH 03/13] Fixed legend bug in PlotAno(). --- R/PlotAno.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/PlotAno.R b/R/PlotAno.R index 495ad670..c2b6bfb3 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -212,10 +212,10 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, } if (is.null(legends) == FALSE) { if (points) { - legend(0, ul, legends[1:nobs], lty = 3, lwd = 10, col = 1, + legend('topleft', legends[1:nobs], lty = 3, lwd = 10, col = 1, cex = legsize) } else { - legend(0, ul, legends[1:nobs], lty = type[1:nobs], + legend('topleft', ul, legends[1:nobs], lty = type[1:nobs], lwd = thickness[1:nobs], col = 1, cex = legsize) } } -- GitLab From d38b36e20119474c492c136ad8324f8f80a9ad04 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Mon, 19 Sep 2016 20:06:26 +0200 Subject: [PATCH 04/13] Supporting 'lon', 'lat' and var-grid_fXh. --- R/Load.R | 6 +++--- R/Utils.R | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/R/Load.R b/R/Load.R index 5ff1dd4c..c42439e9 100644 --- a/R/Load.R +++ b/R/Load.R @@ -618,7 +618,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (!first_dataset_file_found) { found_path <- Sys.glob(.ConfigReplaceVariablesInString(quasi_final_path, replace_values)) if (length(found_path) > 0) { - found_path <- tail(found_path, 1) + found_path <- head(found_path, 1) if (replace_globs) { quasi_final_path <- .ReplaceGlobExpressions(quasi_final_path, found_path, replace_values, tags_to_find, @@ -792,7 +792,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (!first_dataset_file_found) { found_path <- Sys.glob(.ConfigReplaceVariablesInString(quasi_final_path, replace_values)) if (length(found_path) > 0) { - found_path <- tail(found_path, 1) + found_path <- head(found_path, 1) if (replace_globs) { quasi_final_path <- .ReplaceGlobExpressions(quasi_final_path, found_path, replace_values, tags_to_find, @@ -908,7 +908,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (!first_dataset_file_found) { found_path <- Sys.glob(.ConfigReplaceVariablesInString(quasi_final_path, replace_values)) if (length(found_path) > 0) { - found_path <- tail(found_path, 1) + found_path <- head(found_path, 1) if (replace_globs) { quasi_final_path <- .ReplaceGlobExpressions(quasi_final_path, found_path, replace_values, tags_to_find, diff --git a/R/Utils.R b/R/Utils.R index 9c73fa5f..5a7437a0 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -110,7 +110,7 @@ # If we don't find any, we leave the flag 'found_file' with a NULL value. if (length(files) > 0) { # The first file that matches the pattern is chosen and read. - filename <- files[length(files)] + filename <- head(files, 1) filein <- filename found_file <- filename mask <- work_piece[['mask']] @@ -135,6 +135,19 @@ } var_long_name <- fnc$var[[namevar]]$longname units <- fnc$var[[namevar]]$units + file_dimnames <- unlist(lapply(fnc$var[[namevar]][['dim']], '[[', 'name')) + # The following two 'ifs' are to allow for 'lon'/'lat' by default, instead of + # 'longitude'/'latitude'. + if (!(work_piece[['dimnames']][['lon']] %in% file_dimnames) && + (work_piece[['dimnames']][['lon']] == 'longitude') && + ('lon' %in% file_dimnames) { + work_piece[['dimnames']][['lon']] <- 'lon' + } + if (!(work_piece[['dimnames']][['lat']] %in% file_dimnames) && + (work_piece[['dimnames']][['lat']] == 'latitude') && + ('lat' %in% file_dimnames) { + work_piece[['dimnames']][['lat']] <- 'lat' + } if (is.null(work_piece[['is_2d_var']])) { is_2d_var <- all(c(work_piece[['dimnames']][['lon']], work_piece[['dimnames']][['lat']]) %in% -- GitLab From 2e63a3e7935edcdbfad0d71e65de0dde0647739e Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Mon, 19 Sep 2016 20:09:18 +0200 Subject: [PATCH 05/13] Bugfix. --- R/Utils.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/Utils.R b/R/Utils.R index 5a7437a0..4a5e2df9 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -140,12 +140,12 @@ # 'longitude'/'latitude'. if (!(work_piece[['dimnames']][['lon']] %in% file_dimnames) && (work_piece[['dimnames']][['lon']] == 'longitude') && - ('lon' %in% file_dimnames) { + ('lon' %in% file_dimnames)) { work_piece[['dimnames']][['lon']] <- 'lon' } if (!(work_piece[['dimnames']][['lat']] %in% file_dimnames) && (work_piece[['dimnames']][['lat']] == 'latitude') && - ('lat' %in% file_dimnames) { + ('lat' %in% file_dimnames)) { work_piece[['dimnames']][['lat']] <- 'lat' } if (is.null(work_piece[['is_2d_var']])) { -- GitLab From a1acf7b12c7cc925baeb3c940794d07786b41b2d Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Thu, 22 Sep 2016 13:02:05 +0200 Subject: [PATCH 06/13] Added option to load data in multiple grids. --- R/Load.R | 38 ++++++++++++++++++++++++++++++++++---- inst/config/BSC.conf | 13 +++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/R/Load.R b/R/Load.R index c42439e9..634e22da 100644 --- a/R/Load.R +++ b/R/Load.R @@ -439,30 +439,54 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, member = ifelse(is.null(dimnames[["member"]]), replace_values[["DEFAULT_DIM_NAME_MEMBERS"]], dimnames[['member']])) + mandatory_defaults <- c('DEFAULT_EXP_MAIN_PATH', 'DEFAULT_EXP_FILE_PATH', + 'DEFAULT_OBS_MAIN_PATH', 'DEFAULT_OBS_FILE_PATH', + 'DEFAULT_NC_VAR_NAME', 'DEFAULT_SUFFIX', + 'DEFAULT_VAR_MIN', 'DEFAULT_VAR_MAX', + 'DEFAULT_DIM_NAME_LONGITUDES', + 'DEFAULT_DIM_NAME_LATITUDES', + 'DEFAULT_DIM_NAME_MEMBERS') + extra_vars_with_default_ind <- (1:length(replace_values))[grep('^DEFAULT_'), names(replace_values)] + extra_vars_with_default_ind <- extra_vars_with_default_ind[ + grep(paste0(paste0('^', mandatory_defaults), + collapse = '|'), + names(replace_values)[extra_vars_with_default_ind], + invert = TRUE) + ] + extra_vars_with_default <- gsub('^DEFAULT_', '', + names(replace_values)[extra_vars_with_default_ind]) if (!is.null(exp)) { exp <- lapply(exp, function (x) { if (!('dimnames' %in% names(x))) { x[['dimnames']] <- dimnames - x } else { dimnames2 <- dimnames dimnames2[names(x[['dimnames']])] <- x[['dimnames']] x[['dimnames']] <- dimnames2 - x } + for (i in 1:length(extra_vars_with_default)) { + if (!(extra_vars_with_default[i] %in% names(x))) { + x[[extra_vars_with_default[i]]] <- replace_values[[extra_vars_with_default_ind[i]]] + } + } + x }) } if (!is.null(obs)) { obs <- lapply(obs, function (x) { if (!('dimnames' %in% names(x))) { x[['dimnames']] <- dimnames - x } else { dimnames2 <- dimnames dimnames2[names(x[['dimnames']])] <- x[['dimnames']] x[['dimnames']] <- dimnames2 - x } + for (i in 1:length(extra_vars_with_default)) { + if (!(extra_vars_with_default[i] %in% names(x))) { + x[[extra_vars_with_default[i]]] <- replace_values[[extra_vars_with_default_ind[i]]] + } + } + x }) } single_dataset <- (length(obs) + length(exp) == 1) @@ -511,6 +535,8 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, replace_values[["EXP_NAME"]] <- exp[[jmod]][['name']] replace_values[["NC_VAR_NAME"]] <- exp[[jmod]][['nc_var_name']] replace_values[["SUFFIX"]] <- exp[[jmod]][['suffix']] + extra_vars <- names(exp[[jmod]])[which(!(names(exp[[jmod]]) %in% exp_info_names))] + replace_values[extra_vars] <- exp[[jmod]][extra_vars] namevar <- .ConfigReplaceVariablesInString(exp[[jmod]][['nc_var_name']], replace_values) tags_to_find <- c('START_DATE', 'YEAR', 'MONTH', 'DAY', 'MEMBER_NUMBER') position_of_tags <- na.omit(match(tags_to_find, names(replace_values))) @@ -651,6 +677,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, } jsdate <- jsdate + 1 } + replace_values[extra_vars] <- NULL jmod <- jmod + 1 } if (dims2define && length(exp) > 0) { @@ -705,6 +732,8 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, replace_values[["OBS_NAME"]] <- obs[[jobs]][['name']] replace_values[["NC_VAR_NAME"]] <- obs[[jobs]][['nc_var_name']] replace_values[["SUFFIX"]] <- obs[[jobs]][['suffix']] + extra_vars <- names(exp[[jmod]])[which(!(names(exp[[jmod]]) %in% exp_info_names))] + replace_values[extra_vars] <- exp[[jmod]][extra_vars] namevar <- .ConfigReplaceVariablesInString(obs[[jobs]][['nc_var_name']], replace_values) tags_to_find <- c('START_DATE', 'MONTH', 'DAY', 'YEAR', 'MEMBER_NUMBER') position_of_tags <- na.omit(match(tags_to_find, names(replace_values))) @@ -957,6 +986,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, jsdate <- jsdate + 1 } } + replace_values[extra_vars] <- NULL jobs <- jobs + 1 } if (dims2define && length(obs) > 0) { diff --git a/inst/config/BSC.conf b/inst/config/BSC.conf index 2121c0b2..1769e689 100644 --- a/inst/config/BSC.conf +++ b/inst/config/BSC.conf @@ -6,22 +6,27 @@ ############# !!definitions ############# +# Mandatory defaults DEFAULT_EXP_MAIN_PATH = /es*/exp/*/$EXP_NAME$/ -DEFAULT_SUFFIX = _mean -DEFAULT_EXP_FILE_PATH = $STORE_FREQ$$SUFFIX$/$VAR_NAME$*/$EXP_FILE$ -EXP_FILE = $VAR_NAME$_*$START_DATE$*.nc +DEFAULT_EXP_FILE_PATH = $STORE_FREQ$$SUFFIX$/$VAR_NAME$$FILE_GRID$*/$EXP_FILE$ DEFAULT_OBS_MAIN_PATH = /es*/obs/*/$OBS_NAME$/ DEFAULT_OBS_FILE_PATH = $STORE_FREQ$$SUFFIX$/$VAR_NAME$*/$OBS_FILE$ -OBS_FILE = $VAR_NAME$_$YEAR$$MONTH$*.nc DEFAULT_NC_VAR_NAME = $VAR_NAME$ +DEFAULT_SUFFIX = _mean DEFAULT_VAR_MIN = -1e19 DEFAULT_VAR_MAX = 1e19 DEFAULT_DIM_NAME_LONGITUDES = longitude DEFAULT_DIM_NAME_LATITUDES = latitude DEFAULT_DIM_NAME_MEMBERS = ensemble +# Helper variables +EXP_FILE = $VAR_NAME$_*$START_DATE$*.nc +OBS_FILE = $VAR_NAME$_$YEAR$$MONTH$*.nc RECON_LIST = (20thcr_v2|copernicus012|ds083.2|ecco|era40|era40-erainterim|eraclim|erainterim|erainterim-lores|eraland|gecco_v2|gfs|glorys2_v1|glorys2_v3|glosea5|ishii-kimoto|jra55|merra|merra_v2|ncep-reanalysis|oaflux|oi_v2|orap5|piomas|seaice-lim2|sst|tropflux) +# Defaults for extra variables from Load +DEFAULT_FILE_GRID = + ###################### !!table of experiments ###################### -- GitLab From ce021aa7f5e8ffa90c36780f43b8e519d3bf7249 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Thu, 22 Sep 2016 13:35:33 +0200 Subject: [PATCH 07/13] Small fix. --- R/Load.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/Load.R b/R/Load.R index 634e22da..ccba8a0b 100644 --- a/R/Load.R +++ b/R/Load.R @@ -446,7 +446,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, 'DEFAULT_DIM_NAME_LONGITUDES', 'DEFAULT_DIM_NAME_LATITUDES', 'DEFAULT_DIM_NAME_MEMBERS') - extra_vars_with_default_ind <- (1:length(replace_values))[grep('^DEFAULT_'), names(replace_values)] + extra_vars_with_default_ind <- (1:length(replace_values))[grep('^DEFAULT_', names(replace_values))] extra_vars_with_default_ind <- extra_vars_with_default_ind[ grep(paste0(paste0('^', mandatory_defaults), collapse = '|'), -- GitLab From db6abc9b728c361009d1edfc617c357e64235268 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Thu, 22 Sep 2016 13:50:09 +0200 Subject: [PATCH 08/13] Small fix. --- R/Load.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/Load.R b/R/Load.R index ccba8a0b..2a6329cc 100644 --- a/R/Load.R +++ b/R/Load.R @@ -74,9 +74,9 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (!is.list(exp[[i]])) { stop("Error: parameter 'exp' is incorrect. It should be a list of lists.") } - if (!(all(names(exp[[i]]) %in% exp_info_names))) { - stop("Error: parameter 'exp' is incorrect. There are unrecognized components in the information of some of the experiments. Check 'exp' in ?Load for details.") - } + #if (!(all(names(exp[[i]]) %in% exp_info_names))) { + # stop("Error: parameter 'exp' is incorrect. There are unrecognized components in the information of some of the experiments. Check 'exp' in ?Load for details.") + #} if (!('name' %in% names(exp[[i]]))) { exp[[i]][['name']] <- paste0('exp', i) if (!('path' %in% names(exp[[i]]))) { @@ -119,9 +119,9 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, if (!is.list(obs[[i]])) { stop("Error: parameter 'obs' is incorrect. It should be a list of lists.") } - if (!(all(names(obs[[i]]) %in% obs_info_names))) { - stop("Error: parameter 'obs' is incorrect. There are unrecognized components in the information of some of the observations. Check 'obs' in ?Load for details.") - } + #if (!(all(names(obs[[i]]) %in% obs_info_names))) { + # stop("Error: parameter 'obs' is incorrect. There are unrecognized components in the information of some of the observations. Check 'obs' in ?Load for details.") + #} if (!('name' %in% names(obs[[i]]))) { obs[[i]][['name']] <- paste0('obs', i) if (!('path' %in% names(obs[[i]]))) { -- GitLab From eba8b854a81d34216f559d68c09e7099a2ea3fe6 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Thu, 22 Sep 2016 15:18:14 +0200 Subject: [PATCH 09/13] Small fix. --- R/Load.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/Load.R b/R/Load.R index 2a6329cc..6fd02aa8 100644 --- a/R/Load.R +++ b/R/Load.R @@ -732,8 +732,8 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, replace_values[["OBS_NAME"]] <- obs[[jobs]][['name']] replace_values[["NC_VAR_NAME"]] <- obs[[jobs]][['nc_var_name']] replace_values[["SUFFIX"]] <- obs[[jobs]][['suffix']] - extra_vars <- names(exp[[jmod]])[which(!(names(exp[[jmod]]) %in% exp_info_names))] - replace_values[extra_vars] <- exp[[jmod]][extra_vars] + extra_vars <- names(obs[[jobs]])[which(!(names(obs[[jobs]]) %in% obs_info_names))] + replace_values[extra_vars] <- exp[[jobs]][extra_vars] namevar <- .ConfigReplaceVariablesInString(obs[[jobs]][['nc_var_name']], replace_values) tags_to_find <- c('START_DATE', 'MONTH', 'DAY', 'YEAR', 'MEMBER_NUMBER') position_of_tags <- na.omit(match(tags_to_find, names(replace_values))) -- GitLab From 984279a97bf3cd9a031fd32fe077a3fb85f0e7ea Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 19:15:00 +0200 Subject: [PATCH 10/13] Some progress. --- R/Load.R | 8 ++++++-- inst/config/BSC.conf | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/R/Load.R b/R/Load.R index 6fd02aa8..dab7e2d9 100644 --- a/R/Load.R +++ b/R/Load.R @@ -464,10 +464,12 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, dimnames2[names(x[['dimnames']])] <- x[['dimnames']] x[['dimnames']] <- dimnames2 } - for (i in 1:length(extra_vars_with_default)) { + i <- 1 + while (i <= length(extra_vars_with_default)) { if (!(extra_vars_with_default[i] %in% names(x))) { x[[extra_vars_with_default[i]]] <- replace_values[[extra_vars_with_default_ind[i]]] } + i <- i + 1 } x }) @@ -481,10 +483,12 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, dimnames2[names(x[['dimnames']])] <- x[['dimnames']] x[['dimnames']] <- dimnames2 } - for (i in 1:length(extra_vars_with_default)) { + i <- 1 + while (i <= length(extra_vars_with_default)) { if (!(extra_vars_with_default[i] %in% names(x))) { x[[extra_vars_with_default[i]]] <- replace_values[[extra_vars_with_default_ind[i]]] } + i <- i + 1 } x }) diff --git a/inst/config/BSC.conf b/inst/config/BSC.conf index 1769e689..9cca74a3 100644 --- a/inst/config/BSC.conf +++ b/inst/config/BSC.conf @@ -25,7 +25,7 @@ OBS_FILE = $VAR_NAME$_$YEAR$$MONTH$*.nc RECON_LIST = (20thcr_v2|copernicus012|ds083.2|ecco|era40|era40-erainterim|eraclim|erainterim|erainterim-lores|eraland|gecco_v2|gfs|glorys2_v1|glorys2_v3|glosea5|ishii-kimoto|jra55|merra|merra_v2|ncep-reanalysis|oaflux|oi_v2|orap5|piomas|seaice-lim2|sst|tropflux) # Defaults for extra variables from Load -DEFAULT_FILE_GRID = +DEFAULT_FILE_GRID = -regular ###################### !!table of experiments -- GitLab From 6d3b7e2ca31730bb82a89c8440f890411abccb24 Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 19:32:01 +0200 Subject: [PATCH 11/13] Small error message improv. --- R/Load.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/Load.R b/R/Load.R index dab7e2d9..31941c01 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1235,6 +1235,8 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, position_of_tags <- na.omit(match(tags_to_find, names(replace_values))) if (!is.null(exp)) { lapply(exp, function (x) { + extra_vars <- names(x)[which(!(names(x) %in% exp_info_names))] + replace_values[extra_vars] <- x[extra_vars] if (length(position_of_tags) > 0) { quasi_final_path <- .ConfigReplaceVariablesInString(x[['path']], replace_values[-position_of_tags], TRUE) @@ -1243,10 +1245,13 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, replace_values, TRUE) } error_message <<- paste0(error_message, paste0(quasi_final_path, '\n')) + replace_values[extra_vars] <- NULL }) } if (!is.null(obs)) { lapply(obs, function (x) { + extra_vars <- names(x)[which(!(names(x) %in% obs_info_names))] + replace_values[extra_vars] <- x[extra_vars] if (length(position_of_tags) > 0) { quasi_final_path <- .ConfigReplaceVariablesInString(x[['path']], replace_values[-position_of_tags], TRUE) @@ -1255,6 +1260,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, replace_values, TRUE) } error_message <<- paste0(error_message, paste0(quasi_final_path, '\n')) + replace_values[extra_vars] <- NULL }) } stop(error_message) -- GitLab From c3d17803af48a630a629eb14ab146df47f5647df Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 19:36:02 +0200 Subject: [PATCH 12/13] Small config file improv. --- inst/config/BSC.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/config/BSC.conf b/inst/config/BSC.conf index 9cca74a3..ba24c289 100644 --- a/inst/config/BSC.conf +++ b/inst/config/BSC.conf @@ -8,7 +8,7 @@ ############# # Mandatory defaults DEFAULT_EXP_MAIN_PATH = /es*/exp/*/$EXP_NAME$/ -DEFAULT_EXP_FILE_PATH = $STORE_FREQ$$SUFFIX$/$VAR_NAME$$FILE_GRID$*/$EXP_FILE$ +DEFAULT_EXP_FILE_PATH = $STORE_FREQ$$SUFFIX$/$VAR_NAME$*$FILE_GRID$*/$EXP_FILE$ DEFAULT_OBS_MAIN_PATH = /es*/obs/*/$OBS_NAME$/ DEFAULT_OBS_FILE_PATH = $STORE_FREQ$$SUFFIX$/$VAR_NAME$*/$OBS_FILE$ DEFAULT_NC_VAR_NAME = $VAR_NAME$ -- GitLab From a2925042c75704bdd4c7c04f45b1734db3e9208f Mon Sep 17 00:00:00 2001 From: Nicolau Manubens Date: Wed, 28 Sep 2016 20:02:16 +0200 Subject: [PATCH 13/13] Couple of bugfixes. --- R/Load.R | 6 ++++++ inst/config/BSC.conf | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/R/Load.R b/R/Load.R index 31941c01..58d46563 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1235,6 +1235,9 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, position_of_tags <- na.omit(match(tags_to_find, names(replace_values))) if (!is.null(exp)) { lapply(exp, function (x) { + replace_values[["EXP_NAME"]] <- x[['name']] + replace_values[["NC_VAR_NAME"]] <- x[['nc_var_name']] + replace_values[["SUFFIX"]] <- x[['suffix']] extra_vars <- names(x)[which(!(names(x) %in% exp_info_names))] replace_values[extra_vars] <- x[extra_vars] if (length(position_of_tags) > 0) { @@ -1250,6 +1253,9 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, } if (!is.null(obs)) { lapply(obs, function (x) { + replace_values[["OBS_NAME"]] <- x[['name']] + replace_values[["NC_VAR_NAME"]] <- x[['nc_var_name']] + replace_values[["SUFFIX"]] <- x[['suffix']] extra_vars <- names(x)[which(!(names(x) %in% obs_info_names))] replace_values[extra_vars] <- x[extra_vars] if (length(position_of_tags) > 0) { diff --git a/inst/config/BSC.conf b/inst/config/BSC.conf index ba24c289..c6c7e917 100644 --- a/inst/config/BSC.conf +++ b/inst/config/BSC.conf @@ -8,7 +8,7 @@ ############# # Mandatory defaults DEFAULT_EXP_MAIN_PATH = /es*/exp/*/$EXP_NAME$/ -DEFAULT_EXP_FILE_PATH = $STORE_FREQ$$SUFFIX$/$VAR_NAME$*$FILE_GRID$*/$EXP_FILE$ +DEFAULT_EXP_FILE_PATH = $STORE_FREQ$$SUFFIX$/$VAR_NAME$$FILE_GRID$*/$EXP_FILE$ DEFAULT_OBS_MAIN_PATH = /es*/obs/*/$OBS_NAME$/ DEFAULT_OBS_FILE_PATH = $STORE_FREQ$$SUFFIX$/$VAR_NAME$*/$OBS_FILE$ DEFAULT_NC_VAR_NAME = $VAR_NAME$ @@ -25,7 +25,7 @@ OBS_FILE = $VAR_NAME$_$YEAR$$MONTH$*.nc RECON_LIST = (20thcr_v2|copernicus012|ds083.2|ecco|era40|era40-erainterim|eraclim|erainterim|erainterim-lores|eraland|gecco_v2|gfs|glorys2_v1|glorys2_v3|glosea5|ishii-kimoto|jra55|merra|merra_v2|ncep-reanalysis|oaflux|oi_v2|orap5|piomas|seaice-lim2|sst|tropflux) # Defaults for extra variables from Load -DEFAULT_FILE_GRID = -regular +DEFAULT_FILE_GRID = -regular ###################### !!table of experiments -- GitLab