Skip to content

Commit 9b4f7eb

Browse files
committed
DOC: adding docs and plot for Irsa.query_sia()
1 parent e98f27d commit 9b4f7eb

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

docs/ipac/irsa/irsa.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,62 @@ returned as a `~pyvo.dal.TAPResults` object. Its ``to_table`` or ``to_qtable`` m
220220
202.809023 46.964558 15.874 0.081 ... 15.322 0.188 AAC 000
221221

222222

223+
Simple image access queries
224+
---------------------------
225+
226+
`~astroquery.ipac.irsa.query_sia` provides a way to access IRSA's Simple
227+
Image Access VO service. In the following example we are looking for Spitzer
228+
Enhanced Imaging products in the centre of the COSMOS field as an `~astropy.table.Table`.
229+
230+
.. doctest-remote-data::
231+
232+
>>> from astroquery.ipac.irsa import Irsa
233+
>>> from astropy.coordinates import SkyCoord
234+
>>> from astropy import units as u
235+
>>>
236+
>>> coord = SkyCoord('150.01d 2.2d', frame='icrs')
237+
>>> spitzer_images = Irsa.query_sia(pos=(coord, 1 * u.arcmin), collection='spitzer_seip').to_table()
238+
239+
Now open a cutout image for one of the science images. You could either use
240+
the the IRSA on-premise data or the cloud version of it using the
241+
``access_url`` or ``cloud_access`` columns:
242+
243+
.. doctest-remote-data::
244+
245+
>>> from astropy.io import fits
246+
>>> from astropy.nddata import Cutout2D
247+
>>> from astropy.wcs import WCS
248+
>>> science_image = spitzer_images[spitzer_images['dataproduct_subtype'] == 'science'][0]
249+
>>> with fits.open(science_image['access_url'], use_fsspec=True) as hdul:
250+
... cutout = Cutout2D(hdul[0].section, position=coord, size=2 * u.arcmin, wcs=WCS(hdul[0].header))
251+
252+
Now plot the cutout.
253+
254+
.. doctest-skip::
255+
256+
>>> import matplotlib.pyplot as plt
257+
>>> plt.imshow(cutout.data, cmap='grey')
258+
>>> plt.show()
259+
260+
.. plot::
261+
262+
from astroquery.ipac.irsa import Irsa
263+
from astropy.coordinates import SkyCoord
264+
from astropy import units as u
265+
from astropy.io import fits
266+
from astropy.nddata import Cutout2D
267+
from astropy.wcs import WCS
268+
import matplotlib.pyplot as plt
269+
coord = SkyCoord('150.01d 2.2d', frame='icrs')
270+
spitzer_images = Irsa.query_sia(pos=(coord, 1 * u.arcmin), collection='spitzer_seip').to_table()
271+
science_image = spitzer_images[spitzer_images['dataproduct_subtype'] == 'science'][0]
272+
with fits.open(science_image['access_url'], use_fsspec=True) as hdul:
273+
cutout = Cutout2D(hdul[0].section, position=coord, size=2 *
274+
u.arcmin, wcs=WCS(hdul[0].header))
275+
plt.imshow(cutout.data, cmap='grey')
276+
plt.show()
277+
278+
223279
Other Configurations
224280
--------------------
225281

0 commit comments

Comments
 (0)