-- 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)

y=d.sum(1)

import numpy as np

x=np.arange(0,len(y),1)

xmean=(x[600:]*y[600:]).sum()/y[600:].sum()

print xmean

plt.figure(2),plt.plot(x,y)

plt.show()

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...

Physics WebpagesRHUL WebpagesCampus Connect • Royal Holloway, University of London, Egham, Surrey TW20 0EX; Tel/Fax +44 (0)1784 434455/437520

Topic revision: r2 - 25 Oct 2013 - JeanDuffy

 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding RHUL Physics Department TWiki? Send feedback