sp.params['tau'] =0.3 sp.params['logzsol'] = np.log10(0.8) wave2, flux2 = sp.get_spectrum(tage = 4.25, peraa = True) mass_perc2 = sp.stellar_mass D_l = cosmo.luminosity_distance(specz).value # in Mpc conv = 3.086E24 lsol_to_fsol = 3.839E33 sim1.Make_sim(wave2, flux2 * 10**11* lsol_to_fsol / (4 * np.pi * (D_l*conv)**2), specz, perturb = False) ############ ###priors### agelim = Oldest_galaxy(specz) def delay_prior(u): m = (0.03 * u[0] + 0.001) / 0.019 a = (agelim - 0.01)* u[1] + 0.01 t = (1.5 - 0.001)*u[2] + 0.001 z = stats.norm.ppf(u[3],loc = specz, scale = 0.003) d = u[4] lm = stats.norm.ppf(u[5],loc = 10.75, scale = 0.5) return [m, a, t, z, d, lm] ############ #likelihood# def Gather_grism_sim_data(spec): wvs = []
mass_perc2 = sp.stellar_mass D_l = cosmo.luminosity_distance(specz).value # in Mpc conv = 3.086E24 lsol_to_fsol = 3.839E33 sim2.Make_sim(wave2, flux2 * 10**11* lsol_to_fsol / (4 * np.pi * (D_l*conv)**2), specz, rndstate = rndseed) #####RESET FSPS##### sp = fsps.StellarPopulation(imf_type = 2, tpagb_norm_type=0, zcontinuous = 1, logzsol = np.log10(1), sfh = 3, dust_type = 1) ############ ###priors### lages = [0,9.0,9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9] tuniv = Oldest_galaxy(specz) nbins = len(lages) - 1 tbinmax = (tuniv * 0.85) * 1e9 lim1, lim2 = 7.4772, 8.0 agelims = [0,lim1] + np.linspace(lim2,np.log10(tbinmax),nbins-2).tolist() + [np.log10(tuniv*1e9)] agebins = np.array([agelims[:-1], agelims[1:]]).T agelim = Oldest_galaxy(specz) def tab_prior(u): m = (0.03 * u[0] + 0.001) / 0.019 a = (agelim - 1)* u[1] + 1 tsamp = np.array([u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9], u[10], u[11]])
beam_path = '../beams/' data_path = '../data/' if __name__ == '__main__': field = sys.argv[1] galaxy = int(sys.argv[2]) rshift = float(sys.argv[3]) simZ = float(sys.argv[4]) simt = float(sys.argv[5]) simtau = float(sys.argv[6]) simz = float(sys.argv[7]) simd = float(sys.argv[8]) tau = np.round(np.logspace(-2, np.log10(3), 20), 3) age = np.round(np.arange(0.1, np.round(Oldest_galaxy(rshift), 1) + .05, .05), 2) metal = np.round(np.arange(0.002, 0.0305, 0.0005), 4) dust = np.arange(0, 1.05, 0.05) Fit_all_sim(field, galaxy, glob(beam_path + '*{0}*.g102.A.fits'.format(galaxy))[0], glob(beam_path + '*{0}*.g141.A.fits'.format(galaxy))[0], rshift, metal, age, tau, dust, simZ, simt, simtau,