In [2]:
cd ..


/home/rosenfield/research/TP-AGBcalib/code/TPAGB-calib

In [3]:
import ResolvedStellarPops as rsp
import sfh_tests

In [6]:
# convert MATCH SFH to Trilegal AMR
sfh_loc = '/home/rosenfield/research/TP-AGBcalib/PHAT/sfh'
sfh_files = rsp.fileIO.get_files(sfh_loc, '*sfh')

sfhs = [sfh_tests.StarFormationHistories(sfh_file, 'match-old') for sfh_file in sfh_files]
tri_sfhs = [sfh.make_trilegal_sfh() for sfh in sfhs]

In [34]:
trilegal_outputs = []
cmd_input_file = 'cmd_input_CAF09_S_NOV13.dat'
agb_mod = cmd_input_file.split('_')[-1].replace('.dat', '')
# values taken from .sfh file!
dmod = 24.47
dist = 10 ** (dmod / 5 + 1.)
Av = 0.4

gal_inp_dict = {'mag_limit_val': 28, 'object_dist': dist, 'object_av': Av,
                'file_imf': 'tab_imf/imf_kroupa_orig.dat'}

for tri_sfh in tri_sfhs:
    for aringer in [True, False]:
        # make galaxy input for trilegal
        gal_file = tri_sfh.replace('tri.dat', 'gal.inp')
        if aringer is True:
            gal_file = gal_file.replace('gal.inp', 'aringer.gal.inp')
        # initialze the dict
        gal_init = {'photsys': 'phat_agb', 'filter1': 'F475W', 'object_sfr_file': tri_sfh,
                    'aringer': aringer, 'object_mass': 1e8}
        gal_inp = rsp.fileIO.input_parameters(default_dict=rsp.TrilegalUtils.galaxy_input_dict(**gal_init))
        gal_inp.add_params(gal_inp_dict)
        # write the file
        gal_inp.write_params(gal_file, rsp.TrilegalUtils.galaxy_input_fmt())     

        # run trilegal
        trilegal_output = gal_file.replace('gal.inp', 'tri.out')
        rsp.TrilegalUtils.run_trilegal(cmd_input_file, gal_file,
                                       trilegal_output, rmfiles=False,
                                       dry_run=False)
        trilegal_outputs.append(trilegal_output)


code_2.3/main -f cmd_input_CAF09_S_NOV13.dat -a -l /home/rosenfield/research/TP-AGBcalib/PHAT/sfh/M31-B21_3x6-012.aringer.gal.inp /home/rosenfield/research/TP-AGBcalib/PHAT/sfh/M31-B21_3x6-012.aringer.tri.out
code_2.3/main -f cmd_input_CAF09_S_NOV13.dat -a -l /home/rosenfield/research/TP-AGBcalib/PHAT/sfh/M31-B21_3x6-015.aringer.gal.inp /home/rosenfield/research/TP-AGBcalib/PHAT/sfh/M31-B21_3x6-015.aringer.tri.out
TRILEGAL was terminated successfully
TRILEGAL was terminated successfully
code_2.3/main -f cmd_input_CAF09_S_NOV13.dat -a -l /home/rosenfield/research/TP-AGBcalib/PHAT/sfh/M31-B21_3x6-006.aringer.gal.inp /home/rosenfield/research/TP-AGBcalib/PHAT/sfh/M31-B21_3x6-006.aringer.tri.out
TRILEGAL was terminated successfully



In [31]:
vSFH = sfh_tests.VarySFHs(gal_file, sfh_files[0], 'match-old', target='M31-B21_3x6-012')


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-31-f26ffb81faa8> in <module>()
----> 1 vSFH = sfh_tests.VarySFHs(gal_file, sfh_files[0], 'match-old', target='M31-B21_3x6-012')

/home/rosenfield/research/TP-AGBcalib/code/TPAGB-calib/sfh_tests.pyc in __init__(self, galaxy_input, sfh_file, file_origin, target, table_file, ast)
    679         # load stars in data RGB and AGB region as well as TRGBs.
    680         # this is just a call to self.ags.data
--> 681         self.load_data_for_normalization()
    682 
    683         # should we use ast corrections?

/home/rosenfield/research/TP-AGBcalib/code/TPAGB-calib/sfh_tests.pyc in load_data_for_normalization(self)
    900         row, = np.nonzero(self.ags.data['target'] == target)
    901         [self.__setattr__('%s' % c, self.ags.data[row]['%s' % c][0])
--> 902          for c in column_names if c != 'target']
    903 
    904         if len(self.ags.offsets) == 0:

IndexError: index 0 is out of bounds for axis 0 with size 0

In [33]:
reload(rsp.TrilegalUtils)


Out[33]:
<module 'ResolvedStellarPops.TrilegalUtils' from '/home/rosenfield/research/python/ResolvedStellarPops/TrilegalUtils.py'>

In [27]:
tri_out = trilegal_outputs[0]

In [28]:
sgal = rsp.Galaxies.simgalaxy(tri_out, filter1='F475W', filter2='F814W')


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-28-ccb882e25c99> in <module>()
----> 1 sgal = rsp.Galaxies.simgalaxy(tri_out, filter1='F475W', filter2='F814W')

/home/rosenfield/research/python/ResolvedStellarPops/Galaxies.pyc in __init__(self, trilegal_out, filter1, filter2, photsys, count_offset, table_data)
   1126             self.name = trilegal_out.name
   1127         else:
-> 1128             self.data = fileIO.read_table(trilegal_out)
   1129             self.base, self.name = os.path.split(trilegal_out)
   1130         self.filter1 = filter1

/home/rosenfield/research/python/ResolvedStellarPops/fileIO.pyc in read_table(filename, comment_char, loud)
    274         print '%.3fs: lines read' % (elapsed())
    275 
--> 276     col_keys = lines[0].strip().replace(comment_char, '').split()
    277 
    278     Ncols = len(col_keys)

IndexError: list index out of range