A notebook following the first few steps in the python4astronomers tutorial.
Author: Lehman Garrison (lgarrison@cfa.harvard.edu)
Made for the CfA Jupyter Workshop at Wolbach Library, 12/7/2016
In [1]:
from astropy.extern.six.moves.urllib import request
import tarfile
url = 'http://python4astronomers.github.io/_downloads/core_examples.tar'
tarfile.open(fileobj=request.urlopen(url), mode='r|').extractall()
Let's see what files we just extracted:
In [2]:
%ls py4ast/core
Now prep the notebook for plotting:
In [3]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
Parse the FITS file:
In [4]:
from astropy.io import fits
hdus = fits.open('py4ast/core/3c120_stis.fits.gz')
hdus
Out[4]:
In [5]:
primary = hdus[0].data # Primary (NULL) header data unit
img = hdus[1].data # Intensity data
err = hdus[2].data # Error per pixel
dq = hdus[3].data # Data quality per pixel
And finally plot:
In [10]:
%matplotlib inline
plt.imshow(img, origin = 'lower', vmin = -10, vmax = 65)
plt.colorbar()
Out[10]:
Success! Let's save to disk:
In [7]:
plt.savefig('3c120.png')
Did it work?
In [8]:
%ls