Learn R Programming

s2dverification (version 2.4.0)

ConfigEditEntry: Add, Remove Or Edit Entries In The Configuration

Description

ConfigAddEntry(), ConfigEditEntry() and ConfigRemoveEntry() are functions to manage entries in a configuration object created with ConfigFileOpen(). Before adding an entry, make sure the defaults don't do already what you want (ConfigShowDefinitions(), ConfigShowTable()). Before adding an entry, make sure it doesn't override and spoil what other entries do (ConfigShowTable(), ConfigFileOpen()). Before adding an entry, make sure there aren't other entries that already do what you want (ConfigShowSimilarEntries()).

Usage

ConfigAddEntry(configuration, dataset_type, store_format, position = "last", 
               dataset_name = ".*", var_name = ".*", main_path = "*", 
               file_path = "*", nc_var_name = "*", grid = "*", suffix = "*", 
               varmin = "*", varmax = "*")
ConfigEditEntry(configuration, dataset_type, store_format, position, 
                dataset_name = NULL, var_name = NULL, main_path = NULL, 
                file_path = NULL, nc_var_name = NULL, grid = NULL, 
                suffix = NULL, varmin = NULL, varmax = NULL)
ConfigRemoveEntry(configuration, dataset_type, store_format, 
                  dataset_name = NULL, var_name = NULL, position = NULL)

Arguments

Value

The function returns an accordingly modified configuration object. To apply the changes in the configuration file it must be saved using ConfigFileSave().

See Also

ConfigAddVar, ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, ConfigFileOpen, ConfigMatchingVars, ConfigShowSimilarEntries, ConfigShowTable

Examples

Run this code
# Create an empty configuration file
config_file <- paste0(tempdir(), "/example.conf")
ConfigFileCreate(config_file, confirm = FALSE)
# Open it into a configuration object
configuration <- ConfigFileOpen(config_file)
# Add an entry at the bottom of 4th level of file-per-startdate experiments 
# table which will associate the experiment "ExampleExperiment" and variable 
# "ExampleVariable" to some information about its location.
configuration <- ConfigAddEntry(configuration, "experiments", 
                 "file-per-startdate", "last", "ExampleExperiment", 
                 "ExampleVariable", "/path/to/ExampleExperiment", 
                 "ExampleVariable/ExampleVariable_$START_DATE$.nc")
# Add another entry
configuration <- ConfigAddEntry(configuration, "experiments",
                 "file-per-startdate", "last", "ExampleExperiment2",
                 "ExampleVariable", "/path/to/ExampleExperiment2",
                 "ExampleVariable/ExampleVariable_$START_DATE$.nc")
# Edit second entry to generalize for any variable. Changing variable needs .
configuration <- ConfigEditEntry(configuration, "experiments",
                 "file-per-startdate", 2, var_name = ".*",
                 file_path = "$VAR_NAME$/$VAR_NAME$_$START_DATE$.nc")
# Remove first entry
configuration <- ConfigRemoveEntry(configuration, "experiments",
                 "file-per-startdate", "ExampleExperiment", "ExampleVariable")
# Show results
ConfigShowTable(configuration, "experiments", "file-per-ensemble")
# Now put variable in list of supported variables. In this example will be a 
# two-dimensional variable.
configuration <- ConfigAddVar(configuration, "2d", "ExampleMistake")
# Look in list of variables and see there's nothing similar to what we look 
# for. The previous introduction was mistaken
configuration <- ConfigShowSimilarVars(configuration, "Variable")
# Remove variable and add the desired one
configuration <- ConfigRemoveVar(configuration, "2d", "ExampleMistake")
configuration <- ConfigAddVar(configuration, "2d", "ExampleVariable")
# See results
ConfigShowVars(configuration)
# Save the configuration
ConfigFileSave(configuration, config_file, confirm = FALSE)

Run the code above in your browser using DataLab