Transforms¶
These classes and functions are used to manipulate stellar spectra. Users are not expected to directly call these methods unless they are playing around with spectrums or creating custom methods.
-
Starfish.transforms.
resample
(wave, flux, new_wave)[source]¶ Resample onto a new wavelength grid using k=5 spline interpolation
- Parameters
wave (array_like) – The original wavelength grid
flux (array_like) – The fluxes to resample
new_wave (array_like) – The new wavelength grid
- Raises
ValueError – If the new wavelength grid is not strictly increasing monotonic
- Returns
The resampled flux with the same 1st dimension as the input flux
- Return type
numpy.ndarray
-
Starfish.transforms.
rescale
(flux, scale)[source]¶ Rescale the given flux via the following equation
\[f \cdot \Omega\]- Parameters
flux (array_like) – The input fluxes
scale (float or array_like) – The scaling factor. If an array, must have same shape as the batch dimension of
flux
- Returns
The rescaled fluxes with the same shape as the input fluxes
- Return type
numpy.ndarray
-
Starfish.transforms.
renorm
(wave, flux, reference_flux)[source]¶ Renormalize one spectrum to another
This uses the
rescale()
function with alog_scale
of\[\log \Omega = \left. \int{f^{*}(w) dw} \middle/ \int{f(w) dw} \right.\]where \(f^{*}\) is the reference flux, \(f\) is the source flux, and the integrals are over a common wavelength grid
- Parameters
wave (array_like) – The wavelength grid for the source flux
flux (array_like) – The flux for the source
reference_flux (array_like) – The reference source to renormalize to
- Returns
The renormalized flux
- Return type
numpy.ndarray
-
Starfish.transforms.
doppler_shift
(wave, vz)[source]¶ Doppler shift a spectrum according to the formula
\[\lambda \cdot \sqrt{\frac{c + v_z}{c - v_z}}\]- Parameters
wave (array_like) – The unshifted wavelengths
vz (float) – The doppler velocity in km/s
- Returns
Altered wavelengths with the same shape as the input wavelengths
- Return type
numpy.ndarray
-
Starfish.transforms.
instrumental_broaden
(wave, flux, fwhm)[source]¶ Broadens given flux by convolving with a Gaussian kernel appropriate for a spectrograph’s instrumental properties. Follows the given equation
\[f = f * \mathcal{F}^{\text{inst}}_v\]\[\mathcal{F}^{\text{inst}}_v = \frac{1}{\sqrt{2\pi \sigma^2}} \exp \left[-\frac12 \left( \frac{v}{\sigma} \right)^2 \right]\]This is carried out by multiplication in the Fourier domain rather than using a convolution function.
- Parameters
wave (array_like) – The current wavelength grid
flux (array_like) – The current flux
fwhm (float) – The full width half-maximum of the instrument in km/s. Note that this is quivalent to \(2.355\cdot \sigma\)
- Raises
ValueError – If the full width half maximum is negative.
- Returns
The broadened flux with the same shape as the input flux
- Return type
numpy.ndarray
-
Starfish.transforms.
rotational_broaden
(wave, flux, vsini)[source]¶ Broadens flux according to a rotational broadening kernel from Gray (2005) 1
- Parameters
wave (array_like) – The current wavelength grid
flux (array_like) – The current flux
vsini (float) – The rotational velocity in km/s
- Raises
ValueError – if vsini is not positive
- Returns
The broadened flux with the same shape as the input flux
- Return type
numpy.ndarray
- 1
Gray, D. (2005). The observation and Analysis of Stellar Photospheres.
Cambridge: Cambridge University Press. doi:10.1017/CB09781316036570
-
Starfish.transforms.
extinct
(wave, flux, Av, Rv=3.1, law='ccm89')[source]¶ Extinct a spectrum following one of many empirical extinction laws. This makes use of the extinction package. In general, it follows the form
\[f \cdot 10^{-0.4 A_V \cdot A_\lambda(R_V)}\]- Parameters
wave (array_like) – The input wavelengths in Angstrom
flux (array_like) – The input fluxes
Av (float) – The absolute attenuation
Rv (float, optional) – The relative attenuation (the default is 3.1, which is the Milky Way average)
law (str, optional) – The extinction law to use. One of {‘ccm89’, ‘odonnell94’, ‘calzetti00’, ‘fitzpatrick99’, ‘fm07’} (the default is ‘ccm89’)
- Raises
ValueError – If law does not match one of the availabe laws
ValueError – If Rv is not positive
- Returns
The extincted fluxes, with same shape as input fluxes.
- Return type
numpy.ndarray
-
Starfish.transforms.
chebyshev_correct
(wave, flux, coeffs)[source]¶ Multiply the input flux by a Chebyshev series in order to correct for calibration-level discrepancies.
- Parameters
wave (array-lioke) – Input wavelengths
flux (array-like) – Input flux
coeffs (array-like) – The coefficients for the chebyshev series.
- Returns
The corrected flux
- Return type
numpy.ndarray
- Raises
ValueError – If only processing a single spectrum and the linear coefficient is not 1.