smurfs.Smurfs¶
-
class
Smurfs
(file=None, time=None, flux=None, target_name=None, flux_type='PDCSAP', label=None, quiet_flag=False, mission='TESS', sigma_clip=4, iters=1, do_pca=False, do_psf=False, apply_file_correction=False)[source]¶ The Smurfs class is the main way to start your frequency analysis. The workflow for a generic problem is the following:
Instantiate the Smurfs class, by providing the light curve through one of different methods.
Call ‘run’, by providing at least the signal to noise ratio and window size of the analysis.
Either save the analysis using ‘save’ or get the result from the class and continue your analysis.
After ‘run’ has finished, you can access the results through various channels:
Use the ‘ff’ property (returns the ‘FFinder’ instance, where the analysis happens)
Use the ‘result’ property
The class also has other interesting properties like ‘combinations’ (calculates all possible combinations for the frequencies from the results, uses [pyfcomb](https://github.com/MarcoMuellner/pyfcomb) ), ‘nyquist’ ( the nyquist frequency of the provided data) and more.
You can also plot the results using the ‘plot_lc’ or ‘plot_pdg’ methods.
You can provide a light curve through three different methods:
Set target_name: Can be any star that has been observed by the TESS or Kepler mission. You can provide any TIC or KIC ID (including KIC/TIC) or any name resolvable by Simbad.
Set time and flux
Set file: Needs to be an ASCII file containing time and flux
Either can be used. 1) and 2) will be automatically sigma clipped and converted to magnitude.
- Parameters
file – ASCII file containing time and flux
time – time column of the light curve
flux – flux column of the light curve
target_name – Name of the target, resolvable by Simbad or either KIC/TIC ID
flux_type – If you supply a target name that has been observed by TESS SC mode, you can choose either ‘PCDSAP’ or ‘SAP’ flux for that target.
label – Optional label for the star. Results will be saved under this name
quiet_flag – Quiets Smurfs (no more print message will be piped to stdout)
-
property
combinations
¶ Gives a pandas dataframe of all possible combinations for the frequencies from result. It consists of the following columns in this order:
Name: Name of the frequency
ID: Frequency ID (order in which it was removed from the light curve)
Frequency: The frequency for which combinations where searched.
Amplitude: Amplitude of the frequency
Solution: Best solution for this frequency
Residual: Residual for the best solution
Independent: Flag if the frequency is independent according to the solver
Other_solutions: All other possible solutions for this frequency
Will be populated after run was called.
-
property
result
¶ Gives a pandas dataframe of the result from smurfs. It consists of the following columns in this order:
f_obj: Frequency object, that represents a given frequency
frequency
amp
phase
snr
res_noise: Residual noise
significant: Flag that shows if a frequency is significant or not
-
property
ff
¶ Returns the FrequencyFinder object.
-
property
settings
¶ Returns a dataframe consising of the settings used in the analysis.
-
property
statistics
¶ Returns a dataframe consisting of various statistics of the run.
-
property
obs_length
¶ Returns the length of the data set.
-
property
nyquist
¶ Returns the nyquist frequency
-
property
duty_cycle
¶ Shows the duty cycle of the light curve
-
property
periodogram
¶ Returns a Periodogram object of the light curve.
-
property
spectral_window
¶ Computes the spectral window of a given dataset by transforming the light curve with constant flux.
-
fold
(period, t0=None, transit_midpoint=None)[source]¶ Returns a folded light curve. Signature equivalent to lightkurve.LightCurve.fold.
-
flatten
(window_length=101, polyorder=2, return_trend=False, break_tolerance=5, niters=3, sigma=3, mask=None, **kwargs)[source]¶ Flattens the light curve by applying a Savitzky Golay filter. Signature equivalent to lightkurve.LightCurve.flatten.
-
run
(snr=4, window_size=2, f_min=None, f_max=None, skip_similar=False, similar_chancel=True, extend_frequencies=0, improve_fit=True, mode='lmfit', frequency_detection=None)[source]¶ Starts the frequency analysis by instantiating a FrequencyFinder object and running it. After finishing the run, combinations are computed. See FrequencyFinder.run for an explanation of the algorithm.
- Parameters
snr (
float
) – Signal to noise ratio, that provides a lower end of the analysis.window_size (
float
) – Window size, with which the SNR is computed.f_min (
Optional
[float
]) – Minimum frequency that is considered in the analysis.f_max (
Optional
[float
]) – Maximum frequency that is considered in the analysis.skip_similar (
bool
) – Flag that skips a certain range if too many similar frequencies in this range are found in a row.similar_chancel – Flat that chancels the run after 10 frequencies found that are too similar.
extend_frequencies (
int
) – Extends the analysis by this number of insignificant frequencies.improve_fit – If this flag is set, all combined frequencies are re-fitted after every new frequency was found
mode – Fitting mode. You can choose between ‘scipy’ and ‘lmfit’
frequency_detection – If this value is not None and the ratio between the amplitude of the found frequency and the amplitude of the frequency in the original spectrum exceeds this value, this frequency is ignored.
-
improve_result
()[source]¶ Fits the combined found frequencies to the original light curve, hence improving the fit of the total model.
-
plot_lc
(show=False, result=None, **kwargs)[source]¶ Plots the light curve. If a result is already computed, it also plots the resulting model
- Parameters
show – if this is set, pyplot.show() is called
kwargs – kwargs for lightkurve.LightCurve.scatter
-
plot_pdg
(show=False, plot_insignificant=False, **kwargs)[source]¶ Plots the periodogram. If the result is already computed, it will mark the found frequencies in the periodogram.
- Parameters
show – if this is set, pyplot.show() is called
plot_insignificant – Flag, if set, insignififcant frequencies are marked in the perioodogram
kwargs – kwargs for lightkurve.Periodogram.plot
- Returns
-
save
(path, store_obj=False)[source]¶ Saves the result of the analysis to a given folder.
- Parameters
path (
str
) – Path where the result is storedstore_obj – If this is set, the Smurfs object is stored, and can be later reloaded.