Skip to content

Commit 03f995b

Browse files
authored
Merge pull request #153 from Caltech-IPAC/raen/IRSA-7323/spherex-qr2
2 parents 7effa95 + 41212e5 commit 03f995b

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

tutorials/spherex/spherex_cutouts.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The following packages must be installed to run this notebook.
4444
```
4545

4646
```{code-cell} ipython3
47-
import concurrent
47+
import concurrent.futures
4848
import time
4949
5050
import astropy.units as u
@@ -101,11 +101,11 @@ service = pyvo.dal.TAPService("https://irsa.ipac.caltech.edu/TAP")
101101
# Sort by observation time.
102102
query = f"""
103103
SELECT
104-
'https://irsa.ipac.caltech.edu/' || a.uri || '?center={ra.to(u.degree).value},{dec.to(u.degree).value}d&size={size.to(u.degree).value}' AS uri,
104+
'https://irsa.ipac.caltech.edu/' || a.uri || '?center={ra.value},{dec.value}d&size={size.value}' AS uri,
105105
p.time_bounds_lower
106106
FROM spherex.artifact a
107107
JOIN spherex.plane p ON a.planeid = p.planeid
108-
WHERE 1 = CONTAINS(POINT('ICRS', {ra.to(u.degree).value}, {dec.to(u.degree).value}), p.poly)
108+
WHERE 1 = CONTAINS(POINT('ICRS', {ra.value}, {dec.value}), p.poly)
109109
AND p.energy_bandpassname = '{bandpass}'
110110
ORDER BY p.time_bounds_lower
111111
"""
@@ -117,6 +117,11 @@ print("Time to do TAP query: {:2.2f} seconds.".format(time.time() - t1))
117117
print("Number of images found: {}".format(len(results)))
118118
```
119119

120+
:::{note}
121+
SPHEREx data are also available via SIA which can provide a simpler interface for many queries, as demonstrated in {ref}`spherex-intro`.
122+
An advantage of the method shown above is that it provides access to data immediately after ingestion (which occurs weekly) and is not subject to the same ~1 day delay as SIA.
123+
:::
124+
120125
## 6. Define a function that processes a list of SPHEREx Spectral Image Cutouts
121126

122127
This function takes in a row of the catalog that we created above and does the following:
@@ -158,7 +163,7 @@ def process_cutout(row, ra, dec, cache):
158163
# Compute wavelength at cutout position.
159164
spectral_wcs = WCS(header, fobj=hdulist, key="W")
160165
spectral_wcs.sip = None
161-
wavelength, bandpass = spectral_wcs.pixel_to_world(x, y)
166+
wavelength, bandwidth = spectral_wcs.pixel_to_world(x, y)
162167
row["central_wavelength"] = wavelength.to(u.micrometer).value
163168
164169
# Collect the HDUs for this cutout and append the row's cutout_index to the EXTNAME.
@@ -327,7 +332,7 @@ plt.show()
327332

328333
**Authors:** IRSA Data Science Team, including Vandana Desai, Andreas Faisst, Troy Raen, Brigitta Sipőcz, Jessica Krick, Shoubaneh Hemmati
329334

330-
**Updated:** 2025-09-30
335+
**Updated:** 24 October 2025
331336

332337
**Contact:** [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or problems.
333338

tutorials/spherex/spherex_intro.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ More information is available in the [SPHEREx Explanatory Supplement](https://ir
4141
+++
4242

4343
## 3. Requirements
44-
The following packages must be installed to run this notebook. Comment out the following lines if they are already installed.
44+
The following packages must be installed to run this notebook.
4545

4646
```{code-cell} ipython3
47-
# pip install numpy matplotlib astropy astroquery firefly-client
47+
# Uncomment the next line to install dependencies if needed.
48+
# %pip install numpy matplotlib astropy astroquery firefly-client
4849
```
4950

5051
## 4. Imports
@@ -91,16 +92,22 @@ The IRSA SIA collections can be listed using using the ``list_collections`` meth
9192
+++
9293

9394
The collections are documented at [SPHEREx Data Access: Application Program Interfaces (APIs)](https://caltech-ipac.github.io/spherex-archive-documentation/spherex-data-access#application-program-interfaces-apis)
94-
There are currently three collections available:
95+
There are currently three collections available for the second Quick Release:
9596

96-
* `'spherex_qr'` -- Quick Release Spectral Image MEFs that are part of the SPHEREx **Wide Survey**
97-
* `'spherex_qr_cal'` -- Quick Release **Calibration files**
98-
* `'spherex_qr_deep'` -- Quick Release Spectral Image MEFs that are part of the SPHEREx **Deep Survey**
97+
* `'spherex_qr2'` -- Quick Release 2 Spectral Image MEFs that are part of the SPHEREx **Wide Survey**
98+
* `'spherex_qr2_cal'` -- Quick Release 2 **Calibration files**
99+
* `'spherex_qr2_deep'` -- Quick Release 2 Spectral Image MEFs that are part of the SPHEREx **Deep Survey**
99100

100101
```{code-cell} ipython3
101-
results = Irsa.query_sia(pos=(coord, search_radius), collection='spherex_qr')
102+
results = Irsa.query_sia(pos=(coord, search_radius), collection='spherex_qr2')
102103
```
103104

105+
:::{note}
106+
SPHEREx data are ingested on a weekly basis.
107+
Due to the nature of the ingestion process, availability via SIA will lag on the order of a day.
108+
To avoid this delay, users can access data through the browsable directories or the SPHEREx Data Explorer GUI (see [SPHEREx Data Access](https://caltech-ipac.github.io/spherex-archive-documentation/spherex-data-access)), or do a TAP query as shown in {ref}`spherex-cutouts`.
109+
:::
110+
104111
Each row of the results of your query represents a different spectral image.
105112
Because SPHEREx data will be released on a weekly basis, the number of rows returned will change
106113
depending on when you submit the query.
@@ -168,7 +175,7 @@ fc.reinit_viewer()
168175
Visualize a spectral image MEF by sending its URL to the viewer.
169176

170177
```{code-cell} ipython3
171-
fc.show_fits(url=spectral_image_url,
178+
fc.show_fits_image(file_input=spectral_image_url,
172179
plot_id="spectral_image",
173180
Title="Spectral Image"
174181
)
@@ -219,7 +226,7 @@ The main WCS describes the astrometric registration of the image, including opti
219226

220227
There are two alternative WCS systems:
221228
- WCSNAMEA describes zero-based pixel coordinates.
222-
- WCSNAMEW describes spectral coordinates 'Wavelength' and 'Bandpass'. This WCS contains a reference to the lookup table in the 'WCS-WAVE' extension.
229+
- WCSNAMEW describes spectral coordinates 'Wavelength' and 'Bandwidth'. This WCS contains a reference to the lookup table in the 'WCS-WAVE' extension.
223230

224231
+++
225232

@@ -260,7 +267,7 @@ Note: The previous line triggers an Astropy INFO printout,
260267
which implies that the SIP distortion coefficients from the main WCS are preserved in the alternative WCS.
261268
This is because the SIP convention, not formally part of the FITS standard,
262269
is ambiguous as to whether it is meant to apply to 'alternative' (lettered) WCSes in addition to the primary WCS.
263-
See [astropy/astropy#13105](https://github.com/astropy/astropy/issues/13105).)
270+
See [astropy/astropy#13105](https://github.com/astropy/astropy/issues/13105).
264271

265272
The wavelength per pixel is a property of the detector-filter combination and is independent of optical distortion in the telescope,
266273
and is modeled accordingly in WCS 'W', so we turn the SIP distortion off for this WCS.
@@ -272,9 +279,9 @@ spectral_wcs.sip = None
272279

273280
```{code-cell} ipython3
274281
# The standard Astropy methods for converting pixel coordinates to world coordinates can also be used to obtain spectral coordinates.
275-
# Take the pixel coordinates that we determined for the image center and resolve them to the wavelength and bandpass for that pixel
276-
wl, bp = spectral_wcs.pixel_to_world(x, y)
277-
wl, bp
282+
# Take the pixel coordinates that we determined for the image center and resolve them to the wavelength and bandwidth for that pixel
283+
wl, bw = spectral_wcs.pixel_to_world(x, y)
284+
wl, bw
278285
```
279286

280287
### 8c. How does wavelength vary across the detector?
@@ -290,10 +297,10 @@ spectral_image_data = spectral_image.data
290297
# Use the spectral WCS to convert these pixel coordinates to spectral coordinates.
291298
spectral_coords = spectral_wcs.pixel_to_world(x, y)
292299
293-
# Break out the two spectral coordinates (wavelength and bandpass) from the spectral coordinates, and print the results.
294-
wavelength, bandpass = spectral_coords
300+
# Break out the two spectral coordinates (wavelength and bandwidth) from the spectral coordinates, and print the results.
301+
wavelength, bandwidth = spectral_coords
295302
print("Wavelength: \n", wavelength)
296-
print("Bandpass: \n", bandpass)
303+
print("Bandwidth: \n", bandwidth)
297304
```
298305

299306
```{code-cell} ipython3
@@ -436,6 +443,6 @@ Andreas Faisst, Shoubaneh Hemmati, Vandana Desai
436443
**Contact:** [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions
437444
or problems.
438445

439-
**Updated:** June 2025
446+
**Updated:** 24 October 2025
440447

441448
**Runtime:** approximately 30 seconds

tutorials/spherex/spherex_psf.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Both should be defined using `astropy` units.
7070
The goal is to obtain the cutout and then extract the PSF corresponding to the coordinates of interest.
7171

7272
```{tip}
73-
To learn more about how to access SPHEREx spectral images and how to download cutouts, we refer to the [SPHEREx Intro Tutorial](spherex-intro) and the [SPHEREx Cutouts Tutorial](spherex-cutouts).
73+
To learn more about how to access SPHEREx spectral images and how to download cutouts, we refer to the [SPHEREx Intro Tutorial](#spherex-intro) and the [SPHEREx Cutouts Tutorial](#spherex-cutouts).
7474
```
7575

7676
```{code-cell} ipython3
@@ -92,11 +92,11 @@ service = pyvo.dal.TAPService("https://irsa.ipac.caltech.edu/TAP")
9292
# Sort by observation time.
9393
query = f"""
9494
SELECT
95-
'https://irsa.ipac.caltech.edu/' || a.uri || '?center={ra.to(u.degree).value},{dec.to(u.degree).value}d&size={size.to(u.degree).value}' AS uri,
95+
'https://irsa.ipac.caltech.edu/' || a.uri || '?center={ra.value},{dec.value}d&size={size.value}' AS uri,
9696
p.time_bounds_lower
9797
FROM spherex.artifact a
9898
JOIN spherex.plane p ON a.planeid = p.planeid
99-
WHERE 1 = CONTAINS(POINT('ICRS', {ra.to(u.degree).value}, {dec.to(u.degree).value}), p.poly)
99+
WHERE 1 = CONTAINS(POINT('ICRS', {ra.value}, {dec.value}), p.poly)
100100
ORDER BY p.time_bounds_lower
101101
"""
102102
@@ -107,6 +107,11 @@ print("Time to do TAP query: {:2.2f} seconds.".format(time.time() - t1))
107107
print("Number of images found: {}".format(len(results)))
108108
```
109109

110+
:::{note}
111+
SPHEREx data are also available via SIA which can provide a simpler interface for many queries, as demonstrated in {ref}`spherex-intro`.
112+
An advantage of the method shown above is that it provides access to data immediately after ingestion (which occurs weekly) and is not subject to the same ~1 day delay as SIA.
113+
:::
114+
110115
For this example, we focus on the first one of the retrieved SPHEREx spectral images.
111116

112117
```{code-cell} ipython3
@@ -176,7 +181,7 @@ We do this by first determining the pixel (x,y) coordinates of our coordinates o
176181

177182
```{code-cell} ipython3
178183
wcs = WCS(cutout_header)
179-
xpix_cutout, ypix_cutout = wcs.world_to_pixel(SkyCoord(ra=ra.to(u.degree), dec=dec.to(u.degree)))
184+
xpix_cutout, ypix_cutout = wcs.world_to_pixel(SkyCoord(ra=ra, dec=dec))
180185
181186
print(f"Pixel values of coordinates of interest on cutout image: x = {xpix_cutout}, y = {ypix_cutout}")
182187
```
@@ -269,7 +274,7 @@ plt.show()
269274

270275
**Authors:** IRSA Data Science Team, including Vandana Desai, Andreas Faisst, Brigitta Sipőcz, Troy Raen
271276

272-
**Updated:** 2025-09-30
277+
**Updated:** 24 October 2025
273278

274279
**Contact:** Contact [IRSA Helpdesk](https://irsa.ipac.caltech.edu/docs/help_desk.html) with questions or problems.
275280

0 commit comments

Comments
 (0)