iris.config

Provides access to Iris-specific configuration values.

The default configuration values can be overridden by creating the file iris/etc/site.cfg. If it exists, this file must conform to the format defined by ConfigParser.


iris.config.SAMPLE_DATA_DIR

Local directory where sample data exists. Defaults to “sample_data” sub-directory of the Iris package install directory. The sample data directory supports the Iris gallery. Directory contents accessed via iris.sample_data_path().

Deprecated since version 1.10.

iris.config.TEST_DATA_DIR

Local directory where test data exists. Defaults to “test_data” sub-directory of the Iris package install directory. The test data directory supports the subset of Iris unit tests that require data. Directory contents accessed via iris.tests.get_data_path().

iris.config.PALETTE_PATH

The full path to the Iris palette configuration directory

iris.config.IMPORT_LOGGER

The [optional] name of the logger to notify when first imported.

iris.config.RULE_LOG_DIR

The [optional] full path to the rule logging directory used by iris.fileformats.pp.load() and iris.fileformats.pp.save().

Deprecated since version 1.10.

iris.config.RULE_LOG_IGNORE

The [optional] list of users to ignore when logging rules.

Deprecated since version 1.10.


In this module:

iris.config.netcdf

Control Iris NetCDF options.

↑ top ↑

iris.config.get_dir_option(section, option, default=None)

Returns the directory path from the given option and section, or returns the given default value if the section/option is not present or does not represent a valid directory.

↑ top ↑

iris.config.get_option(section, option, default=None)

Returns the option value for the given section, or the default value if the section/option is not present.

↑ top ↑

Control Iris NetCDF options.

class iris.config.NetCDF(conventions_override=None)

Bases: object

Set up NetCDF processing options for Iris.

Currently accepted kwargs:

  • conventions_override (bool):

    Define whether the CF Conventions version (e.g. CF-1.6) set when saving a cube to a NetCDF file should be defined by Iris (the default) or the cube being saved.

    If False (the default), specifies that Iris should set the CF Conventions version when saving cubes as NetCDF files. If True, specifies that the cubes being saved to NetCDF should set the CF Conventions version for the saved NetCDF files.

Example usages:

  • Specify, for the lifetime of the session, that we want all cubes written to NetCDF to define their own CF Conventions versions:

    iris.config.netcdf.conventions_override = True
    iris.save('my_cube', 'my_dataset.nc')
    iris.save('my_second_cube', 'my_second_dataset.nc')
    
  • Specify, with a context manager, that we want a cube written to NetCDF to define its own CF Conventions version:

    with iris.config.netcdf.context(conventions_override=True):
        iris.save('my_cube', 'my_dataset.nc')
    
context(*args, **kwds)

Allow temporary modification of the options via a context manager. Accepted kwargs are the same as can be supplied to the Option.