pykoala.corrections package
Submodules
pykoala.corrections.astrometry module
pykoala.corrections.atmospheric_corrections module
pykoala.corrections.correction module
Base Correction class
- class pykoala.corrections.correction.CorrectionBase(verbose=True, logger=None, log_filename=None, log_level=None)[source]
Bases:
ABC,VerboseMixinAbstract base class for implementing astronomical corrections on a DataContainer.
This class defines the structure and basic functionality required for applying a correction to an astronomical data container. It includes logging capabilities to track the application of corrections.
- verbose
Convenient attribute for controlling the logging output. If True, logs are set to INFO level; if False, logs are set to ERROR level.
- Type
- logger
Logger instance used to log messages. If not provided, a pykoala logger child (see pykoala.ancillary.pykoala_logger) is created with a name based on the correction’s name.
- Type
- log_filename
Name of the file to log messages. If provided, logs will also be saved to this file.
- Type
str, optional
- log_level
Level of logging, which overrides the verbose attribute if provided (for more details see https://docs.python.org/3/library/logging.html#logging-levels).
- Type
int, optional
- name :
Abstract property that needs to be defined in a subclass, representing the name of the correction.
- verbose :
Abstract property that needs to be defined in a subclass, representing the verbosity level of the correction.
- apply :
Abstract method that must be implemented in a subclass to apply the correction.
- vprint(msg, level='info') :
Logs a message at the specified level.
- record_correction(datacontainer, status='applied', \*\*extra_comments) :
Logs the status of the correction in the DataContainer, with additional information if provided.
Examples
To create a new correction, subclass CorrectionBase and implement the name, verbose, and apply methods.
Notes
When implementing a new correction, ensure that the apply method correctly applies the intended transformation to the DataContainer and that the operation is logged via the record_correction method.
- abstract property name
Abstract property for the name of the correction.
- record_correction(datacontainer, status='applied', **extra_comments)[source]
Logs the status of the correction in the DataContainer.
Whenever a correction is applied, this method logs the status of the correction (e.g., ‘applied’ or ‘failed’) and any additional comments in the DataContainer’s log.
- Parameters
datacontainer (koala.DataContainer) – The data container to log the correction.
status (str, optional) – Indicates the success of the correction. Should be either ‘applied’ or ‘failed’ (default is ‘applied’).
**extra_comments (dict) – Additional information to log alongside the correction status.
- Raises
KeyError – If status is not ‘applied’ or ‘failed’.