In [272]:
cd ~/research/TP-AGBcalib/code/TPAGB-calib/
In [274]:
import sfh_tests_multi_proc
from TPAGBparams import snap_src
import ResolvedStellarPops as rsp
In [ ]:
pdb
In [295]:
reload(sfh_tests_multi_proc)
Out[295]:
In [296]:
cmd_input_file = 'caf09_s_nov13.dat'
cmd_input = 'caf09_s_nov13'
In [297]:
targets = ['ddo71', 'hs117', 'kkh37', 'ngc2976-deep', 'ddo78']
galaxy_inputs = [snap_src + '/models/varysfh/%s/%s/mc/input_%s_000.dat' % (t, cmd_input,
t.upper())
for t in targets]
trilegal_outputs = [snap_src + '/models/test/output_%s_%s_000.dat' % (t, cmd_input) for t in targets]
sfh_files = [rsp.fileIO.get_files(snap_src + '/data/sfh_parsec/',
'*%s*.sfh' % t.replace('-deep', ''))[0] for t in targets]
In [298]:
import os
if False in [os.path.isfile(s) for s in np.concatenate([galaxy_inputs, trilegal_outputs, sfh_files])]:
print 'bad file names!!'
In [299]:
file_origin = 'match-grid'
cmd_input_file = 'caf09_s_nov13.dat'
nsfhs = 2
outfile_loc = '/home/rosenfield/research/TP-AGBcalib/SNAP/models/test/'
In [300]:
vSFHs = [sfh_tests_multi_proc.VarySFHs(galaxy_inputs[i], sfh_files[i], file_origin, cmd_input_file,
nsfhs, outfile_loc=outfile_loc) for i in range(len(targets))]
In [348]:
import galaxy_tests
In [361]:
for band in ['ir', 'opt']:
fits_src = snap_src + '/data/angst_no_trim'
filter2 = 'F814W'
trbg_off = 0.1
if band == 'ir':
fits_src = 'default'
filter2 = 'F160W'
trgb_off = 0.2
for i, vSFH in enumerate(vSFHs):
#narratio_dict, sdata, result_dict = \
# vSFH.do_normalization(filter1=vSFH.filter1, trilegal_output=trilegal_outputs[i], debug=True)
gal = galaxy_tests.load_galaxy(vSFH.target, band=band, fits_src=fits_src)
rgb_thresh = 5
trgb = vSFH.__getattribute__('%s_trgb' % band)
mag = vSFH.sgal.data.get_col(filter2)
vSFH.sgal.all_stages()
rgb_inds = vSFH.sgal.irgb
rgb_bins = np.arange(10, 30, 0.01)
rgb_hist, _ = np.histogram(mag[rgb_inds], bins=rgb_bins)
rgb_bin_edge = np.nonzero(rgb_hist > rgb_thresh)[0][0] - 1
offset = rgb_bins[rgb_bin_edge] - trgb
print '%s offset %s: %.3f' % (band, vSFH.target, offset)
fig, ax = plt.subplots()
hist_kw = {'bins': rgb_bins, 'histtype': 'step'}
#ax.hist(mag, color='gray', **hist_kw)
ax.hist(mag[rgb_inds], color='red', **hist_kw)
#ax.hist(mag - offset, color='blue', **hist_kw)
ax.hist(mag[rgb_inds] - offset, color='darkgreen', **hist_kw)
ax.hist(gal.mag2, color='black', **hist_kw)
ax.set_yscale('log')
ax.vlines(trgb + trgb_off, *ax.get_ylim(), linestyle='--')
ax.vlines(trgb, *ax.get_ylim())
ax.vlines(trgb - trgb_off, *ax.get_ylim(), linestyle='--')
ax.vlines(rgb_bins[rgb_bin_edge], *ax.get_ylim(), linestyle='--', color='blue')
ax.set_title('$%s$' % vSFH.target, fontsize=20)
ax.set_xlim(trgb-2, trgb+2)
ax.set_xlabel('$%s$' % filter2, fontsize=20)
In [360]:
plt.close('all')