def ionization_from_luminosity(z, ratedensityfunc, xHe=1.0, rate_is_tfunc = False, ratedensityfunc_args = (), method = 'romberg', **cosmo): """Integrate the ionization history given an ionizing luminosity function, ignoring recombinations. Parameters ---------- ratedensityfunc: callable function giving comoving ionizing photon emission rate density, or ionizing emissivity (photons s^-1 Mpc^-3) as a function of redshift (or time). rate_is_tfunc: boolean Set to true if ratedensityfunc is a function of time rather than z. Notes ----- Ignores recombinations. The ionization rate is computed as ratedensity / nn, where nn = nH + xHe * nHe. So if xHe is 1.0, we are assuming that helium becomes singly ionized at proportionally the same rate as hydrogen. If xHe is 2.0, we are assuming helium becomes fully ionizing at proportionally the same rate as hydrogen. The returened x is therefore the ionized fraction of hydrogen, and the ionized fraction of helium is xHe * x. """ cosmo = cd.set_omega_k_0(cosmo) rhoc, rho0, nHe, nH = cden.baryon_densities(**cosmo) nn = (nH + xHe * nHe) if rate_is_tfunc: t = cd.age(z, **cosmo)[0] def dx_dt(t1): return numpy.nan_to_num(ratedensityfunc(t1, *ratedensityfunc_args) / nn) sorti = numpy.argsort(t) x = numpy.empty(t.shape) x[sorti] = cu.integrate_piecewise(dx_dt, t[sorti], method = method) return x else: dt_dz = lambda z1: cd.lookback_integrand(z1, **cosmo) def dx_dz(z1): z1 = numpy.abs(z1) return numpy.nan_to_num(dt_dz(z1) * ratedensityfunc(z1, *ratedensityfunc_args) / nn) sorti = numpy.argsort(-z) x = numpy.empty(z.shape) x[sorti] = cu.integrate_piecewise(dx_dz, -z[sorti], method = method) return x
from califa_cmap import califa_vel, califa_int from congrid import congrid import make_2d_gaussian as make_gauss import scipy.signal import sys # -------------------------- A few ideas: #1: Signal to noise degradation: should I just add Poisson noise after convolution? #2: PSF: deconvolution #3: redshifting: changes in spectral sampling (resolution) #4: Various binning scenarios #2: Set exposure time as free variable, depending on S/N cosmo = {'omega_M_0':0.3, 'omega_lambda_0':0.7, 'omega_k_0':0.0, 'h':0.7} cosmo = cosmology.set_omega_k_0(cosmo) def get_magnification(z_in, z_out): #calculate ratio of linear dimensions lumdist_in = cosmology.luminosity_distance(z_in, **cosmo) lumdist_out = cosmology.luminosity_distance(z_out, **cosmo) # print lumdist_in magnification = (lumdist_in/lumdist_out) *((1.+z_out)**2/(1.+z_in)**2) #*(p_hi/p_lo))[0] -- we assume pixel scale is the same return magnification def get_scaled_flux(cube, z_out): flux_ratio = (1+z_out)**4 return cube/flux_ratio ### START rfits_img