AltaiPony-Flare science in Kepler, K2 and TESS light curves

Flares are unmistakeable signs of stellar magnetic activity, and a key to our understanding of stellar properties and evolution. They are violent explosions that penetrate all layers of a star’s atmosphere, and enhance its overall brightness by up to orders of magnitude within minutes. We observe flares as distinct signatures in time series of stellar photometric observations that we call light curves. Flaring rates and energies provide unique insights into the nature of the stars that produce them.


Summary
Flares are unmistakeable signs of stellar magnetic activity, and a key to our understanding of stellar properties and evolution. They are violent explosions that penetrate all layers of a star's atmosphere, and enhance its overall brightness by up to orders of magnitude within minutes. We observe flares as distinct signatures in time series of stellar photometric observations that we call light curves. Flaring rates and energies provide unique insights into the nature of the stars that produce them.
Space missions like Kepler (Koch et al., 2010), K2 (Howell et al., 2014), and TESS (Ricker et al., 2014) have collected light curves of tens of thousands of flaring stars, for timespans ranging from several weeks to multiple years. As TESS continues to gather high-cadence data, we developed AltaiPony to aid astronomers who require accurately characterized flare samples for their research. AltaiPony is a toolbox for statistical flares studies on photometric time series from these missions, including flare search and characterization, a framework to determine the algorithm's efficiency, and statistical analysis of flaring rates along with extensive documentation and Jupyter-based tutorials.

Functionality
AltaiPony is based on lightkurve (Lightkurve Collaboration et al., 2018), and can access most methods that are implemented in it, which makes it an accessible tool for new users who are already familiar with the software. lightkurve is a versatile Python package for light curve handling that includes visualization, basic tools for de-trending, transit detection, and asteroseismology. It is the most widely used software for handling Kepler, K2, and TESS data. AltaiPony inherits its main class FlareLightCurve directly from lightkurve's LightCurve, and its mission-specific derivatives.
AltaiPony was designed to be used by astronomers as a one stop shop solution that covers the essential steps of a typical flare study. We begin with adaptations of common de-trending tools like the Savitzky-Golay filter from lightkurve.flatten(), and K2SC (Aigrain et al., 2016). We tailored them to preserve flare signal, while removing astrophysical and instrumental variability. FlareLightCurve.detrend() also allows users to add their own custom detrending functions.
After de-trending, FlareLightCurve.find_flares() returns the occurrence times, amplitudes, durations, and relative energies of all flares above a defined noise threshold in the residual light curve using an adjustable iterative sigma-clipping procedure to identify candidate events as series of positive outliers (Davenport, 2016).
Usually, the measured flare amplitudes and durations differ systematically from their intrinsic properties due to the astrophysical and instrumental characteristics of the light curves in which they were found. Therefore, AltaiPony features an injection-recovery pipeline for synthetic flares that quantifies the cumulated effects of noise patterns, time sampling, de-trending and flare finding procedure of choice. FlareLightCurve.sample_flare_recovery() generates the synthetic data and performs the full flare search. The resulting sample can be used to determine the recovery probability and energy bias of candidate events in the original light curve.
Flare frequency distributions (FFDs), that is, the rates f of flares above a given energy E follow a power law: The free parameters α and β are essential indicators of stellar magnetic activity. To estimate their values and uncertainties for a given sample of flares, AltaiPony provides the analysis class FFD. It includes a fully Bayesian framework (Wheatland, 2004) that combines the power law nature of FFDs, and the exponential flare waiting times to predict flare frequencies, and uses emcee (Foreman-Mackey et al., 2013) to sample from the posterior distribution using the Markov Chain Monte Carlo method. As a fast alternative, we also implemented a modified maximum likelihood estimator (Maschberger & Kroupa, 2009) for α, and a least-squares fit to β with bootstrapped uncertainties.

Other Software
Other software packages for flare science in the field offer alternative methods, as well as complementing functions. Appaloosa (Davenport, 2016) was designed with Kepler light curves in mind. Appaloosa is this software's predecessor as many of its functions, such as the empirical flare model aflare, have been ingested into AltaiPony. stella (Feinstein et al., 2020) uses Convolutional Neural Networks to find flares and return their detection probabilities in TESS light curves. For individual events, allesfitter (Günther & Daylan, 2021) offers a Bayesian framework to fit multiple aspects of stellar variability at once, including flares.

Applications
AltaiPony has already been used in peer-reviewed publications to study flaring activity as a function of stellar age, mass, and rotation in K2 open cluster members (Ilin et al., , 2019, and TESS light curves of ultrafast rotating M dwarfs (Ramsay et al., 2020). The software remains under active development.