Fourier analysis#
import star_privateer as sp
import plato_msap4_demonstrator_datasets.plato_sim_dataset as plato_sim_dataset
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
sp.__version__
'1.1.2'
K2: Rotation period analysis#
t, s, dt = sp.load_k2_example ()
fig, ax = plt.subplots (1, 1, figsize=(8,4))
ax.scatter (t[s!=0]-t[0], s[s!=0], color='black',
marker='o', s=1)
ax.set_xlabel ('Time (day)')
ax.set_ylabel ('Flux (ppm)')
fig.tight_layout ()
As we want to recover rotation periods below 45 days, we only consider the section of the periodogram verifying \(P < P_\mathrm{cutoff} = 60\) days.
pcutoff = 60
As a preprocessing step, we compute the Lomb-Scargle periodogram (in the SAS framework, it will be directyly provided by MSAP1).
p_ps, ls = sp.compute_lomb_scargle (t, s)
Now we perform the periodogram analysis.
cond = p_ps < pcutoff
(prot, e_p, E_p,
_, param, h_ps) = sp.compute_prot_err_gaussian_fit_chi2_distribution (p_ps[cond], ls[cond], pfa_threshold=1e-6,
plot_procedure=False,
verbose=False)
fig= sp.plot_ls (p_ps, ls, filename='figures/fourier_k2.png', param_profile=param,
logscale=False, xlim=(0.1, 5))
IDP_SAS_PROT_FOURIER = sp.prepare_idp_fourier (param, h_ps, ls.size,
pcutoff=pcutoff, pthresh=None,
pfacutoff=1e-6)
df = pd.DataFrame (data=IDP_SAS_PROT_FOURIER)
df
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 0 | 1.393528 | 0.001392 | 0.001395 | 438.472941 | 1.000000e-16 |
| 1 | 0.779111 | 0.000778 | 0.000780 | 368.082305 | 1.000000e-16 |
| 2 | 2.787059 | 0.002784 | 0.002790 | 291.548014 | 1.000000e-16 |
| 3 | 2.683252 | 0.002680 | 0.002686 | 85.520009 | 1.000000e-16 |
| 4 | 0.225067 | 0.000427 | 0.000428 | 43.158470 | 1.000000e-16 |
| 5 | 0.129272 | 0.000028 | 0.000028 | 33.369658 | 3.219155e-15 |
df.to_latex (buf='data_products/idp_sas_prot_fourier_k2_211015853.tex',
formatters=['{:.2f}'.format, '{:.2f}'.format, '{:.2f}'.format,
'{:.2f}'.format, '{:.0e}'.format],
index=False, header=False)
np.savetxt ('data_products/IDP_SAS_PROT_FOURIER_K2.dat',
IDP_SAS_PROT_FOURIER)
PLATO: Rotation period analysis#
The PLATO simulation below encompasses both rotational modulation and low-frequency modulations due to activity. In order to analyse the rotational signal, we first filter out frequencies above 60 days (in PLATO, this will be done outside MSAP4).
filename = sp.get_target_filename (plato_sim_dataset, '040', filetype='csv')
t, s, dt = sp.load_resource (filename)
s_filtered = sp.preprocess (t, s, cut=60)
fig, ax = plt.subplots (1, 1, figsize=(8,4))
ax.scatter (t[s!=0]-t[0], s[s!=0], color='black',
marker='o', s=1, label="Unfiltered")
ax.scatter (t[s!=0]-t[0], s_filtered[s_filtered!=0], color='darkorange',
marker='o', s=1, label="Filtered")
ax.set_xlabel ('Time (day)')
ax.set_ylabel ('Flux (ppm)')
ax.legend ()
fig.tight_layout ()
As we want to recover rotation periods below 60 days, we only consider the section of the periodogram verifying \(P < P_\mathrm{cutoff} = 60\) days.
pcutoff = 60
As a preprocessing step, we compute the Lomb-Scargle periodogram (in the SAS framework, it will be directyly provided by MSAP1).
p_ps, ls = sp.compute_lomb_scargle (t, s_filtered)
Now we perform the periodogram analysis.
cond = p_ps < pcutoff
(prot, e_p, E_p,
_, param, h_ps) = sp.compute_prot_err_gaussian_fit_chi2_distribution (p_ps[cond],
ls[cond],
pfa_threshold=1e-6,
verbose=False)
sp.plot_ls (p_ps, ls, filename='figures/fourier_plato_short.png', param_profile=param,
logscale=False, xlim=(1, pcutoff),
)
IDP_SAS_PROT_FOURIER = sp.prepare_idp_fourier (param, h_ps, ls.size,
pcutoff=pcutoff, pthresh=None,
pfacutoff=1e-6)
df = pd.DataFrame (data=IDP_SAS_PROT_FOURIER)
df
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 0 | 25.714472 | 0.025694 | 0.025745 | 28.380401 | 4.726593e-13 |
| 1 | 26.704732 | 0.026685 | 0.026738 | 17.165303 | 3.509164e-08 |
| 2 | 23.942589 | 0.023925 | 0.023973 | 15.850085 | 1.307361e-07 |
df.to_latex (buf='data_products/idp_sas_prot_fourier_plato_040.tex',
formatters=['{:.2f}'.format, '{:.2f}'.format, '{:.2f}'.format,
'{:.2f}'.format, '{:.0e}'.format],
index=False, header=False)
np.savetxt ('data_products/IDP_SAS_PROT_FOURIER_PLATO.dat',
IDP_SAS_PROT_FOURIER)
PLATO: Long term modulation analysis#
This time, we are interested in recovering long term modulations. We consider the section of the periodogram verifying \(P > P_\mathrm{tresh} = 60\) days.
pthresh = 60
As a preprocessing step, we compute the Lomb-Scargle periodogram (in the SAS framework, it will be directyly provided by MSAP1).
p_ps, ls = sp.compute_lomb_scargle (t, s, normalisation="snr_flat")
Now we perform the periodogram analysis.
(plongterm, e_p, E_p,
_, param, h_ps) = sp.compute_prot_err_gaussian_fit_chi2_distribution (p_ps[p_ps>pthresh],
ls[p_ps>pthresh],
pfa_threshold=1e-6,
verbose=False)
fig = sp.plot_ls (p_ps, ls, filename='figures/fourier_plato_long.png', param_profile=param,
logscale=False, xlim=(1,8*pthresh))
IDP_SAS_LONGTERM_MODULATION_FOURIER = sp.prepare_idp_fourier (param, h_ps, ls.size,
pcutoff=None, pthresh=pthresh,
pfacutoff=1e-6)
df = pd.DataFrame (data=IDP_SAS_LONGTERM_MODULATION_FOURIER)
df
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 0 | 347.003860 | 0.346584 | 0.347278 | 8.754753e+06 | 1.000000e-16 |
| 1 | 693.938698 | 0.693030 | 0.694417 | 2.280495e+06 | 1.000000e-16 |
| 2 | 115.612182 | 0.115417 | 0.115648 | 5.105828e+05 | 1.000000e-16 |
| 3 | 86.663796 | 0.086471 | 0.086644 | 3.620016e+05 | 1.000000e-16 |
| 4 | 62.592651 | 0.062019 | 0.062142 | 2.829973e+05 | 1.000000e-16 |
| 5 | 231.113051 | 0.230567 | 0.231028 | 2.553851e+05 | 1.000000e-16 |
| 6 | 99.058919 | 0.098854 | 0.099052 | 1.641647e+05 | 1.000000e-16 |
| 7 | 77.045937 | 0.076886 | 0.077040 | 1.452372e+05 | 1.000000e-16 |
| 8 | 173.336225 | 0.172940 | 0.173286 | 1.025115e+05 | 1.000000e-16 |
df.to_latex (buf='data_products/idp_sas_longterm_modulation_fourier_plato_040.tex',
formatters=['{:.2f}'.format, '{:.2f}'.format, '{:.2f}'.format,
'{:.2f}'.format, '{:.0e}'.format],
index=False, header=False)
np.savetxt ('data_products/IDP_SAS_LONGTERM_MODULATION_FOURIER_PLATO.dat',
IDP_SAS_LONGTERM_MODULATION_FOURIER)