def test_blackbody(): def bb(w, T): c = 2.99792458e8 h = 6.626068e-34 k = 1.380658e-23 nu = c/w return 2*h*nu**3/c**2 / (np.exp(h*nu/(k*T))-1) w = np.arange(90., 111) * 1e-6 T = 15. flux = bb(w, T) / bb(100e-6, T) ops = [BlackBodyOperator(T, wavelength=wave, wavelength0=100e-6) for wave in w] flux2 = [op(1.) for op in ops] assert all_eq(flux, flux2) w, T = np.ogrid[90:111, 15:20] w = w * 1.e-6 flux = bb(w, T) / bb(100e-6, T) ops = [BlackBodyOperator(T.squeeze(), wavelength=wave[0], wavelength0=100e-6) for wave in w] flux2 = np.array([op(np.ones(T.size)) for op in ops]) assert all_eq(flux, flux2)
def test_blackbody(): def bb(w, T): c = 2.99792458e8 h = 6.626068e-34 k = 1.380658e-23 nu = c / w return 2 * h * nu**3 / c**2 / (np.exp(h * nu / (k * T)) - 1) w = np.arange(90., 111) * 1e-6 T = 15. flux = bb(w, T) / bb(100e-6, T) ops = [ BlackBodyOperator(T, wavelength=wave, wavelength0=100e-6) for wave in w ] flux2 = [op(1.) for op in ops] assert all_eq(flux, flux2) w, T = np.ogrid[90:111, 15:20] w = w * 1.e-6 flux = bb(w, T) / bb(100e-6, T) ops = [ BlackBodyOperator(T.squeeze(), wavelength=wave[0], wavelength0=100e-6) for wave in w ] flux2 = np.array([op(np.ones(T.size)) for op in ops]) assert all_eq(flux, flux2)
def func(alpha): expected = (nu/nu0)**alpha * values op = PowerLawOperator(alpha, nu, nu0) assert all_eq(op(values), expected)
def func(alpha): expected = (nu / nu0)**alpha * values op = PowerLawOperator(alpha, nu, nu0) assert all_eq(op(values), expected)