Note
Go to the end to download the full example code.
Timeseries Analysis#
Alongside the basic data methods shown in the previous tutorial, Lightcurve objects also support Lomb-Scargle timeseries analysis.
Generating Power Spectra#
The pspec() method can be used to generate power spectra from one or more Lightcurves. A minimum and maximum frequency must be provided, along with a number of test frequencies in this range. If no units are given, values are assumed to be in \(\mathbf{days}^{-1}\).
This process transforms the DataSet’s Lightcurve objects into one or more Powspec objects.
Multi-band Power Spectra#
By default, pspec() combines all bands for each target before computing a combined power spectrum.
from ATK import query
asassn_query = query("lightcurve", targets=5346631922949364864, survey="asassn", path="example_lightcurve_5.fits.gz")
pspec_data = asassn_query.apply("pspec", fmin=0, fmax=10, samples=10000, inplace=False)
pspec_data.show(show_types=True)
<Lightcurve DataSet>
.kind (str): Lightcurve
.targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″)
.exception (bool): False
.data (list):
<asassn v, g-band Powspec>
survey (str): asassn
band (str): v, g
frequency (astropy.Quantity): [0.0, 0.001, ..., 9.999, 10.0] d⁻¹
power (numpy.ndarray): [0.0, 0.001, ..., 0.001, 0.001]
fopt (astropy.Quantity): 5.547 d⁻¹
popt (astropy.Quantity): 0.18 d
Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store()
A Powspec can be plotted like any other kind of data, with plot() or open():
pspec_data.open()
Single-band Power Spectra#
To instead process each band individually, pass multiband = False to pspec(). This treats each band as being entirely separate:
pspec_data = asassn_query.apply("pspec", fmin=0, fmax=10, samples=10000, multiband=False, inplace=False)
pspec_data.show(show_types=True)
<Lightcurve DataSet>
.kind (str): Lightcurve
.targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″)
.exception (bool): False
.data (list):
<asassn v-band Powspec>
survey (str): asassn
band (str): v
frequency (astropy.Quantity): [0.0, 0.001, ..., 9.999, 10.0] d⁻¹
power (numpy.ndarray): [nan, 0.009, ..., 0.006, 0.002]
fopt (astropy.Quantity): 5.547 d⁻¹
popt (astropy.Quantity): 0.18 d
<asassn g-band Powspec>
survey (str): asassn
band (str): g
frequency (astropy.Quantity): [0.0, 0.001, ..., 9.999, 10.0] d⁻¹
power (numpy.ndarray): [nan, 0.001, ..., 0.002, 0.001]
fopt (astropy.Quantity): 5.547 d⁻¹
popt (astropy.Quantity): 0.18 d
Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store()
This generates one power spectrum per band:
pspec_data.open()
Phase-Folding Light Curves#
Lightcurve objects can be phase folded with fold(). By default, fold() first generates a power spectrum from which to derive an optimal frequency. fold() therefore accepts all parameters that can be passed to pspec().
A multiband phase-folded light curve can threfore be generated and plotted as follows:
folded_data = asassn_query.apply("fold", fmin=0, fmax=10, samples=10000, inplace=False)
folded_data.show(show_types=True)
folded_data.open()
<Lightcurve DataSet>
.kind (str): Lightcurve
.targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″)
.exception (bool): False
.data (list):
<asassn v-band Lightcurve>
survey (str): asassn
band (str): v
mag (astropy.Quantity): [11.922, 11.987, ..., 11.963, 12.079] mag
mag_err (astropy.Quantity): [0.002, 0.001, ..., 0.001, 0.003] mag
phase (astropy.Quantity): [0.938, 0.357, ..., 0.667, 0.281]
fopt (astropy.Quantity): 2.773 d⁻¹
popt (astropy.Quantity): 0.361 d
<asassn g-band Lightcurve>
survey (str): asassn
band (str): g
mag (astropy.Quantity): [12.097, 12.213, ..., 12.196, 12.198] mag
mag_err (astropy.Quantity): [0.001, 0.002, ..., 0.003, 0.003] mag
phase (astropy.Quantity): [0.453, 0.237, ..., 0.971, 0.995]
fopt (astropy.Quantity): 2.773 d⁻¹
popt (astropy.Quantity): 0.361 d
Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store()
Frequency Optimisation#
Despite the underlying power spectrum being the same, the photometry in the above example has been folded on a different peak frequency - in this case the first subharmonic (i.e. 0.5 * fopt).
By default, a phase-dispersion metric is calculated for a set of harmonics either side of the peak frequency and the best is chosen. This can help to preserve real periodic structure, especially if the modulation is asymmetric as seen here.
This behaviour can be disabled by passing optimise=False to apply() - in this case losing the true orbital frequency in favour of the peak frequency in the power spectrum:
folded_data = asassn_query.apply("fold", fmin=0, fmax=10, samples=10000, optimise=False, inplace=False)
folded_data.show(show_types=True)
folded_data.open()
<Lightcurve DataSet>
.kind (str): Lightcurve
.targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″)
.exception (bool): False
.data (list):
<asassn v-band Lightcurve>
survey (str): asassn
band (str): v
mag (astropy.Quantity): [11.922, 11.987, ..., 11.963, 12.079] mag
mag_err (astropy.Quantity): [0.002, 0.001, ..., 0.001, 0.003] mag
phase (astropy.Quantity): [0.875, 0.715, ..., 0.335, 0.562]
fopt (astropy.Quantity): 5.547 d⁻¹
popt (astropy.Quantity): 0.18 d
<asassn g-band Lightcurve>
survey (str): asassn
band (str): g
mag (astropy.Quantity): [12.097, 12.213, ..., 12.196, 12.198] mag
mag_err (astropy.Quantity): [0.001, 0.002, ..., 0.003, 0.003] mag
phase (astropy.Quantity): [0.905, 0.473, ..., 0.942, 0.989]
fopt (astropy.Quantity): 5.547 d⁻¹
popt (astropy.Quantity): 0.18 d
Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store()
Frequency Overriding#
To avoid the derivation of an optimal frequency entirely, a frequency can be passed via the freq parameter:
folded_data = asassn_query.apply("fold", freq=2.773227732277323, inplace=False)
folded_data.show(show_types=True)
folded_data.open()
<Lightcurve DataSet>
.kind (str): Lightcurve
.targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″)
.exception (bool): False
.data (list):
<asassn v-band Lightcurve>
survey (str): asassn
band (str): v
mag (astropy.Quantity): [11.922, 11.987, ..., 11.963, 12.079] mag
mag_err (astropy.Quantity): [0.002, 0.001, ..., 0.001, 0.003] mag
phase (astropy.Quantity): [0.09, 0.509, ..., 0.775, 0.388]
fopt (astropy.Quantity): 2.773 d⁻¹
popt (astropy.Quantity): 0.361 d
<asassn g-band Lightcurve>
survey (str): asassn
band (str): g
mag (astropy.Quantity): [12.097, 12.213, ..., 12.196, 12.198] mag
mag_err (astropy.Quantity): [0.001, 0.002, ..., 0.003, 0.003] mag
phase (astropy.Quantity): [0.562, 0.346, ..., 0.954, 0.977]
fopt (astropy.Quantity): 2.773 d⁻¹
popt (astropy.Quantity): 0.361 d
Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store()
Download this Tutorial
Total running time of the script: (0 minutes 4.902 seconds)