1.2.6. Library configuration

1.2.6.1. Purpose

Some modules need for instance to access external files (such as a bathymetric file) that are not included directly in the library because they are too bulky. To make the installation generic and portable on different networks, it is necessary not to put these paths hardcoded in the code: so it uses a system configuration. There is thus a default configuration (that of IFREMER network), and it is possible to alter the configuration for example to adapt to his or her needs or network. For example, Actimar has its own configuration. And each user can also have its configuration which affects partly these parameters.

The concept of configuration is at two levels:

  • At the user’s level who can change its personal configuration file.
  • At the developer’s leve who will appeal to the API (vacumm.config) to define and use the configuration in its code.

1.2.6.2. Operating

A number of modules have a default configuration in the form of a config.cfg file in the same directory as the module or in the root directory of the library. The module configuration is then accessible at the section of the same name. For example, if the vacumm.toto.tutu module is configurable, its configuration file may be vacumm/toto/config.cfg, with the content:

[vacumm.toto.tutu]
masection = mavaleur

In addition, the configuration files of support the expansion of variables in two ways:

  1. An options inserted in a value is automatically replaced by its value (it is “extended”) when it is present in the classical form %(option)s. For example:

    [vacumm.toto.tutu]
    option1 = foo
    option2 = %(option1)bar
    

    option2 takes the value foobar. There are several directory names that are currently systematically extended:

    • lib_dir : Root directory of the library (see get_lib_dir()).
    • data_dir : Directory that stores the data used by the library and tutorials (see get_data_dir()).
    • tut_dir : Directory containing tutorial scripts (see get_tut_dir()).
    • dist_dir : Directory of packet distribution for developers (see get_dist_dir()).
    • conf_dir : General directory containing the configuration files (see get_conf_dir()).
    • user_conf_dir : Directory containing user configuration files (see get_user_conf_dir()).
    • mod_dir : Directory of the module (see get_mod_dir()).
  2. The path ~ is automatically replaced by the user home, and environment variables that have the form $HOME ou ${HOME} are replaced by their value.

    Note

    Developers that need to manage configuration can refer to the documentation of the module vacumm.config.

Configuration values are accessible with the function vacumm.config.get_config_value().

1.2.6.3. Default configuration

The general default configuration (loaded with get_default_config()) is following:

[vacumm]
url = http://umr-lops-vacumm.ifremer.fr
url_recent = http://relay.actimar.fr/~raynaud/vacumm

[vacumm.bathy.shorelines]
shapefile_histolitt = /home1/caparmor/sraynaud/data/shorelines/Histolitt/TCHistolitt-V1-0-RGF93-polygone
shapefile_histolitt_url = http://relay.actimar.fr/~raynaud/vacumm_data/TCHistolitt-V1-0-RGF93-polygone
shapefile_histolitt_license = IGN-SHOM 2009: http://www.shom.fr/fr_page/fr_prod_num/tch_licence.html
shapefile_eurosion = /home1/caparmor/sraynaud/data/shorelines/EUROSION/CLEUER100kV2_2
shapefile_eurosion_url = http://relay.actimar.fr/~raynaud/vacumm_data/CLEUER100kV2_2
shapefile_eurosion_license = EUROSION shoreline: http://www.eurosion.org/index.html
shapefile_gshhs = /home1/caparmor/sraynaud/data/shorelines/gshhs/gshhs_land
shapefile_gshhs_url = http://relay.actimar.fr/~raynaud/vacumm_data/gshhs_land
shapefile_gshhs_license = NOAA / GSHHS: http://www.ngdc.noaa.gov/mgg/shorelines/gshhs.html

[vacumm.bathy.bathy]
cfgfile_gridded = %(mod_dir)s/bathy.gridded.cfg
cfgfile_xyz = %(mod_dir)s/bathy.xyz.cfg

[vacumm.misc.plot]
fill = pcolor
nmax_levels = 12
levels_mode = auto
clabel = False
keepminmax = 0
cmap = auto
cmap_positive = speed
cmap_negative = tempo_r
cmap_symetric = balance

[vacumm.misc.docstrings]
verbose = False

[vacumm.misc.grid.basemap]
proj = laea
max_cache_size = 50*1024*1024

[vacumm.tide.station_info]
ports_file = %(data_dir)s/sea_level/ports.txt
meansealevel_file = %(data_dir)s/sea_level/niv_moy.txt

1.2.6.4. User configuration

It is possible to alter for a user the default configuration of one or more modules. The best way is to edit the file $HOME/.config/vacumm/vacumm.cfg. To quickly edit this file, use this script: vacumm_edit_config.py – Edit your user configuration file (DEPRECATED).

If you personally install the library, you can configure it for the users using option --cfgfiles of the setup.py installation script (see User configuration of the modules).

Finally, you can alter this configuration online through function vacumm.config.set_config_value().