Rotational broadening¶
The functions here implement rotational broadening as described in D.F. Gray’s book “The Observation and Analysis of Stellar Photospheres”. Stellar limb-darkening is accounted for using the linear law.
To apply rotational broadening, either rotBroad()
or
fastRotBroad()
can be used. The “fast” algorithm uses
a single broadening kernel, which is appropriate as long as
the wavelength range remains small. Otherwise the slower but
accurate algorithm implemented in rotBroad()
should be
used.
- PyAstronomy.pyasl.rotBroad(wvl, flux, epsilon, vsini, edgeHandling='firstlast')¶
Apply rotational broadening to a spectrum.
This function applies rotational broadening to a given spectrum using the formulae given in Gray’s “The Observation and Analysis of Stellar Photospheres”. It allows for limb darkening parameterized by the linear limb-darkening law.
The edgeHandling parameter determines how the effects at the edges of the input spectrum are handled. If the default option, “firstlast”, is used, the input spectrum is internally extended on both sides; on the blue edge of the spectrum, the first flux value is used and on the red edge, the last value is used to extend the flux array. The extension is neglected in the return array. If “None” is specified, no special care will be taken to handle edge effects.
Note
Currently, the wavelength array as to be regularly spaced.
- Parameters
- wvlarray
The wavelength array [A]. Note that a regularly spaced array is required.
- fluxarray
The flux array.
- vsinifloat
Projected rotational velocity [km/s].
- epsilonfloat
Linear limb-darkening coefficient (0-1).
- edgeHandlingstring, {“firstlast”, “None”}
The method used to handle edge effects.
- Returns
- Broadened spectrumarray
An array of the same size as the input flux array, which contains the broadened spectrum.
Example¶
Apply rotational broadening to a Gaussian and check the result equivalent widths.
from __future__ import print_function, division
import numpy as np
import matplotlib.pylab as plt
from PyAstronomy import funcFit as fuf
from PyAstronomy import pyasl
import scipy.integrate as sci
# Create a spectrum with a single Gaussian
# line using funcFit's GaussFit1d object.
# Note that this object is not used for
# fitting here, but only a calculate a
# Gaussian.
g = fuf.GaussFit1d()
g["mu"] = 5005.
g["A"] = -0.1
g["sig"] = 0.1
g["off"] = 1.0
# Evaluate the spectrum with 0.01 A bin size
wvl = np.linspace(5003., 5007., 400)
flux = g.evaluate(wvl)
# Obtain the broadened spectrum using
# vsini = 13.3 km/s and no limb-darkening
rflux = pyasl.rotBroad(wvl, flux, 0.0, 13.3)
# Obtain the broadened spectrum using
# vsini = 13.3 km/s and strong limb-darkening
lflux = pyasl.rotBroad(wvl, flux, 0.9, 13.3)
# Check that the area of the line did not change
# in response to the broadening
print("Initial EW [A]: ", 4. - sci.trapz(flux, wvl))
print("After broadening without LD: ", 4. - sci.trapz(rflux, wvl))
print("After broadening with LD: ", 4. - sci.trapz(lflux, wvl))
# Plot the results
plt.title("Rotational broadening")
plt.xlabel("Wavelength [A]")
plt.ylabel("Normalized flux")
plt.plot(wvl, flux, 'b-')
plt.plot(wvl, rflux, 'r-')
plt.plot(wvl, lflux, 'g-')
plt.show()
fastRotBroad—a faster algorithm¶
- PyAstronomy.pyasl.fastRotBroad(wvl, flux, epsilon, vsini, effWvl=None)¶
Apply rotational broadening using a single broadening kernel.
The effect of rotational broadening on the spectrum is wavelength dependent, because the Doppler shift depends on wavelength. This function neglects this dependence, which is weak if the wavelength range is not too large.
Note
numpy.convolve is used to carry out the convolution and “mode = same” is used. Therefore, the output will be of the same size as the input, but it will show edge effects.
- Parameters
- wvlarray
The wavelength
- fluxarray
The flux
- epsilonfloat
Linear limb-darkening coefficient
- vsinifloat
Projected rotational velocity in km/s.
- effWvlfloat, optional
The wavelength at which the broadening kernel is evaluated. If not specified, the mean wavelength of the input will be used.
- Returns
- Broadened spectrumarray
The rotationally broadened output spectrum.
Example: Using the fast algorithm¶
import numpy as np
import matplotlib.pylab as plt
from PyAstronomy import pyasl
# Create data with a Gaussian absoprtion line
wvl = np.arange(4999., 5011., 0.04)
flux = np.zeros(len(wvl))
# The Gaussian
A = -0.05
s = 0.1
mu = 5004.1635788
flux += A/np.sqrt(2.*np.pi*s**2) * \
np.exp(-(wvl-mu)**2/(2.*s**2))
# Apply the fast algorithm and ...
bfast = pyasl.fastRotBroad(wvl, flux, 0.81, 11.37)
# ... the slower one
bslow = pyasl.rotBroad(wvl, flux, 0.81, 11.37)
plt.xlabel("Wvl [A]")
plt.ylabel("Flux [au]")
plt.title("Initial spectrum (black), fast (blue), slow (red, shifted)")
plt.plot(wvl, flux, 'k.-')
plt.plot(wvl, bfast, 'b.-')
plt.plot(wvl, bslow+0.01, 'r.-')
plt.show()