In [1]:
%pylab inline
# Matplotlib default settings
rcdef = plt.rcParams.copy()
pylab.rcParams['figure.figsize'] = 12, 10
pylab.rcParams['xtick.major.size'] = 8.0
pylab.rcParams['xtick.major.width'] = 1.5
pylab.rcParams['xtick.minor.size'] = 4.0
pylab.rcParams['xtick.minor.width'] = 1.5
pylab.rcParams['ytick.major.size'] = 8.0
pylab.rcParams['ytick.major.width'] = 1.5
pylab.rcParams['ytick.minor.size'] = 4.0
pylab.rcParams['ytick.minor.width'] = 1.5
rc('axes', linewidth=2)

import numpy as np
from astropy.io import fits 
from __future__ import division 
from astropy import units as u

import cubehelix  # Cubehelix color scheme
import copy

import os.path
from pyraf import iraf


Populating the interactive namespace from numpy and matplotlib

Read in the GALFIT output file


In [3]:
# GALFIT output file 
galfitFile1 = 'red_21572_Icut_1comp.fits'
galfitFile2 = 'red_21572_Icut_2comp.fits'

galOutData1 = fits.open(galfitFile1)
galOutData2 = fits.open(galfitFile2)

# Basic structure 
galOutData1.info()


Filename: red_21572_Icut_1comp.fits
No.    Name         Type      Cards   Dimensions   Format
0    PRIMARY     PrimaryHDU       8   (801, 801)   float32   
1                ImageHDU        53   (801, 801)   float32   
2                ImageHDU        36   (801, 801)   float32   
3                ImageHDU         6   (801, 801)   float32   

In [4]:
# Read in the Multi-Extension Data 
galOri1 = galOutData1[1].data
galMod1 = galOutData1[2].data
galRes1 = galOutData1[3].data

galOri2 = galOutData2[1].data
galMod2 = galOutData2[2].data
galRes2 = galOutData2[3].data

In [9]:
# Header information for the model image
headMod1 = galOutData1[2].header
headMod2 = galOutData2[2].header

# Show an example header from Galfit model image
headMod2


Out[9]:
XTENSION= 'IMAGE   '           / IMAGE extension                                
BITPIX  =                  -32 / Bits per pixel                                 
NAXIS   =                    2 / Number of axes                                 
NAXIS1  =                  801 / Length of data axis 1                          
NAXIS2  =                  801 / Length of data axis 2                          
OBJECT  = 'model   '           / Component type                                 
COMMENT ========== GALFIT Input Parameters ==========                           
INITFILE= 'red_21572_Icut_2comp.in' / GALFIT input file                         
DATAIN  = 'red_21572_Icut_cor.fits' / Input data image                          
SIGMA   = 'none    '           / Input sigma image                              
PSF     = 'red_21572_Ipsf.fits ' / Convolution PSF and kernel                   
CONSTRNT= '2comp.cons'         / Parameter constraint file                      
MASK    = 'red_21572_Icut_msk.fits' / Input mask image                          
FITSECT = '[1:801,1:801]'      / Image section fitted                           
CONVBOX = '800, 800'           / Convolution box size                           
MAGZPT  =                  27. / Magnitude zeropoint                            
COMMENT ========== GALFIT Final Parameters ==========                           
COMP_1  = 'sersic  '           / Component type                                 
1_XC    = '400.4864 +/- 0.0086' / X center [pixel]                              
1_YC    = '400.9287 +/- 0.0079' / Y center [pixel]                              
1_MAG   = '19.6341 +/- 0.1107' / Integrated magnitude [mag]                     
1_RE    = '3.4256 +/- 0.3614'  / Effective radius Re [pixels]                   
1_N     = '2.9510 +/- 0.1542'  / Sersic index                                   
1_AR    = '0.7669 +/- 0.0095'  / Axis ratio (b/a)                               
1_PA    = '77.3182 +/- 1.2794' / Position Angle (PA) [degrees: Up=0, Left=90]   
COMMENT ------------------------------------------------------------------------
COMP_2  = 'sersic  '           / Component type                                 
2_XC    = '400.4681 +/- 0.0613' / X center [pixel]                              
2_YC    = '400.2686 +/- 0.0755' / Y center [pixel]                              
2_MAG   = '18.9063 +/- 0.0575' / Integrated magnitude [mag]                     
2_RE    = '20.0994 +/- 0.8527' / Effective radius Re [pixels]                   
2_N     = '1.8463 +/- 0.1019'  / Sersic index                                   
2_AR    = '0.8483 +/- 0.0111'  / Axis ratio (b/a)                               
2_PA    = '-46.7013 +/- 3.6825' / Position Angle (PA) [degrees: Up=0, Left=90]  
COMMENT ------------------------------------------------------------------------
FLAGS   = 'A-6 A-3 A-5 '       / See `galfit -help' for details.                
COMMENT ------------------------------------------------------------------------
CHISQ   =     492095.934662876 / Chi^2 of fit                                   
NDOF    =               428076 / Degrees of freedom                             
NFREE   =                   14 / Number of free parameters                      
NFIX    =                    0 / Number of fixed parameters                     
CHI2NU  =             1.149553 / Reduced Chi^2                                  
LOGFILE = 'galfit.08'          / Output logfile                                 
COMMENT =============================================                           
COMMENT                                                                         

In [11]:
aa = headMod2['1_MAG']

In [17]:
bb = float((aa.split())[0])

In [ ]:


In [ ]: