def double_beta_dust_FGB_Model(units='K_CMB'): H_OVER_K = constants.h * 1e9 / constants.k # Conversion factor at frequency nu K_RJ2K_CMB = ('(expm1(h_over_k * nu / Tcmb)**2' '/ (exp(h_over_k * nu / Tcmb) * (h_over_k * nu / Tcmb)**2))') K_RJ2K_CMB = K_RJ2K_CMB.replace('Tcmb', str(Planck15.Tcmb(0).value)) K_RJ2K_CMB = K_RJ2K_CMB.replace('h_over_k', str(H_OVER_K)) K_RJ2K_CMB_NU0 = K_RJ2K_CMB + ' / ' + K_RJ2K_CMB.replace('nu', 'nu0') analytic_expr1 = ( '(exp(nu0 / temp * h_over_k) - 1)' '/ (exp(nu / temp * h_over_k) - 1)' '* (nu / nu0)**(1 + beta_d0) * (nu0 / nubreak)**(beta_d0-beta_d1) * (1-(0.5 + 0.5*tanh((nu-nubreak)*500)))' ) #' * (1-heaviside(nu-nubreak ,0.5))') analytic_expr2 = ( '(exp(nu0 / temp * h_over_k) - 1)' '/ (exp(nu / temp * h_over_k) - 1)' '* (nu / nu0)**(1 + beta_d1) * (0.5 + 0.5*tanh((nu-nubreak)*500))' ) #' * heaviside(nu-nubreak,0.5)') #analytic_expr = (analytic_expr1 + ' + ' + analytic_expr2) if 'K_CMB' in units: #analytic_expr += ' * ' + K_RJ2K_CMB_NU0 #pass analytic_expr = analytic_expr1 + ' * ' + K_RJ2K_CMB_NU0 + ' + ' + analytic_expr2 + ' * ' + K_RJ2K_CMB_NU0 elif 'K_RJ' in units: #pass analytic_expr = (analytic_expr1 + ' + ' + analytic_expr2) else: raise ValueError("Unsupported units: %s" % units) return analytic_expr
def __init__(self, units='uK_CMB'): # Prepare the analytic expression x_nu = '(nu * h_over_k / Tcmb)' analytic_expr = 'Tcmb * (x_nu * (exp(x_nu) + 1) / expm1(x_nu) - 4)' analytic_expr = analytic_expr.replace('x_nu', x_nu) if 'K_CMB' in units: pass elif 'K_RJ' in units: analytic_expr += ' / ' + K_RJ2K_CMB else: raise ValueError("Unsupported units: %s" % units) if units[0] == 'u': analytic_expr = '1e6 * ' + analytic_expr elif units[0] == 'm': analytic_expr = '1e3 * ' + analytic_expr kwargs = dict(Tcmb=Planck15.Tcmb(0).value, h_over_k=H_OVER_K) super(ThermalSZ, self).__init__(analytic_expr, **kwargs)
def double_beta_dust_FGB_Model(): H_OVER_K = constants.h * 1e9 / constants.k # Conversion factor at frequency nu K_RJ2K_CMB = ('(expm1(h_over_k * nu / Tcmb)**2' '/ (exp(h_over_k * nu / Tcmb) * (h_over_k * nu / Tcmb)**2))') K_RJ2K_CMB = K_RJ2K_CMB.replace('Tcmb', str(Planck15.Tcmb(0).value)) K_RJ2K_CMB = K_RJ2K_CMB.replace('h_over_k', str(H_OVER_K)) K_RJ2K_CMB_NU0 = K_RJ2K_CMB + ' / ' + K_RJ2K_CMB.replace('nu', 'nu0') analytic_expr1 = ('(exp(nu0 / temp * h_over_k) -1)' '/ (exp(nu / temp * h_over_k) - 1)' '* (nu / nu0)**(1 + beta_d0) * (nu0 / nubreak)**(beta_d0-beta_d1) * '+K_RJ2K_CMB_NU0 + '* (1-heaviside(nu-nubreak,0.5))') analytic_expr2 = ('(exp(nu0 / temp * h_over_k) -1)' '/ (exp(nu / temp * h_over_k) - 1)' '* (nu / nu0)**(1 + beta_d1) * '+K_RJ2K_CMB_NU0 + '* heaviside(nu-nubreak,0.5)') analytic_expr = analytic_expr1 + ' + ' + analytic_expr2 return analytic_expr
'Dust', 'Synchrotron', 'ModifiedBlackBody', 'PowerLaw', 'FreeFree', ] lambdify = lambda x, y: sympy.lambdify(x, y, 'numpy') H_OVER_K = constants.h * 1e9 / constants.k # Conversion factor at frequency nu K_RJ2K_CMB = ('(expm1(h_over_k * nu / Tcmb)**2' '/ (exp(h_over_k * nu / Tcmb) * (h_over_k * nu / Tcmb)**2))') K_RJ2K_CMB = K_RJ2K_CMB.replace('Tcmb', str(Planck15.Tcmb(0).value)) K_RJ2K_CMB = K_RJ2K_CMB.replace('h_over_k', str(H_OVER_K)) # Conversion factor at frequency nu divided by the one at frequency nu0 K_RJ2K_CMB_NU0 = K_RJ2K_CMB + ' / ' + K_RJ2K_CMB.replace('nu', 'nu0') def bandpass_integration(f): ''' Decorator for bandpass integration Parameters ---------- f: callable Function to evaluate an SED. Its first argument must be a frequency array. The other positional or keyword arguments are arbitrary.