species.phot package#
Submodules#
species.phot.syn_phot module#
Module with functionalities for calculating synthetic photometry.
- class species.phot.syn_phot.SyntheticPhotometry(filter_name: str, zero_point: float | None = None)[source]#
Bases:
object
Class for calculating synthetic photometry from a spectrum and also for converting between magnitudes and fluxes. Any filter from the SVO Filter Profile Service will be automatically downloaded and added to the database. Also the detector type (energy- or photon-counting) will be fetched. For a photon-counting detector, an additional wavelength factor is included in the integral for calculating the synthetic photometry, although typically the impact of the factor on the calculated flux is negligible. It is also important to note that by default the magnitude of Vega is set to 0.03 for all filters. The value can be adjusted in the configuration file.
- Parameters:
filter_name (str) –
Filter name by which the profile is stored in database. Any filter from the SVO Filter Profile Service will be automatically downloaded and added to the database.
zero_point (float, None) –
Zero-point flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)) for
filter_name
. This flux is equalized to the magnitude of Vega, which by default is set to 0.03 for all filters. The value can be adjusted in the configuration file. By default, the argument ofzero_point
is set toNone
, in which case the zero point is calculated internally. The zero point can be accessed throughzero_point
attribute from instance ofSyntheticPhotometry
.
- Returns:
None
- Return type:
NoneType
- calc_zero_point() float | float64 [source]#
Internal function for calculating the zero point of the provided
filter_name
. The zero point is here defined as the flux of Vega, which by default is set to a magnitude of 0.03 for all filters.- Returns:
Zero-point flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).
- Return type:
float
- flux_to_magnitude(flux: float, error: float | ndarray | None = None, parallax: Tuple[float, float | None] | Tuple[ndarray, ndarray | None] | None = None, distance: Tuple[float, float | None] | Tuple[ndarray, ndarray | None] | None = None) Tuple[Tuple[float, float | None] | Tuple[ndarray, ndarray | None], Tuple[float | None, float | None] | Tuple[ndarray | None, ndarray | None]] [source]#
Function for converting a flux into a magnitude.
- Parameters:
flux (float, np.ndarray) – Flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).
error (float, np.ndarray, None) – Uncertainty (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)). Not used if set to None.
parallax (tuple(float, float), , tuple(np.ndarray, np.ndarray), None) – Parallax and uncertainty (mas). The returned absolute magnitude is set to
None
in caseparallax
anddistance
are set toNone
. The error is not propagated into the error on the absolute magnitude in case the parallax uncertainty is set toNone
, for exampleparallax=(10., None)
.distance (tuple(float, float), tuple(np.ndarray, np.ndarray), None) – Distance and uncertainty (pc). The returned absolute magnitude is set to
None
in casedistance
andparallax
are set toNone
. The error is not propagated into the error on the absolute magnitude in case the distance uncertainty is set toNone
, for exampledistance=(20., None)
. This parameter is ignored if theparallax
parameter is used.
- Returns:
tuple(float, float), tuple(np.ndarray, np.ndarray) – Apparent magnitude and uncertainty.
tuple(float, float), tuple(np.ndarray, np.ndarray) – Absolute magnitude and uncertainty.
- magnitude_to_flux(magnitude: float, error: float | None = None, zp_flux: float | None = None) Tuple[float | float32 | float64, float | float32 | float64 | None] [source]#
Function for converting a magnitude to a flux.
- Parameters:
magnitude (float) – Magnitude.
error (float, None) – Error on the magnitude. Not used if set to
None
.zp_flux (float, None) – DEPRECATED: Zero-point flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)). This parameter is deprecated and will be removed in a future release. Please use the zero_point parameter of the constructor of
SyntheticPhotometry
instead. By default, the zero point is calculated internally and stored as thezero_point
attribute of an instance fromSyntheticPhotometry
.
- Returns:
float – Flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).
float, None – Error (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)). The returned value is
None
if the argument oferror
isNone
.
- spectrum_to_flux(wavelength: ndarray, flux: ndarray, error: ndarray | None = None, threshold: float | None = 0.01) Tuple[float | float32 | float64, float | float32 | float64 | None] [source]#
Function for calculating the average flux from a spectrum and a filter profile. The uncertainty is propagated by sampling 200 random values from the error distributions.
- Parameters:
wavelength (np.ndarray) – Wavelength points (um).
flux (np.ndarray) – Flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).
error (np.ndarray, None) – Uncertainty (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)). Not used if set to
None
.threshold (float, None) – Transmission threshold (value between 0 and 1). If the minimum transmission value is larger than the threshold, a NaN is returned. This will happen if the input spectrum does not cover the full wavelength range of the filter profile. The parameter is not used if set to
None
(default: 0.01).
- Returns:
float – Average flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).
float, None – Uncertainty (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).
- spectrum_to_magnitude(wavelength: ndarray, flux: ndarray, error: ndarray | List[ndarray] | None = None, parallax: Tuple[float, float | None] | None = None, distance: Tuple[float, float | None] | None = None, threshold: float | None = 0.01) Tuple[Tuple[float, float | None], Tuple[float | None, float | None] | None] [source]#
Function for calculating the apparent and absolute magnitude from a spectrum and a filter profile. The uncertainty is propagated by sampling 200 random values from the error distributions.
- Parameters:
wavelength (np.ndarray) – Wavelength points (um).
flux (np.ndarray) – Flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).
error (np.ndarray, list(np.ndarray), None) – Uncertainty (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).
parallax (tuple(float, float), None) – Parallax and uncertainty (mas). No absolute magnitude is calculated if set to
None
. No error on the absolute magnitude is calculated if theerror
parameter is set toNone
.distance (tuple(float, float), None) – Distance and uncertainty (pc). No absolute magnitude is calculated if set to
None
. No error on the absolute magnitude is calculated if theerror
parameter is set toNone
. This parameter is ignored if theparallax
parameter is used.threshold (float, None) – Transmission threshold (value between 0 and 1). If the minimum transmission value is larger than the threshold, a NaN is returned. This will happen if the input spectrum does not cover the full wavelength range of the filter profile. The parameter is not used if set to
None
(default: 0.01).
- Returns:
tuple(float, float) – Apparent magnitude and uncertainty.
tuple(float, float) – Absolute magnitude and uncertainty.