Skip to content

Commit fe5db1c

Browse files
jkrickbsipocz
authored andcommitted
moving this to the correct location
1 parent 91e9f38 commit fe5db1c

1 file changed

Lines changed: 112 additions & 87 deletions

File tree

tutorials/wise/sia_allwise_atlas.md

Lines changed: 112 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.16.2
7+
jupytext_version: 1.19.1
88
kernelspec:
9-
display_name: Python 3 (ipykernel)
10-
language: python
119
name: python3
10+
display_name: python3
11+
language: python
1212
authors:
13-
- name: David Shupe
14-
- name: IRSA Science Team
13+
- name: IRSA Data Science Team
14+
- name: Troy Raen
15+
- name: Brigitta Sipőcz
16+
- name: Jessica Krick
17+
- name: Andreas Faisst
18+
- name: Jaladh Singhal
19+
- name: Vandana Desai
20+
- name: Dave Shupe
1521
---
1622

17-
# Searching for AllWISE Atlas Images
18-
19-
+++
20-
21-
This notebook tutorial demonstrates the process of querying IRSA's Simple Image Access (SIA) service for AllWISE Atlas images, making a cutout image (thumbnail), and displaying the cutout.
23+
# Searching for AllWISE Images with SIA v2
2224

2325
+++
2426

25-
26-
2727
## Learning Goals
2828

2929
By the end of this tutorial, you will:
3030

31-
* Learn how to search the NASA Astronomical Virtual Observatory Directory web portal for a service that provides access to IRSA's WISE AllWISE Atlas (L3a) coadded images.
32-
* Use the Python pyvo package to identify which of IRSA's AllWISE Atlas images cover a specified coordinate.
33-
* Download one of the identified images.
31+
* Learn how to access IRSA's WISE AllWISE Atlas (L3a) coadded images via the Simple Image Access (SIA) service.
32+
* identify which of IRSA's AllWISE Atlas images cover a specified coordinate.
33+
* Visualize one of the identified images using Forefly.
3434
* Create and display a cutout of the downloaded image.
3535

3636
+++
@@ -41,51 +41,49 @@ The AllWISE program builds upon the work of the successful Wide-field Infrared S
4141

4242
https://irsa.ipac.caltech.edu/Missions/wise.html
4343

44-
The [NASA/IPAC Infrared Science Archive (IRSA)](https://irsa.ipac.caltech.edu) at Caltech is the archive for AllWISE images and catalogs. The AllWISE Atlas images that are the subject of this tutorial are made accessible via the [International Virtual Observatory Alliance (IVOA)](https://ivoa.net) [Simple Image Access (SIA)](https://wiki.ivoa.net/internal/IVOA/SiaInterface/SIA-V2-Analysis.pdf) protocol. IRSA's AllWISE SIA service is registered in the NASA Astronomical Virtual Observatory (NAVO) [Directory](https://vao.stsci.edu). Based on the registered information, the Python package [pyvo](https://pyvo.readthedocs.io) can be used to query the SEIP SIA service for a list of images that meet specified criteria, and standard Python libraries can be used to download and manipulate the images.
45-
Other datasets at IRSA are available through other SIA services:
44+
The [NASA/IPAC Infrared Science Archive (IRSA)](https://irsa.ipac.caltech.edu) at Caltech is the archive for AllWISE images and catalogs. The AllWISE Atlas images that are the subject of this tutorial are made accessible via the [International Virtual Observatory Alliance (IVOA)](https://ivoa.net) [Simple Image Access (SIA)](https://www.ivoa.net/documents/SIA/) protocol.
4645

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

47+
```{note}
48+
IRSA supports both SIA v1 and SIA v2 protocols. The version used depends on the specific dataset. This IRSA [website](https://irsa.ipac.caltech.edu/ibe/sia.html) provides information on which version each service uses and how to access them. Further information on how to access IRSA data with different techniques is available [here](https://irsa.ipac.caltech.edu/docs/program_interface/api_images.html). This tutorial uses SIA v2 for AllWISE Atlas images.
49+
```
4950

5051
+++
5152

5253
## Imports
53-
54-
- `pyvo` for querying IRSA's AllWISE Atlas SIA service
54+
- `numpy` for working with tables
5555
- `astropy.coordinates` for defining coordinates
5656
- `astropy.nddata` for creating an image cutout
5757
- `astropy.wcs` for interpreting the World Coordinate System header keywords of a fits file
5858
- `astropy.units` for attaching units to numbers passed to the SIA service
5959
- `matplotlib.pyplot` for plotting
60-
- `astropy.utils.data` for downloading files
6160
- `astropy.io` to manipulate FITS files
61+
- `firefly_client` for visuzlizing images
62+
- `astroquery.ipac.irsa` for IRSA data access
63+
- `astropy.visualization` for color stretch display
6264

6365
```{code-cell} ipython3
6466
# Uncomment the next line to install dependencies if needed.
65-
# !pip install matplotlib astropy pyvo
67+
%pip install matplotlib astropy jupyter_firefly_extensions
6668
```
6769

6870
```{code-cell} ipython3
69-
import pyvo as vo
71+
import numpy as np
7072
from astropy.coordinates import SkyCoord
7173
from astropy.nddata import Cutout2D
7274
from astropy.wcs import WCS
7375
import astropy.units as u
7476
import matplotlib.pyplot as plt
75-
from astropy.utils.data import download_file
7677
from astropy.io import fits
78+
from firefly_client import FireflyClient
79+
from astroquery.ipac.irsa import Irsa
80+
from astropy.visualization import simple_norm
7781
```
7882

79-
## Section 1 - Setup
83+
## 1. Define the target
8084

8185
+++
8286

83-
Set images to display in the notebook
84-
85-
```{code-cell} ipython3
86-
%matplotlib inline
87-
```
88-
8987
Define coordinates of a bright star
9088

9189
```{code-cell} ipython3
@@ -94,119 +92,146 @@ dec = 77.595559
9492
pos = SkyCoord(ra=ra, dec=dec, unit='deg')
9593
```
9694

97-
## Section 2 - Lookup and define a service for AllWISE Atlas images
95+
## 2. Discover AllWISE Atlas images
9896

9997
+++
10098

101-
Start at STScI VAO Registry at https://vao.stsci.edu/keyword-search/
102-
103-
Limit by Publisher "NASA/IPAC Infrared Science Archive" and Capability Type "Simple Image Access Protocol" then search on "AllWISE Atlas"
104-
105-
Locate the SIA2 URL https://irsa.ipac.caltech.edu/ibe/sia/wise/allwise/p3am_cdd?
99+
IRSA provides Simple Image Access (SIA) services for various datasets. A list of available datasets and their access URLs can be found [here](https://irsa.ipac.caltech.edu/ibe/sia.html).
100+
This tutorial uses SIA v2 for AllWISE Atlas images.
101+
To search for other datasets on SIA v2, try changing the filter string.
102+
Or remove the filter keyword altogether to get a full list of available SIA v2 datasets at IRSA.
106103

107104
```{code-cell} ipython3
108-
allwise_service = vo.dal.SIAService("https://irsa.ipac.caltech.edu/ibe/sia/wise/allwise/p3am_cdd?")
109-
```
110-
111-
## Section 3 - Search the service
105+
#first we need to know the name of the dataset on the IRSA system
106+
names = Irsa.list_collections(filter="allwise")
107+
names
112108
113-
+++
109+
# We see from the resulting table that the dataset collection we are interested in is called "wise_allwise"
110+
```
114111

115-
Search for images covering within 1 arcsecond of the star
112+
## 3. Search for images
113+
Which images in the IRSA allwise dataset include our target of interest?
116114

117115
```{code-cell} ipython3
118-
im_table = allwise_service.search(pos=pos, size=1.0*u.arcsec)
116+
#get a table of all images within 1 arcsecond of our target position
117+
dataset_name = names['collection'][0] #name of our favorite dataset = "wise_allwise"
118+
im_table = Irsa.query_sia(pos=(pos, 1 * u.arcsec), collection=dataset_name)
119119
```
120120

121-
Inspect the table that is returned
122-
123121
```{code-cell} ipython3
122+
# Inspect the table that is returned
124123
im_table
125124
```
126125

127126
```{code-cell} ipython3
128-
im_table.to_table().colnames
127+
# Look at a list of the column names included in this table
128+
im_table.colnames
129129
```
130130

131131
```{code-cell} ipython3
132-
im_table.to_table()['sia_bp_id']
132+
# Let's look at the unique values in one of the columns
133+
print(np.unique(im_table['energy_bandpassname']))
133134
```
134135

135-
## Section 4 - Locate and download an image of interest
136+
## 4.Locate and visualize an image of interest
136137

137-
+++
138-
139-
Let's search the image results for the W3 band image.
138+
We start by filtering the image results for the W3 band images.
139+
Then look at the header of one of the resulting W3 band images of our target star.
140+
Finally, we create an interactive FITS display of the W3 image(s) by [using Firefly](https://caltech-ipac.github.io/firefly_client/index.html), an open-source interactive visualization tool for astronomical data.
141+
To understand how to open the Firefly viewer in a new tab from your Python notebook, refer to [this documentation](https://caltech-ipac.github.io/firefly_client/usage/initializing-vanilla.html) on how to initialize FireflyClient.```
140142

141143
```{code-cell} ipython3
142-
for i in range(len(im_table)):
143-
if im_table[i]['sia_bp_id'] == 'W3':
144-
break
145-
print(im_table[i].getdataurl())
144+
# You can put the URL from the column "access_url" into a browser to download the file.
145+
# Or you can work with it in Python, as shown below.
146+
w3_mask = im_table['energy_bandpassname'] == 'W3'
147+
w3_table = im_table[w3_mask]
146148
```
147149

148-
Download the image and open it in Astropy
149-
150150
```{code-cell} ipython3
151-
fname = download_file(im_table[i].getdataurl(), cache=True)
152-
image1 = fits.open(fname)
153-
```
154-
155-
## Section 5 - Extract a cutout and plot it
151+
# Lets look at the access_url of the first one:
152+
image_url = w3_table['access_url'][0]
153+
image_url
156154
157-
```{code-cell} ipython3
158-
wcs = WCS(image1[0].header)
155+
# Use Astropy to examine the header of the URL from the previous step,
156+
# and grab the data and wcs from the header.
157+
with fits.open(image_url, memmap=False) as hdul:
158+
hdul.info()
159+
data = hdul[0].data
160+
wcs = WCS(hdul[0].header)
159161
```
160162

161163
```{code-cell} ipython3
162-
cutout = Cutout2D(image1[0].data, pos, (60, 60), wcs=wcs)
163-
wcs = cutout.wcs
164-
```
164+
# Uncomment when opening a Firefly viewer in a tab within Jupyter Lab with jupyter_firefly_extensions installed
165+
# fc = FireflyClient.make_lab_client()
165166
166-
```{code-cell} ipython3
167-
fig = plt.figure()
167+
# Uncomment when opening Firefly viewer in contexts other than the above
168+
fc = FireflyClient.make_client(url="https://irsa.ipac.caltech.edu/irsaviewer")
168169
169-
ax = fig.add_subplot(1, 1, 1, projection=wcs)
170-
ax.imshow(cutout.data, cmap='gray_r', origin='lower',
171-
vmax = 1000)
172-
ax.scatter(ra, dec, transform=ax.get_transform('fk5'), s=500, edgecolor='red', facecolor='none')
170+
# Visualize an image by sending its URL to the viewer.
171+
fc.show_fits_image(file_input=image_url,
172+
plot_id="image",
173+
Title="Image"
174+
)
175+
176+
#Try use the interactive tools in the viewer to explore the data.
173177
```
174178

179+
## 5. Extract a cutout and plot it
180+
If you want to see just a cutout of a certain region around the target, we do that below using astropy's Cutout2D.
181+
175182
```{code-cell} ipython3
183+
# make 1' x 1' cutout
184+
cutout = Cutout2D(data, position=pos, size=1 * u.arcmin, wcs=wcs)
176185
186+
#add quick normalization/stretch
187+
norm = simple_norm(cutout.data, stretch="sqrt", percent=99)
188+
189+
# display
190+
plt.imshow(cutout.data, origin='lower', norm = norm)
191+
plt.colorbar(label="Image value")
192+
plt.title("ALLWISE W3 (quicklook)")
193+
plt.xlabel("Pixel X")
194+
plt.ylabel("Pixel Y")
177195
```
178196

179197
***
180198

181199
+++
182200

183-
## About this notebook
201+
## Acknowledgements
202+
203+
- [Caltech/IPAC-IRSA](https://irsa.ipac.caltech.edu/)
184204

185205
+++
186206

187-
**Updated:** 2022-02-14
188207

189-
**Contact:** [the IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or reporting problems.
208+
## About this notebook
190209

210+
**Updated:** 2 March 2026
191211

192-
+++
212+
**Contact:** [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or problems.
193213

194-
## Citations
214+
**Runtime:** As of the date above, this notebook takes about 20 seconds to run to completion on a machine with 8GB RAM and 4 CPU.
215+
This runtime is dependent on archive servers which means runtime will vary for users.
195216

196217
+++
197218

198-
If you use `astropy` for published research, please cite the authors. Follow these links for more information about citing `astropy`:
199-
200-
* [Citing `astropy`](https://www.astropy.org/acknowledging.html)
201-
202-
+++
219+
## Citations
203220

204-
Please include the following in any published material that makes use of the WISE data products:
221+
**Astropy:**
222+
To see the Bibtex references for this, uncomment the below cell
205223

206-
"This publication makes use of data products from the Wide-field Infrared Survey Explorer, which is a joint project of the University of California, Los Angeles, and the Jet Propulsion Laboratory/California Institute of Technology, funded by the National Aeronautics and Space Administration."
224+
**Astroquery:**
225+
To see the Bibtex references for this, uncomment the below cell
207226

208-
Please also cite the dataset Digital Object Identifier (DOI): [10.26131/IRSA153](https://www.ipac.caltech.edu/doi/irsa/10.26131/IRSA153)
227+
**WISE:**
228+
This publication makes use of data products from the Wide-field Infrared Survey Explorer, which is a joint project of the University of California, Los Angeles, and the Jet Propulsion Laboratory/California Institute of Technology, funded by the National Aeronautics and Space Administration."
229+
Digital Object Identifier (DOI): [10.26131/IRSA153](https://www.ipac.caltech.edu/doi/irsa/10.26131/IRSA153)
209230

210231
```{code-cell} ipython3
232+
#import astropy
233+
#import astroquery
211234
235+
#astropy.__citation__
236+
#astroquery.__citation__
212237
```

0 commit comments

Comments
 (0)