.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/datapages/datapage_plotting.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_datapages_datapage_plotting.py: #################### Generating Datapages #################### ATK supports the creation of **datapages** as a means of neatly combining plots into a single grid. To demonstrate this, some data must first be acquired: .. GENERATED FROM PYTHON SOURCE LINES 7-21 .. code-block:: Python from ATK import query target = 587316166180416640 lc = query("lightcurve", survey="asassn", targets=target, path="datapage_lc.fits.gz") pspec = lc.apply("pspec", fmin=0, fmax=60, samples=10000, inplace=False) fold = lc.apply("fold", fmin=0, fmax=60, samples=10000, inplace=False) image = query("image", survey="panstarrs", band="g", targets=target, overlays=["gaia","galex"], path="datapage_image.fits.gz") spec = query("spectrum", survey="sdss", targets=target, path="datapage_spec.fits.gz") sed = query("sed", targets=target, path="datapage_sed.fits.gz") hrd = query("hrd", targets=target, path="datapage_hrd.fits.gz") table = query("datatable", columns={"gaia": ["Gmag", "BPmag", "RPmag"], "galex": ["NUVmag", "FUVmag"]}, targets=target, radius=image.data[0].size) .. GENERATED FROM PYTHON SOURCE LINES 31-34 | The only other requirement is to define the **datapage's** layout. This is done by defining a grid, with each cell in the grid being a :class:`~ATK.Models.DataSet`: .. GENERATED FROM PYTHON SOURCE LINES 34-44 .. code-block:: Python layout = [[image, image, hrd, hrd, lc, lc, lc, lc ], [image, image, hrd, hrd, lc, lc, lc, lc ], [pspec, pspec, pspec, pspec, fold, fold, fold, fold ], [pspec, pspec, pspec, pspec, fold, fold, fold, fold ], [spec, spec, spec, spec, sed, sed, sed, sed ], [spec, spec, spec, spec, sed, sed, sed, sed ], [table, table, table, table, table, table, table, table], [table, table, table, table, table, table, table, table]] .. GENERATED FROM PYTHON SOURCE LINES 45-48 | The above example defines a **datapage** where the first row contains a 2x2 image in the top-left corner, followed by a 2x2 HRD and a 4x2 light curve, etc. Passing this to :func:`~ATK.Visualisation.grid` returns a :class:`~ATK.Models.DataPages` object, which contains one **datapage** per target in the input :class:`~ATK.Models.DataSet` objects: .. GENERATED FROM PYTHON SOURCE LINES 48-54 .. code-block:: Python from ATK import grid datapages = grid(layout) datapages.show() .. rst-class:: sphx-glr-script-out .. code-block:: none <1 DataPages> .targets: 587316166180416640 | 141.185° 8.031° (icrs, 2016-01-01T00:00:00.000) .figures: Available Methods: .open(), .save(), .show() .. GENERATED FROM PYTHON SOURCE LINES 55-63 | | Opening a Datapage ================== The only remaining step is to open or save the **datapage**. Like everything in ATK, :class:`DataPages ` are designed to work with multiple targets. A **datapage** for a specific target can be opened by passing a Gaia source ID or :class:`~ATK.Models.Target` to :meth:`~ATK.Models.DataPages.open`. For example, to open the above **datapage**: .. GENERATED FROM PYTHON SOURCE LINES 63-66 .. code-block:: Python datapages.open(target) .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 74-107 .. note:: Since matching by :class:`~astropy.coordinates.SkyCoord` is inexact, this is not supported by :meth:`~ATK.Models.DataPages.open` and :meth:`~ATK.Models.DataPages.save`. A :class:`~ATK.Models.Target` should therefore be used for exact matching if a Source ID is not available (see :doc:`here <../getting_started/data_query>`). | | Saving Datapages To Local Files =============================== Saving and Opening ------------------ To open a **datapage** and save it to local files, :meth:`~ATK.Models.DataPages.open` can be provided with a ``path``: .. code-block:: python target = 587316166180416640 datapages = ... datapages.open(target, path="example_datapage.html") | | Saving Without Opening ---------------------- **Datapages** can also be saved without opening them via :meth:`~ATK.Models.DataPages.save`: .. code-block:: python target = 587316166180416640 datapages.save(target, path="example_datapage.html") .. GENERATED FROM PYTHON SOURCE LINES 110-115 | | | .. rubric:: Download this Tutorial .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.249 seconds) .. _sphx_glr_download_auto_tutorials_datapages_datapage_plotting.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: datapage_plotting.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: datapage_plotting.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: datapage_plotting.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_