Spectrum
absolute_sampled_spectrum.py
Module to represent an absolute sampled spectrum.
- class AbsoluteSampledSpectrum(source_id, xp_spectra, sampled_bases, merge, truncation=None, with_correlation=False)[source]
Bases:
SampledSpectrum
A spectrum calibrated onto the absolute system of wavelength and flux. The spectrum is represented by a set of discrete measurements or samples.
- classmethod get_flux_label()[source]
Get the labels describing the flux measurements.
- Returns:
Short description of the flux measurements, including the units.
- Return type:
str
- classmethod get_position_label()[source]
Get the positions of the samples, including the units.
- Returns:
Short description of the positions of the samples.
- Return type:
str
- get_positions()[source]
Get the positions of all samples.
- Returns:
1D array containing the position of all samples.
- Return type:
ndarray
- spectrum_to_dict(with_correlation)[source]
Represent the spectrum as a dictionary.
- Returns:
- A dictionary populated with the minimum set of parameters that need to be stored for this object.
This is optimised for writing large number of sampled spectra and for this reason the array of positions is NOT included as it is expected to be the same for a batch of spectra. The array of positions can be retrieved calling the sampling_to_dict method.
- Return type:
dict
generic_spectrum.py
Module to represent a generic spectrum.
- class Spectrum(source_id: str | int)[source]
Bases:
object
Base spectrum. Contain only the source ID.
multi_synthetic_photometry.py
Module to represent a synthetic photometry in multiple photometric systems.
- class MultiSyntheticPhotometry(photometric_system, photometries)[source]
Bases:
object
Synthetic photometry derived from Gaia spectra in multiple photometric systems.
sampled_basis_functions.py
Module to represent a set of basis functions evaluated on a grid.
- class SampledBasisFunctions(sampling_grid, design_matrix=None)[source]
Bases:
object
Evaluation of a set of basis functions on a user-defined grid.
- classmethod from_config(sampling, bases_config)[source]
Instantiate an object starting from a sampling grid and the configuration for the basis functions.
- Parameters:
sampling (ndarray) – 1D array of positions where the bases need to be evaluated.
bases_config (DataFrame) – The configuration of the set of bases loaded into a DataFrame.
- Returns:
An instance of this class.
- Return type:
object
- classmethod from_design_matrix(sampling, design_matrix)[source]
Instantiate an object starting from a sampling grid and the design matrix.
- Parameters:
sampling (ndarray) – 1D array of positions where the bases need to be evaluated.
design_matrix (ndarray) – 2D array containing the evaluation of each basis at all positions in the sampling grid.
- Returns:
An instance of this class.
- Return type:
object
- classmethod from_external_instrument_model(sampling, weights, external_instrument_model)[source]
- Instantiate an object starting from a sampling grid, an array of weights and the external calibration instrument
model.
- Parameters:
sampling (ndarray) – 1D array of positions where the bases need to be evaluated.
weights (ndarray) – 1D array containing the weights to be applied at each element in the sampling grid. These are simply used to define where in the sampling grid some contribution is expected. Where the weight is 0, the bases will not be evaluated.
external_instrument_model (obj) – external calibration instrument model. This object contains information on the dispersion, response and inverse bases.
- Returns:
An instance of this class.
- Return type:
sampled_spectrum.py
Module to represent a sampled spectrum.
- class SampledSpectrum(source_id, sampling_grid)[source]
Bases:
Spectrum
A spectrum defined by a set of discrete measurements. Each measurement is defined by a position in wavelength (or pseudo-wavelength), a measured flux and an associated flux error. Specific implementations of this class will define the units in use for positions and fluxes.
- get_flux_label()[source]
Get the labels describing the flux measurements.
- Returns:
Short description of the flux measurements, including the units.
- Return type:
str
single_synthetic_photometry.py
Module to represent a synthetic photometry in a single photometric system.
- class SingleSyntheticPhotometry(source_id, xp_spectra, sampled_bases, merge, photometric_system)[source]
Bases:
PhotometricAbsoluteSampledSpectrum
Synthetic photometry derived from Gaia spectra in one photometric system.
spectral_energy_distribution.py
Module to represent a spectral energy distribution (SED).
- class SpectralEnergyDistribution(source_id, wl, flux)[source]
Bases:
SampledSpectrum
A spectral energy distribution.
utils.py
Module to hold methods useful for different kinds of spectra.
xp_continuous_spectrum.py
Module to represent a BP/RP continuous spectrum.
- class XpContinuousSpectrum(source_id, xp, coefficients, covariance, standard_deviation)[source]
Bases:
XpSpectrum
- A Gaia BP/RP spectrum represented as a continuous function defined as the sum of a set of bases functions multiplied
by a set of coefficient. This definition is the result of the least squares fit. Covariance and standard deviation for the least square solution are also part of the continuous spectrum definition to allow estimating errors.
- classmethod from_data_frame(df, band)[source]
Initialise XP continuous spectrum from a Pandas DataFrame.
- Parameters:
df (DataFrame) – DataFrame containing at least the fields source_id, BAND_n_parameters, BAND_coefficients, BAND_coefficient_correlations, BAND_standard_deviation, where BAND is either ‘bp’ or ‘rp’. The same structure as used in the archive for the correlation matrix is expected.
band (str) – Gaia photometer, can be either ‘bp’ or ‘rp’.
- get_coefficients()[source]
Get the coefficients associated with the spectrum.
- Returns:
The 1D array of the coefficients multiplying the basis functions.
- Return type:
ndarray
- get_covariance()[source]
Get the covariance associated with the spectrum.
- Returns:
The 2D array of the covariance matrix.
- Return type:
ndarray
- get_standard_deviation()[source]
Get the standard deviation associated with the spectrum.
- Returns:
The standard deviation of the least squares solution.
- Return type:
float
- spectrum_to_dict()[source]
Represent spectrum as dictionary.
- Returns:
- A dictionary populated with the minimum set of parameters that need to be stored for this object.
This is optimised for writing large number of sampled spectra and for this reason the array of positions is NOT included as it is expected to be the same for a batch of spectra. The array fo positions can be retrieved calling the sampling_to_dict method.
- Return type:
dict
xp_sampled_spectrum.py
Module to represent a BP/RP sampled spectrum.
- class XpSampledSpectrum(source_id=0, xp=None, pos=None, flux=None, flux_error=None, cov=None, stdev=None)[source]
Bases:
XpSpectrum
,SampledSpectrum
A Gaia BP/RP spectrum sampled to a given grid of positions.
- classmethod from_continuous(continuous_spectrum, sampled_basis_functions, truncation=-1, with_correlation=False)[source]
Initialise a spectrum.
- Parameters:
continuous_spectrum (XpContinuousSpectrum) – The continuous representation of this spectrum.
sampled_basis_functions (SampledBasisFunctions) – The set of basis functions sampled onto the grid defining the resolution of the final sampled spectrum.
truncation (int) – Number of bases to be used for this spectrum. The set of bases functions used for the continuous representation of the spectra has been optimised to ensure that the first bases are the ones that contribute most. In many cases, the last bases contribution will be below the noise. Truncation of the basis function set to preserve only the significant bases is optional. By default, no truncation will be applied, i.e. all bases will be used.
with_correlation (bool) – Whether correlation information should be generated.
- classmethod from_data_frame(df, sampling, band)[source]
Initialise a sampled spectrum from a Pandas DataFrame.
- Parameters:
df (DataFrame) – DataFrame containing at least the fields source_id, flux, flux_error, cov The same structure as used in the archive for the correlation matrix is expected.
sampling (ndarray) – Given sampling.
band (str) – Gaia photometer, can be either ‘bp’ or ‘rp’.
- classmethod from_sampled(source_id, xp, pos, flux, flux_error, cov=None)[source]
Initialise a spectrum.
Args: source_id (long): The source identifier. xp (object): The photometer enum (BP/RP). pos (ndarray): The array of positions (in pseudo-wavelength or wavelength) of the samples. flux (ndarray): The flux value of each sample. flux_error (ndarray): The uncertainty on the flux value of each sample. cov (ndarray): The covariance matrix.
- classmethod get_flux_label()[source]
Get the labels describing the flux measurements.
- Returns:
Short description of the flux measurements, including the units.
- Return type:
str
- classmethod get_position_label()[source]
Get the positions of the samples, including the units.
- Returns:
Short description of the positions of the samples.
- Return type:
str
- get_positions()[source]
Get the positions of all samples.
- Returns:
1D array containing the position of all samples.
- Return type:
ndarray
- spectrum_to_dict(with_correlation)[source]
Represent spectrum as dictionary.
- Returns:
- A dictionary populated with the minimum set of parameters that need to be stored for this object. This
is optimised for writing large number of sampled spectra and for this reason the array of positions is NOT included as it is expected to be the same for a batch of spectra. The array of positions can be retrieved by calling the sampling_to_dict method.
- Return type:
dict
xp_spectrum.py
Module to represent a BP/RP spectrum.