Plotting a Light Curve ====================== We can now look at plotting another kind of data: light curves. Through this, we will see some of the customisation options that are available through :func:`plot() `. The first step is to fetch some light curve data. For this, we introduce another system: the white dwarf pulsar, AR Sco. .. code-block:: python from AstroToolkit.Tools import query lightcurve_data = query(kind="lightcurve",source=6050296829033196032,survey="ztf") lightcurve_data.showdata() .. code-block:: console .kind: lightcurve .survey: ztf .source: 6050296829033196032 .pos: [245.44701332846378, -22.886218247040002] .identifier: J162147.28-225310.39 .figure: None .dataname: J162147.28-225310.39_6050296829033196032_ztf_ATKlightcurve.fits .plotname: J162147.28-225310.39_6050296829033196032_ztf_ATKlightcurve.html .trace: start -> extracted pos from source query, assumed [2016, 0] -> ztf: [2019, 0] -> ztf query performed -> [2000,0] -> end .data: band: g ra: [245.447071 245.4470765 245.447069 ... 245.4471056 245.4470825 245.4470859] dec: [-22.8864202 -22.8864231 -22.8864182 ... -22.8865103 -22.8865078 -22.8865203] mjd: [58235.38073661 58235.44304301 58246.36157061 ... 60524.18209167 60527.19084229 60529.19070857] mag: [16.7012329 14.7080278 16.4311085 ... 15.7799644 14.800931 16.0791607] mag_err: [0.02124788 0.019023 0.02014201 ... 0.01882575 0.01893662 0.01923533] band: r ra: [245.4470594 245.4470709 245.4470644 ... 245.4471027 245.4470833 245.4470933] dec: [-22.8864405 -22.8864381 -22.8864126 ... -22.8865397 -22.8865631 -22.8865343] mjd: [58218.40971316 58218.47173164 58246.40244004 ... 60504.26994093 60510.25643771 60527.15762767] mag: [15.6002302 15.0777416 14.619998 ... 15.7173185 14.579071 15.1474562] mag_err: [0.01373806 0.01352318 0.01368265 ... 0.01386647 0.01370837 0.01352345] band: i ra: None dec: None mjd: None mag: None mag_err: None Available Methods: .bin(), .crop(), .exportplot(), .plot(), .savedata(), .saveplot(), .showdata(), .showplot(), .sigmaclip() The attributes of the resulting :class:`LightcurveStruct ` are all familiar. We do have some new methods (:func:`bin() `, :func:`crop() ` and :func:`sigmaclip() `), but we won't look at those here. Let's now plot our light curve, skipping :func:`plot() `: .. code-block:: python lightcurve_data.showplot() .. code-block:: console Note: No plot was found. One will be generated with a default configuration. Plotting lightcurve data... Saving plot to local storage: J092444.48+080151.00_587316166180416640_ztf_ATKlightcurve.html .. raw:: html
| This looks a little bland, and the bands all merge together. We can pass some additional arguments to :func:`plot() ` to add some colour: .. code-block:: python lightcurve_data.plot(bands=["g","r","i"],colours=["green","red","blue"]) lightcurve_data.showplot() .. raw:: html
| **Note:** i-band data is missing since AR Sco has no i-band photometry in ZTF. That looks better. However, the options that we can pass to :func:`plot() ` are not purely stylistic. :class:`LightcurveStructs ` support three kinds of plotting: "lightcurve" (as seen above), "powspec", and "phasefold". The latter two utilise the Lomb-Scargle periodogram to perform time series analysis. Let's try generating a power spectrum: .. _power-spectrum: .. code-block:: python lightcurve_data.plot(kind="powspec").showplot() .. raw:: html
and a phase folded light curve: .. code-block:: python lightcurve_data.plot(kind="phasefold").showplot() .. raw:: html
Additional plotting options are available depending on the kind of data being plotted, and the way in which it is being plotted (e.g. the lightcurve/powspec/phasefold plots above). As an example, we could bin the phase-folded light curve and shift it slightly to the right to better align it with our phase axis: .. code-block:: python lightcurve_data.plot(kind="phasefold",bins=100,shift=0.115) .. raw:: html
For a full description of available parameters, see each :ref:`data structure's ` documentation. | Note: The code used in this tutorial can be executed using: .. code-block:: python from AstroToolkit.Examples import lightcurve_plotting