#!/usr/bin/python #By Samuel George; sgeorge@mrao.cam.ac.uk #Original 10/12/11 #Purpose: Create a dataset with 2 Gaussians and fit both #usage: extract_spectra.py #produces: plot_spectra.png import warnings warnings.simplefilter("ignore",DeprecationWarning) import matplotlib matplotlib.use('Agg') #avoid X11 issues. import pyfits, numpy, scipy, pylab from scipy import * from pylab import * input_file = "Neon.fits" hdulist = pyfits.open(input_file) img_data = hdulist[0].data #we know that the spectra, by looking at the FITS file with DS9 has data in a small apeture #for now we will ignore any averaging. #lets take line 144 as we know there is data. data_use = img_data[144] #plot the spectra fig = figure(figsize=(9, 9)) #make a plot ax1 = fig.add_subplot(111) ax1.plot(img_data[144]) #spectrum setp(gca(), ylabel="Un-normalised power", xlabel="Pixel Position") pylab.savefig("plot_spectra.png")