'''
@brief Runs routines that read in text image files; writes out "nint" form [don't know why it doesn't work w/ EGRET data???]
@author A. Connors
'''
# @file make_txt_rmatrix.py
#
# This script is explicitly for reading in "output.txt" format files
# and writing them out in same format, but with "nint" form.
#
import pyfits
#from numarray import * ## Changed to numpy Aug 2007
from numpy import *
from get_txt_rmatrix import *

infile_list = [
    ('counts_g1-9_g004gt1GeVpadded64x64b.txt','nintcounts_g1-9_g004gt1GeVpadded64x64b.txt')
     ]

naxis_3tuple = (1,64,64)

for nametuple in infile_list:
    print ' File names:',nametuple
    tst = ScanTxtMatrix(nametuple[0],naxis_3tuple)

    OutData = tst.data
    OutHeader = tst.header
    fninttstout = open(nametuple[1],'w')
    for l2 in range(64):
        for l1 in range(64):
            OutData = nint(tst.data[0][l2][l1])
            fninttstout.write( str(OutData[0][l2][l1])+'\n' )
# Close
    fninttstout.close()

# End!!

    
