cobtools.photometry package
Submodules
cobtools.photometry.color_index module
- cobtools.photometry.color_index.bp_rp_to_sptype(bp_rp: float | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], mh: float | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = 0.0, kind: str = 'dwarf') str | List[str][source]
Convert Gaia BP-RP color index to spectral type using the Teff derived from bp_rp_to_teff and the Teff-SpType relation from Pecaut & Mamajek (2013).
- Parameters:
bp_rp (Union[float, ArrayLike]) – Gaia BP-RP color index.
mh (Union[float, ArrayLike], optional) – Metallicity, by default 0.0 (solar metallicity).
kind (str, optional) – Kind of star, by default “dwarf”. Currently, only “dwarf” is supported. Passing any other value will raise a ValueError.
- Returns:
Spectral type. If the input is a single value, returns a string. If the input is an ArrayLike, returns a list of strings.
- Return type:
Union[str, List[str]]
- Raises:
ValueError – If the calculated effective temperature is out of the valid range for spectral type determination.
- cobtools.photometry.color_index.bp_rp_to_teff(bp_rp: float | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], mh: float | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] = 0.0, kind: str = 'dwarf') float | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str][source]
Convert Gaia BP-RP color index to effective temperature (Teff) using polynomial coefficients from Mucciarelli et al. (2021).
- Parameters:
bp_rp (Union[float, ArrayLike]) – Gaia BP-RP color index.
mh (Union[float, ArrayLike], optional) – Metallicity, by default 0.0 (solar metallicity).
kind (str, optional) – Kind of star, by default “dwarf”. Currently, only “dwarf” is supported. Passing any other value will raise a ValueError.
- Returns:
Effective temperature (Teff) in Kelvin.
- Return type:
Union[float, ArrayLike]
- Raises:
TypeError – If the input parameters are not of the expected type or cannot be converted to the expected type.
ValueError – If the input parameters are out of bounds or invalid.
ValueError – If the kind is not valid.
ValueError – If the input arrays have different shapes.
cobtools.photometry.flux_conversion module
Utilities for converting between magnitudes and fluxes for supported photometric bands.
Functions
magnitude_to_flux(mag, band): Convert magnitude values to fluxes for a given photometric band.
- cobtools.photometry.flux_conversion.magnitude_to_flux(mag: float | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], band: Band) float | ndarray[source]
Convert magnitude to flux for a given band
- Parameters:
mag (Union[float, ArrayLike]) – Magnitude(s) to convert
band (Band) – Band for which to convert magnitude to flux. Must be a Band instance.
- Returns:
Flux(es) in erg/s/cm^2
- Return type:
Union[float, np.ndarray]
- Raises:
ValueError – If mag is not a float or array-like of floats, or if it contains non-finite values.
TypeError – If band is not an instance of Band.
Notes
The conversion is done using the formula:
\[F = w_{\text{eff}} F_0 10^{-0.4m},\]where \(F_0\) is the zero-point flux for the band, \(w_{\text{eff}}\) is the effective wavelength, and \(m\) is the magnitude. \(F_0\) values are from various references.
Examples
>>> from cobtools.data_models.band import Band >>> from cobtools.photometry.flux_conversion import magnitude_to_flux >>> band = Band(name='gaia_g') >>> mag = 15.0 >>> flux = magnitude_to_flux(mag, band)
References
Gaia Collaboration (2021), A&A, 639, A3. LSST Collaboration (2019), ApJ, 873, 2.