def predict_c_one(theta, age): # Time, tq and tau are in units of Gyrs t = N.linspace(0,14.0,100) tq, tau = theta sfr = expsfh(tau, tq, t) nuv_u = N.zeros_like(sfr) u_r = N.zeros_like(sfr) # Work out total flux at each time given the sfh model of tau and tq (calls assign_fluxes function) # The total_flux array has time_steps as the rows (y) and model_lambda along the columns(x) total_flux = assign_fluxes.assign_total_flux(data[0,1:], data[1:,0], data[1:,1:], t*1E9, sfr) # Calculate fluxes from the flux at all times then interpolate to get one colour for the age you are observing the galaxy at - if many galaxies are being observed, this also works with an array of ages to give back an array of colours nuv_u, u_r = get_colours(t*1E9, total_flux, data) nuv_u_age = N.interp(age, t, nuv_u) u_r_age = N.interp(age, t, u_r) return nuv_u_age, u_r_age
def predict_c_one(theta, age): # Time, tq and tau are in units of Gyrs time = N.arange(0, 0.01, 0.003) t = N.linspace(0,14.0,100) t = N.append(time, t[1:]) tq, tau = theta sfr = expsfh(tau, tq, t) nuv_u = N.zeros_like(sfr) u_r = N.zeros_like(sfr) # Work out total flux at each time given the sfh model of tau and tq (calls assign_fluxes function) total_flux, masses = assign_fluxes.assign_total_flux(data[0,1:], data[1:,0], data[1:,1:], t*1E9, sfr) # Calculate fluxes from the flux at all times then interpolate to get one colour for the age you are observing the galaxy at - if many galaxies are being observed, this also works with an array of ages to give back an array of colours nuv_u, u_r, rmag = get_colours(t*1E9, total_flux, data) nuv_u_age = N.interp(age, t, nuv_u) u_r_age = N.interp(age, t, u_r) rmag_age = N.interp(age, t, rmag) mass = N.interp(age, t, masses) return nuv_u_age, u_r_age, rmag_age, mass
def predict_colour_for_loop(tq, tau, z): cosmo = FlatLambdaCDM(H0 = 71.0, Om0 = 0.26) age = cosmo.age(z) print age #time = N.arange(0, 0.01, 0.003) #t = N.arange(0, 13.7, 0.01) #time = N.append(time, t[1:]) time = N.arange(28.0)/2.0 dir ='/Users/becky/Projects/Green-Valley-Project/bc03/models/Padova1994/chabrier/ASCII/' model = 'extracted_bc2003_lr_m62_chab_ssp.ised_ASCII' data = N.loadtxt(dir+model) sfr = N.zeros(len(time)*len(tq)*len(tau)).reshape(len(time), len(tq), len(tau)) nuv_u = N.zeros_like(sfr) u_r = N.zeros_like(sfr) nuv_u_age = N.zeros(len(age)*len(tq)*len(tau)).reshape(len(age),len(tq), len(tau)) u_r_age = N.zeros_like(nuv_u_age) for m in range(len(tq)): for n in range(len(tau)): sfr[:,m,n] = expsfh(tau[n], tq[m], time) total_flux = assign_fluxes.assign_total_flux(data[0,1:], data[1:,0], data[1:,1:], time*1E9, sfr[:,m,n]) nuv_u[:,m,n], u_r[:,m,n] = get_colours(total_flux, data) nuv_u_age[:,m,n] = N.interp(age, time, nuv_u[:,m,n]) u_r_age[:,m,n] = N.interp(age, time, u_r[:,m,n]) return nuv_u_age, u_r_age