Working with Images#

Performing an Image Query#

To fetch an image, set the 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:

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)
<Image DataSet>

.kind (str):        Image
.targets (list):    2552928187080872832 | 12.297° 5.377° (icrs, 2016-01-01T00:00:00.000)
.exception (bool):  False
.data (list):
          <panstarrs g-band Image>
                    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):        <ImageHDU>
                    wcs (astropy.WCS):             <WCS>


Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store()

Just like the Vizier query() from the previous tutorial, this returns a DataSet. In this case, the DataSet’s data attribute is a list of Image objects (one per target, subject to data availability).


Note

ATK supports queries to the following imaging surveys and bands:

  • Pan-STARRS - panstarrs (g, r, i, z, y)

  • SkyMapper - skymapper (g, r, i, z, u, v)

  • DSS1 - dss1 (blue, red)

  • DSS2 - dss2 (blue, red, ir)

  • WISE - wise (w1, w2, w3, w4)

  • 2MASS - 2mass (j, h, k)

  • SDSS - sdss (u, g, r, i, z)

For a refresher on query() fundamentals, see previous tutorials.



Plotting the Returned Data#

Unlike the Record from the previous tutorial, the returned Image is plottable. The DataSet’s plot() method can therefore be used to generate a Bokeh figure:

ps_query.plot()

The generated figure is stored in the figure attribute of the DataSet:

ps_query.show()
<Image DataSet>

.kind:      Image
.targets:   2552928187080872832 | 12.297° 5.377° (icrs, 2016-01-01T00:00:00.000)
.exception: False
.data:
      <panstarrs g-band Image>
            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:        <ImageHDU>
            wcs:        <WCS>

.figure:    <Bokeh Figure>

Available Methods: .add(), .apply(), .from_target(), .merge(), .open(), .plot(), .save(), .show(), .split(), .store()


Viewing a Figure#

A DataSet’s open() method can be used to open the stored figure in the default browser:

ps_query.open()
Bokeh Figure


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 open() is called, plot() is called automatically.



Saving Figures to Local Files#

To save a figure as a local HTML file, open() can be provided with a path:

ps_query.open("example_image.html")

Warning

If 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 open() is called. The duration for which figures are cached can be changed in the config.


Alternatively, the figure can be saved to local files without opening it by using the DataSet’s save() method:

ps_query.save("example_image.html")



Download this Tutorial

Total running time of the script: (0 minutes 0.294 seconds)

Gallery generated by Sphinx-Gallery