Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

IRSA Tutorials

Understanding and Analyzing SPHEREx Mosaic Cubes

1. Learning Goals

2. SPHEREx Overview

SPHEREx is a NASA Astrophysics Medium Explorer mission that launched in March 2025. During its planned two-year mission, SPHEREx will obtain 0.75-5 micron spectroscopy over the entire sky, with deeper data in the SPHEREx Deep Fields. SPHEREx data will be used to:

The community will also mine SPHEREx data and combine it with synergistic data sets to address a variety of additional topics in astrophysics.

More information is available in the SPHEREx Explanatory Supplement.

3. Imports

The following packages must be installed to run this notebook.

/home/runner/work/irsa-tutorials/irsa-tutorials/.tox/py312-buildhtml/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
Notebook Cell

4. Open SPHEREx Mosaic Cube

We first show how to open the SPHEREx mosaic cube and how to assign wavelengths to the different planes in the cube.

The mosaic cube was obtained from the IRSA SPHEREx mosaic tool GUI. The mosaic tool computes a cube (x,y,λ\lambda) from SPHEREx data at a given sky position provided by the user. In brief, the tool gathers all the SPHEREx spectral images at that position, extracts the pixels at similar wavelenghts, and reprojects them into cube layers at the respective wavelengths. The final cube has 102 wavelength layers from 0.75 to 5 μm5\,{\rm \mu m}. The user can also specify the spatial size of the cube.

Because the IRSA SPHEREx mosaic tool does not have an API, we have created and downloaded the mosaic already and added it to the ./data/ directory.

We first define the path to the mosaic cube.

Next, we open the image and convert the flux units from MJy/sr to mJy:

[mJy]=[MJy/sr]×23.5045×(pixel scale)2/1000[\rm{mJy}] = [\rm{MJy/sr}] \times 23.5045 \times (\rm{pixel\ scale})^2 / 1000

We also update the BUNIT keyword in the header to reflect this change.

The cube’s WCS describes three axes — right ascension, declination, and wavelength. For spatial operations like plotting and reprojection we only need the two sky axes, which we extract with WCS.celestial.

We can now open the cube:

Filename: /home/runner/.cache/astropy/download/url/fe849a8d38ed3375365307e9e9222675/contents
No.    Name      Ver    Type      Cards   Dimensions   Format
  0  PRIMARY       1 PrimaryHDU       5   ()      
  1  IMAGE         1 ImageHDU        51   (267, 267, 102)   float32   
  2  NHITS         1 ImageHDU        51   (267, 267, 102)   int32   
  3  FLAGS         1 ImageHDU        55   (267, 267, 102)   int32   
  4  SPECTRAL_CHANNELS    1 BinTableHDU     29   102R x 8C   [I, I, E, E, E, E, E, E]   
  5  WCS-WAVE      1 BinTableHDU     18   1R x 3C   [102J, 102E, 102E]   
Loaded SPHEREx cube with pixel scale 9.0 arcsec/px
WARNING: FITSFixedWarning: The WCS transformation has more axes (4) than the image it is associated with (3) [astropy.wcs.wcs]

Note that the FITS has different layers.

5. Create a Quick Look Spectrum

Once we have the cube loaded, let’s generate a quick-look spectrum. This has two purposes: First, it shows how to extract a spectrum from a cube using the PhotUtils python package. Second, it allows us to visualize the wavelength channels (i.e., planes) which we will need to chose the planes to make the final PAH 3.3 μm3.3\,{\rm \mu m} map.

5.1 Create a Wavelength Look-Up Table

Later we will measure an aperture flux on each plane (representing a different wavelength) of the mosaic cube. In order to turn this aperture flux table into a spectrum, we need to track the relevant wavelength range of each plane. Furthermore, the wavelength look-up table will be used to construct the emission line map.

We construct the wavelenght look-up table from the WCS-WAVE layer, which summarizes the wavelength information.

Let’s have a look at this table. The bandwidths correspond to the width of each wavelength channel.

Loading...

5.2 Extract Spectrum

To obtain the spectrum, we create a function that computes the sum of the fluxes in apertures and does a background subtraction using an annulus. Both aperture and annulus sizes are user-defined. We use the PhotUtils package for this (see here for more information). The measurements are done for each cube plane and the combined. Furthermore, the function creates a plot showing the collapsed cube and the apertures used (this output can be turned off).

Notebook Cell
WARNING: MergeConflictWarning: Cannot merge meta key 'date' types <class 'str'> and <class 'str'>, choosing date='2026-09-22 10:54:32 UTC' [astropy.utils.metadata.merge]
<Figure size 500x500 with 1 Axes>
Loading...

Finally, we also add the wavelength from the wavelength look-up table that created above to the photometry table. This makes it easy to plot the spectrum afterwards.

Now that we have all the information, we can plot the spectrum. We also mark some prominent near-infrared emission features for reference.

<Figure size 700x400 with 1 Axes>

6. Create a PAH 3.3 μm3.3\,{\rm \mu m} Map

We now create the PAH 3.3 μm3.3\,{\rm \mu m} map from the cube. The emission line map is created by subtracting the median of nearby continuum planes from the feature plane.

We first identify the relevant planes by matching the observed PAH wavelength to the entries in wave_tab. For M101 the redshift is negligible, but the same code works for any target — just set z to the known redshift.

Feature plane: [np.int64(63)]  (3.293 μm)
Continuum planes: [np.int64(61), np.int64(62), np.int64(64), np.int64(65)]

We can also visualize the chosen planes on the spectrum plot to for additional checking.

<Figure size 700x400 with 1 Axes>

For the map creation, we set up a handy function:

With the planes identified, we can now build the map:

Finally, we can plot our PAH 3.3 μm3.3\,{\rm \mu m} SPHEREx map!

<Figure size 500x500 with 1 Axes>

The map shows the location of the PAH 3.3 μm3.3\,{\rm \mu m} emission in the local galaxy M101. Specifically, the 3.3 μm3.3\,{\rm \mu m} feature is an observational indicator of very small carbonageous dust grains. You can see that the PAH emission is not continuous as it is tied to regions of star formation. To explore this further, we can correlate the PAH map with the GALEX far-UV (FUV) continuum map, which maps the UV emission of hot, young stars. This is done in the next section.

7. Get Corresponding GALEX Image

Next we retrieve the GALEX image corresponding to the SPHEREx mosaic. This is scientifically interesting as we can observe how the PAH emission correlates with UV emission of hot young stars. It is expected that there is an anticorrelation as the small PAH grain (traced by the 3.3 μm3.3\,{\rm \mu m} feature) are being dissociated in strong UV radiation fields.

We first obtain the position in coordinates at the center of the SPHEREx cube. Note that this is a 3d cube, so we have to take axes 1 and 2 (0-indexed) to obtain the coordinates!

Sky position at R.A. = 210.8022671 and Decl. = 54.34895

We then query IRSA at this position to obtain the GALEX FUV image. This data product is part of the Spitzer Local Volume Legacy Survey, which observes many local galaxies. Accordingly, we query the collection spitzer_lvl and search for science images from GALEX in the FUV energy passband.

Loading...

Once we have the table, we can access the URL of the image in the access_url column. With the URL we can load the FITS image and create a cutout of similar size as the SPHEREx mosaic.

Filename: /home/runner/.cache/astropy/download/url/adfbacbc3e38c3f9b2d2159447c2aeb7/contents
No.    Name      Ver    Type      Cards   Dimensions   Format
  0  PRIMARY       1 PrimaryHDU     137   (3840, 3840)   float32   

Additionally, we do some post-processing on the image to convert the pixel units to milli-Jansky, similar as the SPHEREx mosaic. Note that the zero points for the GALEX FUV and NUV images are different as defined above. We refer to the Spitzer LVL documentation for more details on the GALEX pixel units.

/tmp/ipykernel_4097/3849881548.py:2: RuntimeWarning: divide by zero encountered in log10
  img_galex_ab = -2.5*np.log10(img_galex) + zps["fuv"]

In a last step, we will have to reproject the GALEX image to the SPHEREx mosaic. This is necesary so we can overlap the GALEX image with the PAH 3.3 μm3.3\,{\rm \mu m} map that we have created above. For this, we use the reproject package.

Finally, we caon overlay the PAH emission on the GALEX map, which is our final result of this tutorial notebook.

<Figure size 900x900 with 1 Axes>

The figure shows the PAH 3.3 μm3.3\,{\rm \mu m} emission (red contours) on top of the GALEX FUV continuum emission (blue). The inset shows a zoom in on the central regions. This comparison confirms that the PAH 3.3 μm3.3\,{\rm \mu m} emission generally follows the location of young hot stars. However, there are also differences (see zoom-in) where there are bright UV regions devoid of PAH emission. This may be the case where the strong ionization fields of young stars dissolve the small dust grains.

Acknowledgements

About this notebook

Updated: 8 May 2026

Contact: Contact IRSA Helpdesk with questions or problems.

Runtime: This notebook takes about 20 seconds to run to completion on a machine with 32GB RAM and 8 CPU.