You are viewing the latest unreleased documentation 3.9.0.dev37. You can switch to a stable version.

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.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


class iris.config.NetCDF(conventions_override=None)[source]#

Bases: object

Control Iris NetCDF options.

Set up NetCDF processing options for Iris.

Parameters:

conventions_override (bool, optional) – 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.

Examples

  • 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(**kwargs)[source]#

Allow temporary modification of the options via a context manager.

Accepted kwargs are the same as can be supplied to the Option.

iris.config.get_dir_option(section, option, default=None)[source]#

Return the directory path from the given option and section.

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.

iris.config.get_logger(name, datefmt=None, fmt=None, level=None, propagate=None, handler=True)[source]#

Create a custom class for logging.

Create a logging.Logger with a logging.StreamHandler and custom logging.Formatter.

Parameters:
  • name – The name of the logger. Typically this is the module filename that owns the logger.

  • datefmt (optional) – The date format string of the logging.Formatter. Defaults to %d-%m-%Y %H:%M:%S.

  • fmt (optional) – The additional format string of the logging.Formatter. This is appended to the default format string %(asctime)s %(name)s %(levelname)s - %(message)s.

  • level (optional) – The threshold level of the logger. Defaults to INFO.

  • propagate (optional) – Sets the propagate attribute of the logging.Logger, which determines whether events logged to this logger will be passed to the handlers of higher level loggers. Defaults to False.

  • handler (bool, default=True) – Create and attach a logging.StreamHandler to the logger. Defaults to True.

Return type:

logging.Logger.

iris.config.get_option(section, option, default=None)[source]#

Return the option value for the given section.

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