Core

config.py

Module to handle the calibrator and generator configuration files.

get_file(label, key, system, bp_model, rp_model, config_file=None)[source]

Get the file path corresponding to the given label and key.

Parameters:
  • label (str) – Label of the photometric system or functionality (e.g.: ‘Johnson’ or ‘calibrator’).

  • key (str) – Type of file to load (‘zeropoint’, ‘merge’, ‘sampling’).

  • system (str) – Photometric system name, can be None in which case the generic configuration is loaded.

  • bp_model (str) – BP model.

  • rp_model (str) – RP model.

  • config_file – Path to configuration file.

Returns:

Path of a file.

Return type:

str

get_file_path(config_file=None)[source]
get_filter_version_from_config(_config_parser)[source]
load_xpmerge_from_xml(system=None, bp_model=None, rp_model='v142r', config_file=None)[source]

Load the XpMerge table from the filter XML file.

Parameters:
  • system (str) – Name of the photometric system if it corresponds.

  • bp_model (str) – BP model.

  • rp_model (str) – RP model.

Returns:

Array containing the sampling grid values. dict: A dictionary containing the XpMerge table with one entry for BP and one for RP.

Return type:

ndarray

load_xpsampling_from_xml(system=None, bp_model=None, rp_model='v142r', config_file=None)[source]

Load the XpSampling table from the XML filter file.

Parameters:
  • system (str) – Photometric system name, can be None in which case the generic configuration is loaded.

  • bp_model (str) – BP model.

  • rp_model (str) – RP model.

Returns:

A dictionary containing the XpSampling table with one entry for BP and one for RP.

Return type:

dict

replace_file_name(_config_file, label, key, bp_model, rp_model, system)[source]

generic_functions.py

Module to hold some functions used by different subpackages.

array_to_symmetric_matrix(array, array_size)[source]
Convert the input 1D array into a 2D matrix. The array is assumed to store only the unique elements of a symmetric

matrix (i.e. all elements above the diagonal plus the diagonal) in column major order. A full 2D matrix is returned symmetric with respect to the diagonal.

Parameters:
  • array (ndarray) – 1D array.

  • array_size (int) – number of rows/columns in the output matrix.

Returns:

a full 2D matrix.

Return type:

array of arrays

Raises:

TypeError – If array is not of type np.ndarray.

cast_output(output)[source]
correlation_from_covariance(covariance)[source]
correlation_to_covariance(correlation: ndarray, error: ndarray, stdev: float) ndarray[source]

Compute the covariance matrix from the correlation values.

If the input correlation values are a 1D array, the values are assumed to be the lower triangle of a symmetric matrix (excluding the diagonal). The array will be internally converted to a full correlation matrix.

Parameters:
  • correlation (ndarray) – A 2D numpy array of shape (n, n) representing the correlation matrix. Alternatively, a 1D numpy array of length n*(n-1)/2 representing the lower triangle of a symmetric correlation matrix (excluding the diagonal).

  • error (ndarray) – A 1D numpy array of length n containing the flux errors.

  • stdev (float) – The scaling factor for the errors.

Returns:

A 2D numpy array of shape (n, n) representing the covariance matrix.

Return type:

ndarray

Raises:

ValueError – If the dimensions of input correlation are not either 1 or 2.

get_matrix_size_from_lower_triangle(array)[source]

Compute the size of a symmetric matrix from an array containing the values of its lower triangle, excluding the diagonal.

Parameters:

array (ndarray) – An array of length n*(n-1)/2 representing the lower triangle of an n x n symmetric matrix, excluding the diagonal.

Returns:

The size n of the symmetric matrix.

Return type:

int

Raises:

ValueError – If the length of array is not a valid input for a symmetric matrix lower triangle.

get_spectra_type(spectra)[source]

Get the spectra type.

Parameters:

spectra (object) – A spectrum or a spectra list.

Returns:

Spectrum type (e.g. AbsoluteSampledSpectrum).

Return type:

str

parse_band(band)[source]
standardise_extension(_extension)[source]

Standardise the provided extension which can contain or not an initial dot, and can contain a mix of uppercase and lowercase letters.

Parameters:

_extension (str) – File extension which may or may not contain an initial dot.

Returns:

The extension in lowercase letters and with no initial dot (eg.: ‘csv’).

Return type:

str

str_to_array(str_array)[source]
str_to_matrix(str_matrix)[source]

Convert a string of the form ((1,2,3),(4,5,6),(7,8,9)) to a NumPy matrix.

validate_arguments(default_output_file, given_output_file, save_file)[source]
validate_pwl_sampling(sampling)[source]
validate_wl_sampling(sampling)[source]

nature.py

Module to hold “natural” constants.

satellite.py

Module to hold satellite-related constants.

class Bands(bp, rp)

Bases: tuple

bp

Alias for field number 0

rp

Alias for field number 1

class WLRange(low, high)

Bases: tuple

high

Alias for field number 1

low

Alias for field number 0