9. cpl.esorex EsoRex legacy support

EsoRex is a standard execution environment for CPL recipes provided by ESO.

9.1. Support for configuration and SOF files

cpl.esorex.init(source=None)

Set up the logging and the recipe search path from the esorex.rc file.

Parameters:source (str or file) – Configuration file object, or string with file content. If not set, the esorex config file ~/.esorex/esorex.rc is used.
cpl.esorex.load_rc(source=None)

Read an EsoRex configuration file.

Parameters:source (str or file) – Configuration file object, or string with file content. If not set, the EsoRex config file ~/.esorex/esorex.rc is used.

These files contain configuration parameters for EsoRex or recipes. The content of the file is returned as a map with the (full) parameter name as key and its setting as string value.

The result of this function may directly set as cpl.Recipe.param attribute:

import cpl
myrecipe = cpl.Recipe('muse_bias')
myrecipe.param = cpl.esorex.load_rc('muse_bias.rc')
cpl.esorex.load_sof(source)

Read an EsoRex SOF file.

Parameters:source (str or file) – SOF (“Set Of Files”) file object or string with SOF file content.

These files contain the raw and calibration files for a recipe. The content of the file is returned as a map with the tag as key and the list of file names as value.

The result of this function may directly set as cpl.Recipe.calib attribute:

import cpl
myrecipe = cpl.Recipe('muse_bias')
myrecipe.calib = cpl.esorex.read_sof(open('muse_bias.sof'))

Note

The raw data frame is silently ignored wenn setting cpl.Recipe.calib for MUSE recipes. Other recipes ignore the raw data frame only if it was set manually as cpl.Recipe.tag or in cpl.Recipe.tags since there is no way to automatically distinguish between them.

9.2. Convienence logging control

cpl.esorex.msg = <cpl.esorex.CplLogger object>

This variable is a CplLogger instance that provides a convienience stream handler similar to the terminal logging functionality of the CPL. It basically does the same as:

import logging

log = logging.getLogger()
log.setLevel(logging.INFO)
ch = logging.StreamHandler()
ch.setLevel(logging.OFF)
ch.setFormatter(logging.Formatter('[%(levelname)7s] %(message)s'))
log.addHandler(ch)

The following attributes control the format of the terminal messages:

CplLogger.level

Log level for output to the terminal. Any of [ DEBUG, INFO, WARN, ERROR, OFF ].

CplLogger.format

Output format.

See also

logging.LogRecord attributes

Key mappings in the logging output.

CplLogger.time

If True, attach a time tag to output messages.

CplLogger.component

If True, attach the component name to output messages.

CplLogger.threadid

If True, attach a thread tag to output messages.

cpl.esorex.log = <cpl.esorex.CplFileLogger object>

This variable is a CplFileLogger instance that provides a convienience file handler similar to the file logging functionality of the CPL. It basically does the same as:

import logging

log = logging.getLogger()
log.setLevel(logging.INFO)
ch = logging.FileHandler(filename)
ch.setLevel(logging.INFO)
ch.setFormatter(logging.Formatter('%(asctime)s [%(levelname)7s] %(funcName)s: %(message)s'))
log.addHandler(ch)

The following attributes control the format of the log file messages:

CplLogger.dir

Directory name that is prepended to the log file name.

CplLogger.level

Log level for output to the terminal. Any of [ DEBUG, INFO, WARN, ERROR, OFF ].

CplLogger.format

Output format.

See also

logging.LogRecord attributes

Key mappings in the logging output.

CplLogger.time

If True, attach a time tag to output messages.

CplLogger.component

If True, attach the component name to output messages.

CplLogger.threadid

If True, attach a thread tag to output messages.