.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/lightcurves/lightcurve_timeseries.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_tutorials_lightcurves_lightcurve_timeseries.py: ################### Timeseries Analysis ################### Alongside the basic **data methods** shown in the :doc:`previous tutorial `, :class:`~ATK.Models.Lightcurve` objects also support Lomb-Scargle timeseries analysis. | Generating Power Spectra ======================== The :meth:`~ATK.Models.Lightcurve.pspec` method can be used to generate power spectra from one or more :class:`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** :math:`\mathbf{days}^{-1}`. This process transforms the :class:`~ATK.Models.DataSet`'s :class:`~ATK.Models.Lightcurve` objects into one or more :class:`~ATK.Models.Powspec` objects. Multi-band Power Spectra ------------------------ By default, :meth:`~ATK.Models.Lightcurve.pspec` combines all bands for each target before computing a combined power spectrum. .. GENERATED FROM PYTHON SOURCE LINES 19-27 .. code-block:: Python 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) .. rst-class:: sphx-glr-script-out .. code-block:: none .kind (str): Lightcurve .targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″) .exception (bool): False .data (list): 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() .. GENERATED FROM PYTHON SOURCE LINES 40-43 | A :class:`~ATK.Models.Powspec` can be plotted like any other kind of data, with :meth:`~ATK.Models.DataSet.plot` or :meth:`~ATK.Models.DataSet.open`: .. GENERATED FROM PYTHON SOURCE LINES 44-47 .. code-block:: Python pspec_data.open() .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 57-62 | Single-band Power Spectra ------------------------- To instead process each band individually, pass ``multiband = False`` to :meth:`~ATK.Models.Lightcurve.pspec`. This treats each band as being entirely separate: .. GENERATED FROM PYTHON SOURCE LINES 62-66 .. code-block:: Python pspec_data = asassn_query.apply("pspec", fmin=0, fmax=10, samples=10000, multiband=False, inplace=False) pspec_data.show(show_types=True) .. rst-class:: sphx-glr-script-out .. code-block:: none .kind (str): Lightcurve .targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″) .exception (bool): False .data (list): 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 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() .. GENERATED FROM PYTHON SOURCE LINES 73-76 | This generates one power spectrum per band: .. GENERATED FROM PYTHON SOURCE LINES 76-79 .. code-block:: Python pspec_data.open() .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 89-97 | | Phase-Folding Light Curves ========================== :class:`~ATK.Models.Lightcurve` objects can be phase folded with :meth:`~ATK.Models.Lightcurve.fold`. **By default,** :meth:`~ATK.Models.Lightcurve.fold` **first generates a power spectrum from which to derive an optimal frequency.** :meth:`~ATK.Models.Lightcurve.fold` therefore accepts all parameters that can be passed to :meth:`~ATK.Models.Lightcurve.pspec`. A multiband phase-folded light curve can threfore be generated and plotted as follows: .. GENERATED FROM PYTHON SOURCE LINES 98-103 .. code-block:: Python folded_data = asassn_query.apply("fold", fmin=0, fmax=10, samples=10000, inplace=False) folded_data.show(show_types=True) folded_data.open() .. rst-class:: sphx-glr-script-out .. code-block:: none .kind (str): Lightcurve .targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″) .exception (bool): False .data (list): 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 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() .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 116-125 | 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 :meth:`~ATK.Models.DataSet.apply` - in this case losing the true orbital frequency in favour of the peak frequency in the power spectrum: .. GENERATED FROM PYTHON SOURCE LINES 125-130 .. code-block:: Python 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() .. rst-class:: sphx-glr-script-out .. code-block:: none .kind (str): Lightcurve .targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″) .exception (bool): False .data (list): 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 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() .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 143-148 | Frequency Overriding -------------------- To avoid the derivation of an optimal frequency entirely, a frequency can be passed via the ``freq`` parameter: .. GENERATED FROM PYTHON SOURCE LINES 148-153 .. code-block:: Python folded_data = asassn_query.apply("fold", freq=2.773227732277323, inplace=False) folded_data.show(show_types=True) folded_data.open() .. rst-class:: sphx-glr-script-out .. code-block:: none .kind (str): Lightcurve .targets (list): 5346631922949364864 | 170.1° -54.7° (icrs, 2016-01-01T00:00:00.000, 3.0″) .exception (bool): False .data (list): 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 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() .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 166-171 | | | .. rubric:: Download this Tutorial .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.902 seconds) .. _sphx_glr_download_auto_tutorials_lightcurves_lightcurve_timeseries.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: lightcurve_timeseries.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: lightcurve_timeseries.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: lightcurve_timeseries.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_