Spectrum
¶
- class sed_analysis_tools.sed_analysis_tools.Spectrum(x: ndarray, y: ndarray, frac_err: float | ndarray | list = 0.0, seed: int = 0)¶
A class to represent a spectrum, including its wavelength, flux, and errors.
- add_noise(frac_err: float | ndarray | list, seed: int = 0) None ¶
Add noise to the spectrum based on fractional flux error.
- Parameters:
frac_err (float or np.ndarray or list) – The fractional noise level or array of noise values.
seed (int, optional) – Seed for random noise generation. Default is 0.
- Raises:
ValueError – If the noise array length does not match the data length or is not float/list/np.array.
- property error_zero: bool¶
Check if the fractional flux error is zero for all values.
- Returns:
True if all errors are zero, False otherwise.
- Return type:
bool
- property flux: Quantity¶
Convert logarithmic flux values to linear scale in erg/s/Angstrom.
- Returns:
Flux in erg/s/Angstrom.
- Return type:
u.Quantity
- property flux_err: Quantity¶
Calculate the flux error based on fractional flux error.
- Returns:
Flux error in erg/s/Angstrom.
- Return type:
u.Quantity
- plot(ax=None, **kwargs) None ¶
Plot the spectrum.
- Parameters:
ax (matplotlib.axes.Axes, optional) – The axis to plot on. If None, a new axis is created.
**kwargs (dict) – Additional keyword arguments for the plotting function.
- plot_physical(ax=None, **kwargs) None ¶
Plot the spectrum in physical units.
- Parameters:
ax (matplotlib.axes.Axes, optional) – The axis to plot on. If None, a new axis is created.
**kwargs (dict) – Additional keyword arguments for the plotting function.
- property wavelength: Quantity¶
Convert logarithmic wavelength values to linear scale in Angstroms.
- Returns:
Wavelength in Angstroms.
- Return type:
u.Quantity