--
JeanDuffy - 25 Oct 2013
Extraction of useful information from a fit file
#Change directory
import os
os.chdir("C:/Users/Jean/Desktop/Python/Bsc/Fits")
# Import fits from astropy.io
from astropy.io import fits
# Open the fit file "Atlas_pleione_1sec.fit" which
# opens it as an HDU (Header Data Unit) list and set to f.
f=fits.open("Atlas_pleione_1sec.fit")
# Set i to be an HDU object.
i=f[0]
# Set d to be an array of data.
d=i.data
# Imports matplotlib.pyplot module
import matplotlib.pyplot as plt
# Plots the array
plt.figure(0),plt.imshow(d)
# Creates a figure and shows the plot
# Not needed in the kernel (for some reason)
# Gets all the Header information from the fit file
print fits.getheader("Atlas_pleione_1sec.fit")
# These can be run in the kernel
print d.mean()
print d.std()
print d.sum()
print d.sum(0)
print d.sum(1)
# Create a sub area
d2=d[700:800,850:950]
# Plot the subarea on a new figure
plt.figure(1), plt.imshow(d2)
plt.show()