update discussion, and more

This commit is contained in:
2025-06-01 16:34:18 +02:00
parent 67c2fc688a
commit 4cfffa1010
11 changed files with 5987 additions and 366 deletions
@@ -17,14 +17,16 @@ The initial dataset was taken from a list of well known flaring stars from \cite
This chapter explains the methods used in this study, split into the algorithms for flare detection and folding lightcurves. Everything, like the GUI discussed in chapter \ref{sec:gui}, was written in python 3 (\cite{10.5555/1593511}). It also makes extensive use of the python packages astropy (\cite{astropy:2018}), numpy (\cite{numpy}), scipy (\cite{scipy}), pandas (\cite{pandas}) and lightkurve (\cite{lightkurve}). The focus of this chapter lays in the description of the method used to create the final output, which is less customizable than the GUI, which exposes most parameters offered in the functions of the lightkurve API. Unless stated otherwise, the default parameters are used. Furthermore for the final output only PDCSAP\_FLUX is used, which is set as the default flux in the lightkurve $LightCurve$ objects after reading the fit file. The methods are the same for both $KeplerLightCurve$ and $TessLightCurve$ subclasses.
\subsection{Flare detection}
\label{sec:data:data_reduction:flare_detection}
The first step is to normalize the lightcurve. This is done to apply the same thresholds to all files in later steps. An example of this is shown in figure \ref{fig:full_gui_normal_selection_normalize_options} in chapter \ref{sec:gui:data_display}. The normalization is done via the $normalize()$ function of the $LightCurve$ class of the lightkurve api. Afterwards the lightcurves are flattened by called $flatten()$ of the $LightCurve$ objects. The resulting object is then used as the base for the detection of flares. This removes all longterm trends like brightness changes due to spot modulation or similar, while retaining short term events like flares or transits. A similar approach was used by \cite{au_mic_flaring_spi}.\\
The next step is then to call $calculateFlareFitsForLightcurve()$ with the flattened lightcurve as well as the normalized lightcurve as parameters. It returns two lists of dictionaries with the data for the flare peak as well as a fit which is described in the following paragraphs.
It parses the flattened lightcurve with the scipy $find_peaks$ function. This function returns local maxima, which can be further filtered by their minimum height as well as the minimum distance of datapoints they need to be apart. The minimum distance between points is set to 1 with no minimum required height. Afterwards the found peaks are sorted by height, and the highest 100 are returned. This was found to be a good amount as the most flares per fits file found in this study were around 70 for CD-56 1032A and B.\\
It parses the flattened lightcurve with the scipy $find\_peaks$ function. This function returns local maxima, which can be further filtered by their minimum height as well as the minimum distance of datapoints they need to be apart. The minimum distance between points is set to 1 with no minimum required height. Afterwards the found peaks are sorted by height, and the highest 100 are returned. This was found to be a good amount as the most flares per fits file found in this study were around 70 for CD-56 1032A and B.\\
Afterwards each individual peak is checked. For this purpose every datapoint of the normalized flattened lightcurve is subtracted by 1 to move the average from 1 to 0. Additionally the star and end point of the flare are estimated. This is done by checking the datapoints before and after the peak. If it finds that the flux delta is below 0.005 for three consecutive datapoints, it stops, and assumes that the last checked point is the start/end of the flare. In the case it finds an infinite or NaN value (which can happen if there are gaps in the lightcurve data), or it reaches 100 datapoints before/after it will stop. This was found to cover most flares detected and provides enough datapoints for the following steps.\\
Afterwards multiple checks are done. The first checking if the 1 datapoint before the peak, and 1 after the peak are above a threshold of 0.003, or if 2 datapoint after the peak after above the same threshold (which is a similar approach to \cite{kepler_411_study}). Afterwards it is checked if the datapoint at two indices before the peak is larger than the datapoint right before the registered peak. While this eliminates the positive detection of 2 flares in they case of them appearing very shortly after another, it was by visual inspection found to eliminate more false positives. Shortly after another appearing flares are still allowed, if the criteria are met, and theres atleast one more datapoint between the peaks. Then a fit of the flare is generated. The first half of the fit, till the peak, is that of a gaussian function, with the second half being an exponential decay (similar approach to \cite{au_mic_flaring_spi} and \cite{doyle_2018}). Then the residual sum of squares (RSS) between the fit and the flux of the flare, as well as the total sum of squares (TSS) are calculated. Afterwards R-squared is calculated, and if it is below 0.8, the flare is rejected as the flare would not have the typical form. In the last step, the location of the flare in the normalized and flattened lightcurve are compared. This step has been introduced, as in some rare cases the flattening algorithm can produce a large spike (values of 10 or higher when normalized).
\subsection{Lightcurve folding}
\label{sec:data:data_reduction:lightcurve_folding}
This section will mainly describe how the $getOptimizedFold()$ function works. It takes the normalized lightcurve as well as a fit type as parameters. The fit type can either be "sine" for a sine fit, "poly" for a polynomlial fit, or "linear" for a linear fit. The default value is "sine", but can be changed for each individual star in the GUI.
The function at first generates two periodograms with the lightkurve function $to\_periodogram$. The first one uses the lombscargle algorithm, while the second one uses the boxleastsquares algorithm. Afterwards the 4 highest peaks of each are taken and converted into periods (unit in days).