Module for the calibrator functionality.

calibrate(input_object: list | ~pathlib.Path | str, sampling: ~numpy.ndarray | None = None, truncation: bool = False, output_path: ~pathlib.Path | str = '.', output_file: str = 'output_spectra', output_format: str | None = None, save_file: bool = True, with_correlation: bool = False, username: str | None = None, password: str | None = None) -> (<class 'pandas.core.frame.DataFrame'>, <class 'numpy.ndarray'>)[source]

Calibration utility: calibrates the input internally-calibrated continuously-represented mean spectra to the absolute system. An absolute spectrum sampled on a user-defined or default wavelength grid is created for each set of BP and RP input spectra. If either band is missing, the output spectrum will only cover the range covered by the available data.

  • input_object (list/Path/str) – Path to the file containing the mean spectra as downloaded from the archive in their continuous representation, a list of sources ids (string or long), or a pandas DataFrame.

  • sampling (ndarray) – 1D array containing the desired sampling in absolute wavelengths [nm].

  • truncation (bool) – Toggle truncation of the set of bases. The level of truncation to be applied is defined by the recommended value in the input files.

  • output_path (Path/str) – Path where to save the output data.

  • output_file (str) – Name of the output file without extension (e.g. ‘my_file’).

  • output_format (str) – Desired output format. If no format is given, the output file format will be the same as the input file (e.g. ‘csv’).

  • save_file (bool) – Whether to save the output in a file. If false, output_format and output_file will be ignored.

  • with_correlation (bool) – Whether correlation information should be generated.

  • username (str) – Cosmos username, only suggested when input_object is a list or ADQL query.

  • password (str) – Cosmos password, only suggested when input_object is a list or ADQL query.


tuple containing:

DataFrame: The values for all sampled absolute spectra. ndarray: The sampling used to calibrate the input spectra (user-provided or default).

Return type:


Module for handling the various components of the external calibration instrument model. These are dispersion function, instrument response and set of inverse bases.

class ExternalInstrumentModel(dispersion: dict, response: dict, bases: DataFrame)[source]

Bases: object

External calibration instrument model.

classmethod from_config_csv(dispersion_path: str, response_path: str, bases_path: str)[source]

Create an external calibration instrument model from the input configuration files.

  • dispersion_path (str) – Path to the configuration file containing the dispersion.

  • response_path (str) – Path to the configuration file containing the response.

  • bases_path (str) – Path to the configuration file containing the inverse bases.


An external calibration instrument model object.

Return type:


get_response(wavelength: float) ndarray[source]

Get the response of the mean instrument at a certain wavelength.


wavelength (float) – The absolute wavelength.


The response of the mean instrument at the input wavelength.

Return type:


wl_to_pwl(wavelength: float) ndarray[source]

Convert the input absolute wavelength to a pseudo-wavelength.


wavelength (float) – Absolute wavelength.


The corresponding pseudo-wavelength value.

Return type: