.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/images/image_query.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_images_image_query.py: ################### Working with Images ################### Performing an Image Query ========================= To fetch an image, set the :func:`~ATK.Tools.query` ``kind`` to ``"image"`` and supply both a ``band`` and a ``size`` (rather than a ``radius``). A ``survey`` must also be chosen - this tutorial will use Pan-STARRS: .. GENERATED FROM PYTHON SOURCE LINES 9-15 .. code-block:: Python from ATK import query ps_query = query("image", targets=2552928187080872832, survey="panstarrs", band="g", size=120, path="example_image_1.fits.gz") ps_query.show(show_types=True) .. rst-class:: sphx-glr-script-out .. code-block:: none .kind (str): Image .targets (list): 2552928187080872832 | 12.297° 5.377° (icrs, 2016-01-01T00:00:00.000) .exception (bool): False .data (list): survey (str): panstarrs correction (str): full search_pos (astropy.SkyCoord): 12.295° 5.38° (icrs, 2011-12-16T21:11:06.224) band (str): g size (astropy.Quantity): 120.0″ epoch (astropy.Time): 2011-12-16T21:11:06.224 hdu (astropy.ImageHDU): wcs (astropy.WCS): Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store() .. GENERATED FROM PYTHON SOURCE LINES 29-49 | Just like the `Vizier `_ :func:`~ATK.Tools.query` from the previous tutorial, this returns a :class:`~ATK.Models.DataSet`. In this case, the :class:`~ATK.Models.DataSet`'s :attr:`~ATK.Models.DataSet.data` attribute is a list of :class:`~ATK.Models.Image` objects (**one per target, subject to data availability**). | .. note:: ATK supports queries to the following imaging surveys and bands: .. include:: supported_image_surveys.rst For a refresher on :func:`~ATK.Tools.query` fundamentals, see :doc:`previous tutorials <../getting_started/data_query>`. | | Plotting the Returned Data ========================== Unlike the :class:`~ATK.Models.Record` from the previous tutorial, the returned :class:`~ATK.Models.Image` is plottable. The :class:`~ATK.Models.DataSet`'s :meth:`~ATK.Models.DataSet.plot` method can therefore be used to generate a Bokeh :class:`~bokeh.plotting.figure`: .. GENERATED FROM PYTHON SOURCE LINES 49-52 .. code-block:: Python ps_query.plot() .. GENERATED FROM PYTHON SOURCE LINES 56-59 | The generated figure is stored in the :attr:`~ATK.Models.DataSet.figure` attribute of the :class:`~ATK.Models.DataSet`: .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python ps_query.show() .. rst-class:: sphx-glr-script-out .. code-block:: none .kind: Image .targets: 2552928187080872832 | 12.297° 5.377° (icrs, 2016-01-01T00:00:00.000) .exception: False .data: survey: panstarrs correction: full search_pos: 12.295° 5.38° (icrs, 2011-12-16T21:11:06.224) band: g size: 120.0″ epoch: 2011-12-16T21:11:06.224 hdu: wcs: .figure: Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store() .. GENERATED FROM PYTHON SOURCE LINES 66-72 | | Viewing a Figure ================ A :class:`~ATK.Models.DataSet`'s :meth:`~ATK.Models.DataSet.open` method can be used to open the stored figure in the default browser: .. GENERATED FROM PYTHON SOURCE LINES 73-76 .. code-block:: Python ps_query.open() .. raw:: html
Bokeh Figure


.. GENERATED FROM PYTHON SOURCE LINES 85-117 Since a Gaia source ID was used for targeting, proper motion correction has been used to automatically centre the image on the target star. | .. note:: If a figure has not yet been generated when :meth:`~ATK.Models.DataSet.open` is called, :meth:`~ATK.Models.DataSet.plot` is called automatically. | | Saving Figures to Local Files ============================= To save a figure as a local HTML file, :meth:`~ATK.Models.DataSet.open` can be provided with a ``path``: .. code-block:: python ps_query.open("example_image.html") | .. warning:: If :meth:`~ATK.Models.DataSet.open` is not provided with a ``path``, the figure will be temporarily saved to the ``~/.AstroToolkit/cached_figures`` directory (i.e. inside the home directory). By default, cached figures that are over an hour old will be removed the next time :meth:`~ATK.Models.DataSet.open` is called. The duration for which figures are cached can be changed in the :doc:`config <../configuration/config>`. | Alternatively, the figure can be saved to local files without opening it by using the :class:`~ATK.Models.DataSet`'s :meth:`~ATK.Models.DataSet.save` method: .. code-block:: python ps_query.save("example_image.html") .. GENERATED FROM PYTHON SOURCE LINES 119-124 | | | .. rubric:: Download this Tutorial .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.294 seconds) .. _sphx_glr_download_auto_tutorials_images_image_query.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: image_query.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: image_query.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: image_query.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_