t1 = time.clock() logger.info("Creating bulge spectra (tau proportional to distance).") bulge_image_pad, disk_image_pad = create_model_images(norm_model, imshape_pad, PSF=None) bulge_r = get_bulge_distance(imshape_pad, norm_model) bulge_ifs_pad = np.empty(ifsshape_pad) tau_image_pad = np.empty(imshape_pad) for i in xrange(imshape_pad[0]): for j in xrange(imshape_pad[1]): r = bulge_r[i, j] tau = tau_r(args.tau0, args.dtau_dr, r) if tau <= 1e-20: tau = 1e-20 tau_image_pad[i, j] = tau bulge_sfh = SyntheticSFH(base.ageBase) bulge_sfh.addExp(base.ageBase.max(), tau, 1.0) bulge_spec = (f_ssp * bulge_sfh.massVector()[:, np.newaxis]).sum(axis=1).sum(axis=0) bulge_spec /= np.median(bulge_spec[wl_norm_window]) bulge_ifs_pad[:, i, j] = bulge_spec * (args.fluxUnit * bulge_image_pad[np.newaxis, i, j]) logger.info("Creating disk spectra.") disk_sfh = SyntheticSFH(base.ageBase) disk_sfh.addSquare(0.0, 14e9, 1.0) disk_spec = (f_ssp * disk_sfh.massVector()[:, np.newaxis]).sum(axis=1).sum(axis=0) disk_spec /= np.median(disk_spec[wl_norm_window]) logger.info("Creating IFS.") disk_ifs_pad = disk_spec[..., np.newaxis, np.newaxis] * (args.fluxUnit * disk_image_pad) full_ifs_pad = bulge_ifs_pad + disk_ifs_pad
########## ################################################################################ logger.setLevel(-1) args = parse_args() pdf = plot_setup(args.plotFile) logger.info('Loading base %s', path.basename(args.baseFile)) t1 = time.clock() base = StarlightBase(args.baseFile, args.baseDir) l_ssp = np.arange(base.l_ssp.min(), base.l_ssp.max(), 2.0) logger.info('Took %.2f seconds to read the base (%d files)' % (time.clock() - t1, base.sspfile.size)) wl_norm_window = (base.l_ssp < 5680.0) & (base.l_ssp > 5590.0) logger.info('Computing synthetic SFH and their spectra.') bulge_sfh = SyntheticSFH(base.ageBase) bulge_sfh.addExp(14e9, 2.0e9, 1.0) bulge_flux = (base.f_ssp * bulge_sfh.massVector()[:, np.newaxis]).sum(axis=1).sum(axis=0) bulge_flux /= np.median(bulge_flux[wl_norm_window]) bulge_flux = spec_resample(base.l_ssp, l_ssp, bulge_flux) disk_sfh = SyntheticSFH(base.ageBase) #disk_sfh.addExp(10e9, 2.0e9, 1.0) disk_sfh.addSquare(0.0, 14e9, 1.0) disk_flux = (base.f_ssp * disk_sfh.massVector()[:, np.newaxis]).sum(axis=1).sum(axis=0) disk_flux /= np.median(disk_flux[wl_norm_window]) disk_flux = spec_resample(base.l_ssp, l_ssp, disk_flux) logger.debug('Plotting SFH.') fig = plt.figure(figsize=(8,6)) gs = plt.GridSpec(2, 1, height_ratios=[1.0, 1.0])
def get_synth_sfh(t0, tau, ages, dt=0.5e9): sfh = SyntheticSFH(ages) sfh.addExp(t0, tau, 1.0) return sfh.massVector()