Skip to article frontmatterSkip to article content
IRSA Tutorials

Searching for contributed COSMOS images

This notebook tutorial demonstrates the process of querying IRSA’s Simple Image Access (SIA) service for the COSMOS images, making a cutout image (thumbnail), and displaying the cutout.

Learning Goals

By the end of this tutorial, you will:

Introduction

The COSMOS Archive serves data taken for the Cosmic Evolution Survey with HST (COSMOS) project, using IRSA’s general search service, Atlas. COSMOS is an HST Treasury Project to survey a 2 square degree equatorial field with the ACS camera. For more information about COSMOS, see:

https://irsa.ipac.caltech.edu/Missions/cosmos.html

The NASA/IPAC Infrared Science Archive (IRSA) at Caltech is one of the archives for COSMOS images and catalogs. The COSMOS images that are the subject of this tutorial are made accessible via the International Virtual Observatory Alliance (IVOA) Simple Image Access (SIA) protocol. IRSA’s SEIP SIA service is registered in the NASA Astronomical Virtual Observatory (NAVO) Directory. Based on the registered information, the Python package pyvo can be used to query the SIA service for a list of images that meet specified criteria, and standard Python libraries can be used to download and manipulate the images. Other datasets at IRSA are available through other SIA services:

https://irsa.ipac.caltech.edu/docs/program_interface/api_images.html

Imports

# Uncomment the next line to install dependencies if needed.
# !pip install matplotlib astropy pyvo
import pyvo as vo
from astropy.coordinates import SkyCoord
from astropy.nddata import Cutout2D
from astropy.wcs import WCS
import astropy.units as u
import matplotlib.pyplot as plt
from astropy.utils.data import download_file
from astropy.io import fits

Section 1 - Setup

Set images to display in the notebook

%matplotlib inline

Define coordinates of a bright source

ra = 149.99986
dec = 2.24875
pos = SkyCoord(ra=ra, dec=dec, unit='deg')

Section 2 - Lookup and define a service for COSMOS images

Start at STScI VAO Registry at https://vao.stsci.edu/keyword-search/

Limit by Publisher “NASA/IPAC Infrared Science Archive” and Capability Type “Simple Image Access Protocol” then search on “COSMOS”

Locate the SIA2 URL https://irsa.ipac.caltech.edu/cgi-bin/Atlas/nph-atlas?mission=COSMOS&hdr_location=\COSMOSDataPath\&collection_desc=Cosmic+Evolution+Survey+with+HST+(COSMOS)&SIAP_ACTIVE=1&

cosmos_service = vo.dal.SIAService("https://irsa.ipac.caltech.edu/cgi-bin/Atlas/nph-atlas?mission=COSMOS&hdr_location=%5CCOSMOSDataPath%5C&collection_desc=Cosmic+Evolution+Survey+with+HST+%28COSMOS%29&SIAP_ACTIVE=1&")

Section 3 - Search the service

Search for images covering within 1 arcsecond of the star

im_table = cosmos_service.search(pos=pos, size=1.0*u.arcsec)

Inspect the table of images that is returned

im_table
<DALResultsTable length=279> ra ... deg ... float64 ... ------- ... 150.014 ... 150.022 ... 150.014 ... 150.022 ... 149.977 ... 149.977 ... 150.061 ... 150.061 ... 150.116 ... ... ... 150.061 ... 150.061 ... 150.061 ... 150.061 ... 150.061 ... 150.061 ... 150.061 ... 150.061 ... 149.995 ...
im_table.to_table().colnames
['ra', 'dec', 'cra', 'cdec', 'naxis1', 'naxis2', 'ctype1', 'ctype2', 'crval1', 'crval2', 'crpix1', 'crpix2', 'cdelt1', 'cdelt2', 'crota2', 'ra1', 'dec1', 'ra2', 'dec2', 'ra3', 'dec3', 'ra4', 'dec4', 'equinox', 'hdu', 'facility_name', 'instrument_name', 'dataproduct_type', 'file_type', 'band_name', 'wavelength', 'access_estsize', 's_fov', 'tile', 'fname', 'dataset', 'cutout', 'sia_desc', 'sia_naxes', 'sia_naxis', 'sia_scale', 'sia_cdmatrix', 'sia_format', 'sia_url']

View the first ten entries of the table

im_table.to_table()[:10]
Loading...

Section 4 - Locate and download an image of interest

Locate the first image in the band_name of i+

for i in range(len(im_table)):
    if im_table[i]['band_name'] == 'i+':
        break
print(im_table[i].getdataurl())
https://irsa.ipac.caltech.edu:443/data/COSMOS/images/subaru/best_psf/ip/subaru_ip_best-psf_066_rms_20.fits

Download the image

fname = download_file(im_table[i].getdataurl(), cache=True)
image1 = fits.open(fname)

Section 5 - Extract a cutout and plot it

wcs = WCS(image1[0].header)

Make a cutout centered on the position

cutout = Cutout2D(image1[0].data, pos, (60, 60), wcs=wcs)
wcs = cutout.wcs
fig = plt.figure()

ax = fig.add_subplot(1, 1, 1, projection=wcs)
ax.imshow(cutout.data, cmap='gray_r', origin='lower')
ax.scatter(ra, dec, transform=ax.get_transform('fk5'), s=500, edgecolor='red', facecolor='none')
<Figure size 640x480 with 1 Axes>

About this notebook

Author: David Shupe, IRSA Scientist, and the IRSA Science Team

Updated: 2022-02-14

Contact: the IRSA Helpdesk with questions or reporting problems.

Citations

If you use astropy for published research, please cite the authors. Follow these links for more information about citing astropy:

If you use COSMOS ACS imaging data in published research, please cite the dataset Digital Object Identifier (DOI): COSMOS Project (2020).

References
  1. COSMOS Project. (2020). Cosmic Evolution Survey with HST (COSMOS). IPAC. 10.26131/IRSA178