In [30]:
%%bash
pip install aplpy 
pip install https://github.com/ericmandel/pyds9/archive/master.zip


Requirement already satisfied (use --upgrade to upgrade): aplpy in /Users/adam/anaconda/envs/esopython2016/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): astropy in /Users/adam/anaconda/envs/esopython2016/lib/python3.5/site-packages (from aplpy)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.0 in /Users/adam/anaconda/envs/esopython2016/lib/python3.5/site-packages (from astropy->aplpy)
Collecting https://github.com/ericmandel/pyds9/archive/master.zip
  Downloading https://github.com/ericmandel/pyds9/archive/master.zip (1.0MB)
  Requirement already satisfied (use --upgrade to upgrade): pyds9==1.8.1 from https://github.com/ericmandel/pyds9/archive/master.zip in /Users/adam/anaconda/envs/esopython2016/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): six in /Users/adam/anaconda/envs/esopython2016/lib/python3.5/site-packages (from pyds9==1.8.1)

In [31]:
%%bash
curl -O https://astropy.stsci.edu/data/galactic_center/gc_bolocam_gps.fits
curl -O https://astropy.stsci.edu/data/galactic_center/gc_2mass_k.fits


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1605k  100 1605k    0     0   739k      0  0:00:02  0:00:02 --:--:--  740k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1020k  100 1020k    0     0   435k      0  0:00:02  0:00:02 --:--:--  435k

In [32]:
%matplotlib inline
import pylab as pl

In [33]:
from astropy.io import fits

In [34]:
stellardata = fits.getdata('gc_2mass_k.fits')

In [35]:
pl.imshow(stellardata, cmap=pl.cm.gray, vmax=1000)


Out[35]:
<matplotlib.image.AxesImage at 0x11f17b4e0>

In [36]:
dustdata = fits.getdata('gc_bolocam_gps.fits')

In [37]:
pl.contour(dustdata)


Out[37]:
<matplotlib.contour.QuadContourSet at 0x11f333a20>

In [38]:
# pl.hist(dustdata.flatten(), bins=50)
pl.hist(dustdata[np.isfinite(dustdata)], bins=50)


Out[38]:
(array([  1.00000000e+00,   3.00000000e+00,   4.00000000e+00,
          4.00000000e+00,   3.10000000e+01,   1.46000000e+02,
          1.27700000e+03,   4.25890000e+04,   2.89834000e+05,
          2.97930000e+04,   1.11970000e+04,   5.02900000e+03,
          2.38000000e+03,   1.46500000e+03,   9.86000000e+02,
          7.11000000e+02,   4.68000000e+02,   3.19000000e+02,
          2.79000000e+02,   2.58000000e+02,   1.84000000e+02,
          1.81000000e+02,   1.33000000e+02,   1.02000000e+02,
          8.90000000e+01,   8.20000000e+01,   6.90000000e+01,
          6.10000000e+01,   5.10000000e+01,   5.00000000e+01,
          3.50000000e+01,   1.90000000e+01,   1.80000000e+01,
          1.80000000e+01,   7.00000000e+00,   9.00000000e+00,
          7.00000000e+00,   1.10000000e+01,   2.00000000e+00,
          4.00000000e+00,   5.00000000e+00,   2.00000000e+00,
          1.00000000e+00,   0.00000000e+00,   2.00000000e+00,
          2.00000000e+00,   0.00000000e+00,   2.00000000e+00,
          0.00000000e+00,   1.00000000e+00]),
 array([-1.94999576, -1.71324491, -1.47649406, -1.23974322, -1.00299237,
        -0.76624153, -0.52949068, -0.29273983, -0.05598899,  0.18076186,
         0.4175127 ,  0.65426355,  0.89101439,  1.12776524,  1.36451609,
         1.60126693,  1.83801778,  2.07476862,  2.31151947,  2.54827032,
         2.78502116,  3.02177201,  3.25852285,  3.4952737 ,  3.73202455,
         3.96877539,  4.20552624,  4.44227708,  4.67902793,  4.91577878,
         5.15252962,  5.38928047,  5.62603131,  5.86278216,  6.099533  ,
         6.33628385,  6.5730347 ,  6.80978554,  7.04653639,  7.28328723,
         7.52003808,  7.75678893,  7.99353977,  8.23029062,  8.46704146,
         8.70379231,  8.94054316,  9.177294  ,  9.41404485,  9.65079569,
         9.88754654]),
 <a list of 50 Patch objects>)

In [39]:
pl.contour(dustdata, levels=np.linspace(0.2,10,10))


Out[39]:
<matplotlib.contour.QuadContourSet at 0x119e72e48>

An example of why overplotting directly doesn't work:


In [40]:
pl.figure(figsize=(12,12))
pl.imshow(stellardata, cmap=pl.cm.gray, vmax=1000)
pl.contour(dustdata, levels=np.linspace(0.2,10,10))


Out[40]:
<matplotlib.contour.QuadContourSet at 0x11a6747f0>

In [41]:
import aplpy

In [42]:
F = aplpy.FITSFigure('gc_2mass_k.fits')
F.show_grayscale(vmax=1000)
F.show_contour('gc_bolocam_gps.fits', convention='calabretta')


/Users/adam/anaconda/envs/esopython2016/lib/python3.5/site-packages/matplotlib/artist.py:221: MatplotlibDeprecationWarning: This has been deprecated in mpl 1.5, please use the
axes property.  A removal date has not been set.
  warnings.warn(_get_axes_msg, mplDeprecation, stacklevel=1)
INFO: Auto-setting vmin to  4.221e+02 [aplpy.core]
WARNING: FITSFixedWarning: LONPOLE2= 180.000000000 /lonpole 
invalid alternate code, keyword resembles LONPOLEa but isn't. [astropy.wcs.wcs]
WARNING: FITSFixedWarning: LATPOLE2= 0.00000000000 /latpole 
invalid alternate code, keyword resembles LATPOLEa but isn't. [astropy.wcs.wcs]

In [43]:
import pyds9

In [47]:
DD = pyds9.DS9('mine')

In [48]:
DD.set('frame 1')
DD.set_pyfits(fits.open('gc_2mass_k.fits'))


Out[48]:
1

In [49]:
DD.set('frame lock wcs')
DD.set('frame 2')
DD.set_pyfits(fits.open('gc_bolocam_gps.fits'))


Out[49]:
1

In [50]:
DD.set('blink')


Out[50]:
1

Exercises

  1. Using the gc_2mass_k.fits image & aplpy, make a finder chart of the galactic center

    • add a scalebar
    • make nicer contours
    • adjust the scaling
    • add a colorbar
    • Recenter & zoom on a particular object

In [ ]: