exo_k.util.spectrum
@author: jeremy leconte
A module to handle ouputs rebinning and plotting
Module Contents
- exo_k.util.spectrum.planckovclum
- class exo_k.util.spectrum.Spectrum(value=None, wns=None, wnedges=None, input_spectral_unit='cm^-1', spectral_unit='cm^-1', filename=None, spectral_radiance=False, from_taurex=False, dataset='native_spectrum', **kwargs)[source]
Bases:
exo_k.util.spectral_object.Spectral_object
A class defining a Spectrum object to plot and manipulate.
Instanciate with a value, bin centers, and bin edges. Can also load a Taurex spectrum if filename is provided.
- Parameters:
value (
Array
) – spectrum valueswns (
Array
) – Spectral grid (can be wavenumbers or wavelengths)wnedges (
Array
) – Bin edges grid (can be wavenumbers or wavelengths)input_spectral_unit (
str
) – Unit of the input spectral gridspectral_unit (
str
) – desired output unit for the spectral gridfilename (
str
) – Name of a file where the spectrum is stored. If a filename is given, there is no need to provide values, wns, …spectral_radiance (
bool
) – If True, the spectrum is assumed to be a flux in units of inverse spectral units (for example W/micron if the spectral unit is microns) If False, the spectrum is considered as monochromatic values (like Rp/Rs**2)
- value
- wns
- wnedges
- spec_unit
- spectral_radiance
- convert_spectral_units(input_spectral_unit='cm^-1', spectral_unit='cm^-1', spectral_radiance=None)[source]
- Parameters:
spectral_radiance (Optional[bool])
- normalize(bolometric_flux)[source]
Normalize the spectrum to a specified bolometric flux
- Parameters:
bolometric_flux (
float
) – Integral of the flux over the total bandpass after normalization.
- plot_spectrum(ax, per_wavenumber=True, x_axis='wls', xscale=None, yscale=None, **kwarg)[source]
Plot the spectrum
- Parameters:
ax (
pyplot.Axes
) – A pyplot axes instance where to put the plot.per_wavenumber (
bool
, optional) – Defines the units of spectral flux density. False converts to per wavelength units.x_axis (
str
, optional) – If ‘wls’, x axis is wavelength. Wavenumber otherwise.xscale (
str
, optional) – If ‘log’ log axes are used.yscale (
str
, optional) – If ‘log’ log axes are used.
- bin_down(wnedges)[source]
Bins down the spectrum to a new grid of wnedges by conserving area.
- Parameters:
wnedges (
array
,np.ndarray
) – Wavenumbers of the bin edges to be used
- bin_down_cp(wnedges)[source]
Returns a new binned down spectrum to a grid of wnedges by conserving area.
- Parameters:
wnedges (
array
,np.ndarray
) – Wavenumbers of the bin edges to be used- Returns:
Spectrum
Binned down spectrum
- clip_spectral_range(wn_range=None, wl_range=None)[source]
Limits the data to the provided spectral range (inplace):
Wavenumber in cm^-1 if using wn_range argument
Wavelength in micron if using wl_range
- randomize(uncertainty=0.0)[source]
Adds random noise with a given uncertainty.
- Parameters:
uncertainty (float)
- property total
- Defines the weighted sum over the spectrum
- read_hdf5(filename=None)[source]
Reads data in a hdf5 file
- Parameters:
filename (
str
) – Name of the file to be created and saved
- write_hdf5(filename)[source]
Saves data in a hdf5 format
- Parameters:
filename (
str
) – Name of the file to be created and saved