In [1]:
from __future__ import print_function, division, absolute_import

Exercises for image visualization

Feel free to pick and choose from these.

Some exercises make use of code in the notebook. Other exercises will require a GUI interaction.

1. matplotlib: Contours from another image, and secondary axes

Using matplotlib and astropy:

  • display the file .data/w5.fits as a bitmap with log stretch and min-max scaling
  • overlay the data in image extension 1 of ./data/0259p6031_1342192088_SpirePhoto_L20_PMP350_SPG14.0.fits.fits.gz as white contours with levels drawn at [0.7, 1.4, 3] image units (Jy/beam)
  • display coordinate axes and grid (green, alpha=1) in (RA, Dec)
  • overlay a coordinate grid (cyan, alpha=1) and axis labels in Galactic longitude and latitude

In [14]:
import matplotlib.pyplot as plt
from astropy.io import fits
from astropy.wcs import WCS
from astropy.visualization import (MinMaxInterval,
                                  LogStretch,
                                  ImageNormalize)
%matplotlib inline

2. RGB-3-color images

Using astropy and reproject (installable with pip install reproject), follow these instructions in the Astropy documentation to make color RGB images. Compare the second one to Figure 1 of Lupton et al 2004.


In [28]:
import numpy as np
from astropy.visualization import make_lupton_rgb
from astropy.io import fits
from reproject import reproject_interp

In [10]:
# Read in the three images downloaded from here:
g = fits.open('http://dr13.sdss.org/sas/dr13/eboss/photoObj/frames/301/1737/5/frame-g-001737-5-0039.fits.bz2')[0]
r = fits.open('http://dr13.sdss.org/sas/dr13/eboss/photoObj/frames/301/1737/5/frame-r-001737-5-0039.fits.bz2')[0]
i = fits.open('http://dr13.sdss.org/sas/dr13/eboss/photoObj/frames/301/1737/5/frame-i-001737-5-0039.fits.bz2')[0]

3. RGB colors of Herschel-SPIRE images

Reproject the 250 um image of W5 in ./data/0259p6031_1342192088_SpirePhoto_L20_PMP250_SPG14.0.fits.gz (extension 1) and the 350 micron image in ./data/0259p6031_1342192088_SpirePhoto_L20_PMP350_SPG14.0.fits.gz onto the 500 micron image in that directory, and try the same 3-color procedures.


In [21]:
w5_250 = fits.open('./data/0259p6031_1342192088_SpirePhoto_L20_PMP250_SPG14.0.fits.gz')[1]
w5_350 = fits.open('./data/0259p6031_1342192088_SpirePhoto_L20_PMP350_SPG14.0.fits.gz')[1]
w5_500 = fits.open('./data/0259p6031_1342192088_SpirePhoto_L20_PMP500_SPG14.0.fits.gz')[1]

4. Ginga reference viewer

If you haven't already, install Ginga with pip install ginga.

  • Launch the Ginga reference viewer from the shell.
  • Read in the three Herschel-SPIRE images in ./data/0259*fits.gz into separate channels
    • Use top-level menu "Channel -> Add Channel"
    • Use top-level menu "File -> Load Image"
  • Start the WCS Match plugin and blink the images

5. Firefly with PTF Images

  • Point your browser to IRSA's PTF image service.
  • Search position 312.503802, -0.706603 in the Level 1 images.
  • Go to Catalogs, overlay Gaia catalog
  • Select different images; and select different Gaia sources in an image (two tabs in table).

6. Glue with a photometric redshift catalog

If you haven't already, install Glue with conda install -c conda-forge glueviz

  • Start glue from the command line
  • Import a photometric redshift catalog from ./data/mrrphotz_xmmbrite.dat
  • Import the image ./data/xmm-lss-cutout-350um
  • Link the ra and dec from the table to Right Ascenscion and Declination from the image
  • Drag the image and start an Image Viewer
  • Drag the catalog over the image
  • Table alz2 is $log_{10}(1+z_{phot})$ for free $A_V$ solution. Define a new component photz inside Glue as np.power( 10, mrrphotz_xmmbrite.dat:alz2 ) - 1.0 and add it to the table
  • Make a histogram of spectroscopic redshift, spectz0. Select the subset of spectz0 > 0 and call it non-zero specz
  • Make a scatter plot of photz vs spectz0 for this subset
  • Facet the non-zero specz into 5 subsets by nbopt (number of optical bands). Explore the spatial distribution of the data with the highest number of optical bands.

Advanced: Install Firefly Standalone

If you have Java or are comfortable installing it, you can install a local Firefly server.

Check that you have java 1.8 installed with java -version

Download Firefly Standalone from release page (https://github.com/Caltech-IPAC/firefly/releases

Start with java -jar firefly-exec.war

Firefly will be available on localhost port 80: http://localhost:8080/firefly/

Once it is running, if you have done pip install firefly_client:

  • upload the file .data/w5.fits and display it
  • overlay the w5_wise.tbl

The steps are in the ImageVizSlides notebook.