Skip to content

pixel CCF

CCF

Initialize the CCF object.

Parameters:

Name Type Description Default
rv array - like

Radial velocity array where the CCF is defined [km/s or astropy unit].

required
intensity array - like

CCF intensity array.

required
normalize bool

If True, normalize the CCF by its median. Default is True.

True

convolved (bool, optional): If True, indicates that the CCF is already convolved with the instrumental profile. Default is False.

Attributes:

Name Type Description
rv array - like

Radial velocity array.

intensity array - like

Normalized or raw CCF intensity array. Indicates if the CCF is convolved.

n int

Number of points in the CCF.

step float

Step size between consecutive RV points.

width float

Maximum absolute value of RV, representing the CCF width.

_rv_units Unit

Units of the RV array.

_vrot Quantity

Rotational velocity, initialized to zero.

Source code in SOAP/classes.py
class CCF:
    """
    Initialize the CCF object.

    Args:
        rv (array-like):
            Radial velocity array where the CCF is defined [km/s or astropy unit].
        intensity (array-like):
            CCF intensity array.
        normalize (bool, optional):
            If True, normalize the CCF by its median. Default is True.
    convolved (bool, optional):
        If True, indicates that the CCF is already convolved with the instrumental profile. Default is False.

    Attributes:
        rv (array-like):
            Radial velocity array.
        intensity (array-like):
            Normalized or raw CCF intensity array.
            Indicates if the CCF is convolved.
        n (int):
            Number of points in the CCF.
        step (float):
            Step size between consecutive RV points.
        width (float):
            Maximum absolute value of RV, representing the CCF width.
        _rv_units (astropy.units.Unit):
            Units of the RV array.
        _vrot (astropy.units.Quantity):
            Rotational velocity, initialized to zero.
    """
    # is this a CCF?
    _ccf: bool = True

    @maybe_quantity_input(rv=kms)
    def __init__(self, rv, intensity, normalize=True, convolved=False):

        self.rv = rv
        if normalize:
            self.intensity = intensity / np.median(intensity)
        else:
            self.intensity = intensity
        self.convolved = convolved
        self.n = len(self.rv)  # Number of points of the CCF
        self.step = self.rv[1] - self.rv[0]
        #! is this correct? it assumes a symmetric CCF?
        self.width = np.max(np.abs(self.rv))
        self._rv_units = rv.unit
        self._vrot = 0.0 * self._rv_units

    @property
    def vrot(self):
        """Rotation velocity of the star to which the CCF is associated"""
        return self._vrot

    @vrot.setter
    def vrot(self, value):
        self._vrot = value

    @property
    def n_v(self):
        """
        Total number of RV bins in the CCF after considering a stellar rotation
        velocity equal to vrot
        """
        # The CCF is assumed to have a rotational velocity equal to 0 because it
        # is taken in the stellar disk center. To consider rotation when
        # simulating the emerging spectrum on the limb of the star (velocity
        # different from 0), we have to extrapolate outside of the range
        # [-self.width, self.width]. This is done by calculating self.n_v which
        # is the number of additional RV bins required to consider a stellar
        # rotation of star.vrot

        # self.n_v must by an odd integer so that we have as many values on the
        # positive side of the CCF as on the negative one (because 0 is present)
        r = np.round(((1.1 * self.vrot) / self.step) * 2)
        if r % 2 == 0:
            return int(self.n + r)
        else:
            return int(self.n + r + 1)

    @property
    def v_interval(self):
        # self.v_interval gives the difference in radial velocity
        # between the minimum and maximum values of the CCF,
        # once the extrapolation is done
        # self.n_v gives the number of points of the extrapolated CCF.
        # (self.n_v-1) gives the number of intervals,
        # which is then multiplied by the sampling of the CCF
        # self.step to give self.v_interval
        return self.step * (self.n_v - 1) / 2.0

    def plot(self, ax=None, **kwargs):
        import matplotlib.pyplot as plt

        if ax is None:
            _, ax = plt.subplots(1, 1)
        ax.plot(self.rv, self.intensity, label=str(self), **kwargs)
        ax.set(ylabel="CCF", xlabel=f"RV [{self._rv_units}]")

n_v property

Total number of RV bins in the CCF after considering a stellar rotation velocity equal to vrot

vrot property writable

Rotation velocity of the star to which the CCF is associated

solarCCF

Bases: CCF

Solar CCF obtained by cross-correlation with a G2 mask (Pepe+2002), which spectra was obtained with the FTS spectrograph, for the quiet Sun (Wallace+1998) or a sunspot umbra(Wallace+1995). Source: https://nso.edu/data/historical-archive/

Parameters:

Name Type Description Default
vrot float

Rotation velocity of the star (used to select a wider CCF window)

required
active_region bool, default False

Get the CCF for the active region instead of the quiet Sun

False

Attributes:

Name Type Description
rv array - like

Radial velocity array where the CCF is defined [km/s].

intensity array - like

CCF intensity array.

n int

Number of points in the CCF.

step float

Step size between consecutive RV points.

width float

Maximum absolute value of RV, representing the CCF width.

Source code in SOAP/classes.py
class solarCCF(CCF):

    """ 
    Solar CCF obtained by cross-correlation with a G2 mask (Pepe+2002), which spectra was obtained with the FTS spectrograph, for the quiet Sun (Wallace+1998) or a sunspot umbra(Wallace+1995).
    Source: https://nso.edu/data/historical-archive/

    Args:
        vrot(float):
            Rotation velocity of the star (used to select a wider CCF window)
        active_region (bool, default False):
            Get the CCF for the active region instead of the quiet Sun

    Attributes:
        rv (array-like):
            Radial velocity array where the CCF is defined [km/s].
        intensity (array-like):
            CCF intensity array.
        n (int):
            Number of points in the CCF.
        step (float):
            Step size between consecutive RV points.
        width (float):
            Maximum absolute value of RV, representing the CCF width.
    """

    @maybe_quantity_input(vrot=kms)
    def __init__(self, vrot, active_region=False):
        this_dir = os.path.dirname(__file__)
        if vrot < 10 * kms:
            f = "CCF_solar_spectrum_G2_FTS_reso_not_evenly_sampled_in_freq.rdb"
            file = os.path.join(this_dir, "solarCCFs", f)
        else:
            f = "CCF_solar_spectrum_G2_FTS_reso_not_evenly_sampled_in_freq_extra_large_low_resolution.rdb"
            file = os.path.join(this_dir, "solarCCFs", f)

        data_solar_ccf = read_rdb(file)
        rv_ccf = data_solar_ccf["vrad"].copy()
        if active_region:
            intensity_ccf = data_solar_ccf["CCF_spot"].copy()
        else:
            intensity_ccf = data_solar_ccf["CCF"].copy()
        self.active_region = active_region

        super().__init__(rv_ccf, intensity_ccf, convolved=False)
        self.vrot = vrot

    def __repr__(self):
        which = "sunspot" if self.active_region else "quiet Sun"
        return f"solarCCF(FTS, {which})"

gaussianCCF

Bases: CCF

A local stellar CCF modeled by a Gaussian profile, which is a common approximation. The Gaussian is defined by its depth and FWHM, and is centered at a given radial velocity. The CCF is defined over a window of RV values, with a specified step size.

Parameters:

Name Type Description Default
depth float

Amplitude of the CCF, between 0 and 1

0.56
fwhm float

Full width at half maximum of the CCF [km/s]

2.5
RV float

Radial velocity where the CCF is centered [km/s]

0.0
window float

The CCF is defined between -window and +window [km/s]

20
step float

Radial velocity step of the CCF [km/s]

0.1
convolved bool

Whether the CCF is already convolved with the instrumental profile.

True

Attributes:

Name Type Description
rv array - like

Radial velocity array where the CCF is defined [km/s].

intensity array - like

CCF intensity array.

n int

Number of points in the CCF.

step float

Step size between consecutive RV points [km/s].

Source code in SOAP/classes.py
class gaussianCCF(CCF):
    """
    A local stellar CCF modeled by a Gaussian profile, which is a common approximation. The Gaussian is defined by its depth and FWHM, and is centered at a given radial velocity. The CCF is defined over a window of RV values, with a specified step size.

    Args:
        depth (float):
            Amplitude of the CCF, between 0 and 1
        fwhm (float):
            Full width at half maximum of the CCF [km/s]
        RV (float):
            Radial velocity where the CCF is centered [km/s]
        window (float):
            The CCF is defined between -window and +window [km/s]
        step (float):
            Radial velocity step of the CCF [km/s]
        convolved (bool, optional):
            Whether the CCF is already convolved with the instrumental
            profile.

    Attributes:
        rv (array-like):
            Radial velocity array where the CCF is defined [km/s].
        intensity (array-like):
            CCF intensity array.
        n (int):
            Number of points in the CCF.
        step (float):
            Step size between consecutive RV points [km/s].
    """

    @maybe_quantity_input(fwhm=kms, RV=kms, window=kms, step=kms)
    def __init__(
        self, depth=0.56, fwhm=2.5, RV=0.0, window=20, step=0.1, convolved=True
    ):
        """
        Args:
            depth (float):
                Amplitude of the CCF, between 0 and 1
            fwhm (float):
                Full width at half maximum of the CCF [km/s]
            RV (float):
                Radial velocity where the CCF is centered [km/s]
            window (float):
                The CCF is defined between -window and +window [km/s]
            step (float):
                Radial velocity step of the CCF [km/s]
            convolved (bool, optional):
                Whether the CCF is already convolved with the instrumental
                profile.
        """
        self._depth = depth
        self._fwhm = fwhm
        sigma = fwhm / (2 * np.sqrt(2 * np.log(2)))
        rv_ccf = unit_arange(RV - window, RV + window + step, step)
        intensity_ccf = -depth * np.exp(-((rv_ccf - RV) ** 2) / (2 * sigma**2)) + 1
        super().__init__(rv_ccf, intensity_ccf, convolved=convolved)

    def __repr__(self):
        # which = 'sunspot' if self.active_region else 'quiet Sun'
        pars = f"depth={self._depth:.3f}, fwhm={self._fwhm:.3f}"
        return f"gaussianCCF({pars})"