In [1]:
file = '/Users/schriste/Downloads/go06940108.fits'

In [ ]:
from matplotlib import pyplot as plt

In [ ]:
%pylab inline

In [ ]:
import pandas as pd

In [2]:
from astropy.io import fits as pyfits

In [ ]:
from sunpy.time import parse_time

In [ ]:
from datetime import timedelta

In [3]:
fits = pyfits.open(file)

In [4]:
fits[0].header


Out[4]:
SIMPLE  =                    T / Written by IDL:   9-Jan-1994 02:01:38.00       
EXTEND  =                    T / FITS file contains extensions                  
NUMEXT  =                    2 / no. of extensions in file                      
BITPIX  =                  -32 / IEEE single precision floating point           
NAXIS   =                    2 / no. of dimensions in array                     
NAXIS1  =                28236 / no. of time intervals                          
NAXIS2  =                    3 / time, X-ray long, X-ray short                  
DATE-OBS= '08/01/94 '          / UT date of first observation (DD/MM/YY)        
TIME-OBS= '0000:01 '           / time of first observation (HHMM:SS)            
TIMEZERO=          473990400.0 / DATE-OBS in seconds from 79/1/1,0              
DATE-END= '08/01/94 '          / UT date of last observation (DD/MM/YY)         
TIME-OBS= '2359:58 '           / time of last observation (HHMM:SS)             
TELESCOP= 'GOES 6   '          / spacecraft                                     
INSTRUME= 'X-ray Detector'                                                      
OBJECT  = 'Sun'                                                                 
ORIGIN  = 'SDAC/GSFC '         / written by Solar DAC at GSFC                   
DATE    = '09/01/94'           / file creation date (DD/MM/YY)                  
                                                                                
CTYPE1  = 'seconds '     / seconds into DATE-OBS of 3s interval (see comments)  
CTYPE2  = 'watts / m^2'  / in 1. - 8. Angstrom band                             
CTYPE3  = 'watts / m^2'  / in .5 - 4. Angstrom band                             
COMMENT = 'Energy band information given in extension 1'                        
COMMENT = 'Status word information given in extension 2'                        
COMMENT = 'Times given are usually 2-3 seconds after start time of interval.'   
COMMENT = 'Can't be more exact due to analog filtering of data with time '      
COMMENT = 'constant of 6-10 seconds.'                                           
COMMENT = 'Flux value of -99999.0 means no data.'                               
COMMENT = 'Reference: Solar X-Ray Measurements from SMS-1, SMS-2, and GOES-1;'  
COMMENT = 'Information for Data Users.  Donnelly et al,  June 1977.'            
COMMENT = 'NOAA TM ERL SEL-48'                                                  
COMMENT = 'Reference: SMS GOES Space Environment Monitor Subsystem,'            
COMMENT = 'Grubb, Dec 75, NOAA, Technical Memorandum ERL SEL-42.'               
COMMENT = 'Reference: Expresions to Determine Temperatures and Emission'        
COMMENT = 'Measures for Solar X-ray events from GOES Measurements.'             
COMMENT = 'Thomas et al, 1985, Solar Physics 95, pp 323-329.'                   

In [5]:
fits[0].data


Out[5]:
array([[  1.41406250e+00,   4.47656250e+00,   7.53125000e+00, ...,
          8.63920625e+04,   8.63951250e+04,   8.63981797e+04],
       [  6.19950015e-07,   6.16847046e-07,   6.23053040e-07, ...,
          4.33770026e-07,   4.30667029e-07,   4.24461007e-07],
       [  5.13070031e-09,   5.41100009e-09,   5.41100009e-09, ...,
          3.16860005e-09,   3.16860005e-09,   1.76710002e-09]], dtype=float32)

In [8]:
seconds = fits[0].data[0]

In [13]:
parse_time(fits[0].header['TIMEZERO'])


Out[13]:
datetime.datetime(1994, 1, 8, 0, 0)

In [14]:
start_time = parse_time(fits[0].header['TIMEZERO'])

In [23]:
(seconds[0] - np.floor(seconds[0])) * 1e6


Out[23]:
414062.5

In [43]:
times = [start_time + timedelta(seconds = int(np.floor(s)), microseconds = int((s - np.floor(s))*1e6)) for s in seconds]

In [92]:
times[-1]


Out[92]:
datetime.datetime(1994, 1, 8, 23, 59, 58, 179687)

In [72]:
xrsa = fits[0].data[1]

In [73]:
xrsb = fits[0].data[2]

In [85]:
xrsb[xrsb == -99999] = np.nan

In [86]:
xrsa[xrsa == -99999] = np.nan

In [87]:
newxrsa = xrsa.byteswap().newbyteorder()
newxrsb = xrsb.byteswap().newbyteorder()

In [88]:
d = {'xrsa': newxrsa, 'xrsb': newxrsb}

In [89]:
goes = pd.DataFrame(d, index=times)

In [90]:
plt.figure()


Out[90]:
<matplotlib.figure.Figure at 0x1087b2dd0>
<matplotlib.figure.Figure at 0x1087b2dd0>

In [91]:
goes.plot()


Out[91]:
<matplotlib.axes.AxesSubplot at 0x10b869290>

In [ ]: