Converter

config.py

Module to work with the converter’s configuration.

get_config(config, id)[source]

Access the group of rows in the configuration for the given ID.

Parameters
  • config (str) – A DataFrame containing the configuration columns and values.

  • id (int) – An identifier of a set of configurations.

Returns

A DataFrame containing the configuration values.

Return type

DataFrame

load_config(path)[source]

Load the configuration for the converter functionality.

Parameters

path (str) – Path to the configuration file.

Returns

A DataFrame containing the columns and values of the configuration file.

Return type

DataFrame

parse_configuration_file(xml_file, columns)[source]

Parse the input XML file and store the result in a pandas DataFrame with the given columns.

Parameters
  • xml_file (str) – Path to the XML configuration file.

  • columns (list) – List of columns of the configuration file.

Returns

A DataFrame with the given columns and their corresponding values.

Return type

DataFrame

converter.py

Module for the converter functionality.

convert(input_object, sampling=numpy.linspace(0.0, 60.0, 600), truncation=False, output_path='.', output_file='output_spectra', output_format=None, save_file=True, username=None, password=None)[source]

Conversion utility: converts the input internally calibrated mean spectra from the continuous representation to a sampled form. The sampling grid can be defined by the user, alternatively a default will be adopted. Optionally, the continuous representation can be truncated dropping the bases functions (and corresponding coefficients) that were considered not to be significant considering the errors on the reconstructed mean spectra.

Parameters
  • input_object (object) – 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 pseudo-wavelengths.

  • 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 (str) – Path where to save the output data.

  • output_file (str) – Name of the output file.

  • output_format (str) – Format to be used for the output file. If no format is given, then the output file will be in the same format as the input file.

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

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

Returns

tuple containing:

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

Return type

(tuple)

Raises

ValueError – If the sampling is out of the expected boundaries.

get_design_matrices(unique_bases_ids, sampling, config_df)[source]

Get the design matrices corresponding to the input bases.

Parameters
  • unique_bases_ids (set) – A set containing the basis function IDs for which the design matrix is required.

  • sampling (ndarray) – 1D array containing the sampling grid.

  • config_df (DataFrame) – A DataFrame containing the configuration for all sets of basis functions.

Returns

a list of the design matrices for the input list of bases.

Return type

list

get_unique_basis_ids(parsed_input_data)[source]

Get the IDs of the unique basis required to sample all spectra in the input files.

Parameters

parsed_input_data (DataFrame) – Pandas DataFrame populated with the content of the file containing the mean spectra in continuous representation.

Returns

A set containing all the required unique basis function IDs.

Return type

set