.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/lightcurves/lightcurve_manipulation.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_manipulation.py: ################# Manipulating Data ################# :class:`~ATK.Models.Lightcurve` objects offer the first examples of **data methods** - these are methods that manipulate the containers themselves. Data Methods ============ The set of available methods depends on the ``kind`` of data that is being stored in the :class:`~ATK.Models.DataSet`, but all methods can be utilised via the :class:`~ATK.Models.DataSet`'s :meth:`~ATK.Models.DataSet.apply` method. | To showcase this, some data will first be fetched from ZTF for Al Com - a WZ Sge cataclysmic variable: .. GENERATED FROM PYTHON SOURCE LINES 15-22 .. code-block:: Python from ATK import query asassn_query = query("lightcurve", targets=3932951035266314496 , survey="ztf", path="example_lightcurve_4.fits.gz") asassn_query.show(show_all=True) asassn_query.open(time_format="original") .. rst-class:: sphx-glr-script-out .. code-block:: none .kind: Lightcurve .targets: 3932951035266314496 | 188.107° 14.345° (icrs, 2016-01-01T00:00:00.000, 3.0″) .exception: False .data: survey: ztf band: g correction: full search_pos: 188.107° 14.345° (icrs, 2019-01-01T00:00:00.000) separation: 0.088″ mjd: [58202.312, 58216.264, ..., 60846.259, 60853.206] d mag: [19.888, 20.018, ..., 19.771, 19.994] mag mag_err: [0.129, 0.141, ..., 0.118, 0.138] mag ra: [188.107, 188.107, ..., 188.107, 188.107] ° dec: [14.345, 14.345, ..., 14.345, 14.345] ° survey: ztf band: r correction: full search_pos: 188.107° 14.345° (icrs, 2019-01-01T00:00:00.000) separation: 0.043″ mjd: [58217.279, 58217.28, ..., 59269.348, 59269.348] d mag: [20.089, 19.978, ..., 19.804, 20.122] mag mag_err: [0.154, 0.145, ..., 0.103, 0.126] mag ra: [188.107, 188.107, ..., 188.107, 188.107] ° dec: [14.345, 14.345, ..., 14.345, 14.345] ° survey: ztf band: i correction: full search_pos: 188.107° 14.345° (icrs, 2019-01-01T00:00:00.000) separation: 0.077″ mjd: [58232.295, 58257.206, ..., 60416.388, 60450.212] d mag: [20.057, 19.959, ..., 19.185, 19.328] mag mag_err: [0.179, 0.171, ..., 0.107, 0.118] mag ra: [188.107, 188.107, ..., 188.107, 188.107] ° dec: [14.345, 14.345, ..., 14.345, 14.345] ° Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store() .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 38-43 | Cropping a Light Curve ---------------------- The returned :class:`~ATK.Models.Lightcurve` can be cropped by applying its :meth:`~ATK.Models.Lightcurve.crop` **data method**. This truncates all array-like attributes of the :class:`~ATK.Models.Lightcurve` to match a chosen MJD range, in this case focusing on the large outburst: .. GENERATED FROM PYTHON SOURCE LINES 43-47 .. code-block:: Python cropped_data = asassn_query.apply("crop", cmin=58550, cmax=58660, inplace=False) cropped_data.open(time_format="original") .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 57-68 | .. note:: **By default,** :meth:`~ATK.Models.DataSet.apply` **modifies the stored data containers in-place**. To instead operate on a copy of the :class:`~ATK.Models.DataSet` - thereby leaving the original unmodified - pass ``inplace=False`` to :meth:`~ATK.Models.DataSet.apply` (as above). | Binning a Light Curve --------------------- The :class:`~ATK.Models.Lightcurve` can also be binned, combining all array-like attributes into a requested number of ``bins`` or a given bin ``size``: .. GENERATED FROM PYTHON SOURCE LINES 69-73 .. code-block:: Python binned_data = asassn_query.apply("bin", bins=200, inplace=False) binned_data.open(time_format="original") .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 83-89 .. code-block:: Python import astropy.units as u binned_data = asassn_query.apply("bin", size=10*u.day, inplace=False) binned_data.open(time_format="original") .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 99-102 Sigma-Clipping a Light Curve ============================ The :class:`~ATK.Models.Lightcurve` can be sigma clipped by applying :meth:`~ATK.Models.Lightcurve.clip`, which clips all array-like attributes to eliminate data points where the light curve's brightness is outside a given number of standard deviation from the median: .. GENERATED FROM PYTHON SOURCE LINES 102-106 .. code-block:: Python clipped_data = binned_data.apply("clip", sigma=2, inplace=False) clipped_data.open(time_format="original") .. raw:: html
Bokeh Figure


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