def test_intensity_black_body(clib, nu, T):
    func = clib.intensity_black_body
    func.restype = c_double
    func.argtypes = [c_double, c_double]
    actual = func(nu, T)
    expected = intensity_black_body(nu, T)
    ntest.assert_almost_equal(
            actual,
            expected
            )
 def setup(self):
     self.nlte_species=[(2,0),(2,1)]
     self.nlte_config = ConfigurationNameSpace({'species':self.nlte_species})
     self.atom_data = atomic.AtomData.from_hdf5(helium_test_db)
     self.plasma = plasma_array.BasePlasmaArray.from_abundance(
         {'He':1.0}, 1e-15*u.Unit('g/cm3'), self.atom_data, 10 * u.day,
         nlte_config=self.nlte_config)
     self.plasma.j_blues = 0.5 * pd.DataFrame(intensity_black_body(self.atom_data.lines.nu.values[np.newaxis].T, np.array([10000.])))
     self.plasma.tau_sobolevs = pd.DataFrame(np.zeros_like(self.plasma.j_blues))
     self.plasma.t_rads=np.array([10000.])
     self.plasma.t_electrons=np.array([9000.])
     self.plasma.ws=np.array([0.5])
     self.plasma.electron_densities=pd.Series([1.e9])
     self.plasma.ion_populations = ion_populations
     self.plasma.calculate_nlte_level_populations()
Exemple #3
0
    def calculate(self, lines, nu, t_rad, w, j_blues_norm_factor,
                  j_blue_estimator):
        # Used for initialization
        if len(j_blue_estimator) == 0:
            return JBluesDiluteBlackBody.calculate(lines, nu, t_rad, w)
        else:
            j_blues = pd.DataFrame(
                j_blue_estimator *
                j_blues_norm_factor.value,
                index=lines.index,
                columns=np.arange(len(t_rad)))

            for i in xrange(len(t_rad)):
                zero_j_blues = j_blues[i] == 0.0
                j_blues[i][zero_j_blues] = (
                    self.w_epsilon *
                    intensity_black_body(nu[zero_j_blues].values,
                                         t_rad[i]))
            return j_blues
Exemple #4
0
 def calculate(lines, nu, t_rad, w):
     j_blues = w * intensity_black_body(nu.values[np.newaxis].T, t_rad)
     j_blues = pd.DataFrame(j_blues, index=lines.index,
                            columns=np.arange(len(t_rad)))
     return j_blues
Exemple #5
0
def test_intensity_black_body(nu, t, i):
    assert float(intensity_black_body(nu, t)) == i