diff --git a/tardis/plasma_array.py b/tardis/plasma_array.py index 17f94953129..ecddb932d9b 100644 --- a/tardis/plasma_array.py +++ b/tardis/plasma_array.py @@ -374,8 +374,12 @@ def calculate_saha_nebular(self, delta=None): try: zeta = interpolate.interp1d(zeta_data.columns.values, zeta_data.ix[phis.index].values)(self.t_rads) except ValueError: - raise ValueError('Outside of interpolation area %s' % self.t_rads) - finally: + raise ValueError('t_rads outside of zeta factor interpolation' + ' zeta_min={0:.2f} zeta_max={1:.2f} ' + '- requested {2}'.format( + zeta_data.columns.values.min(), zeta_data.columns.values.max(), + self.t_rads)) + else: # fixing missing nan data # issue created - fix with warning some other day zeta[np.isnan(zeta)] = 1.0 diff --git a/tardis/tests/test_plasma.py b/tardis/tests/test_plasma_nlte.py similarity index 99% rename from tardis/tests/test_plasma.py rename to tardis/tests/test_plasma_nlte.py index 6837d295dd5..2ce54802d14 100644 --- a/tardis/tests/test_plasma.py +++ b/tardis/tests/test_plasma_nlte.py @@ -34,11 +34,11 @@ def pytest_generate_tests(metafunc): metafunc.parametrize(argnames, [[funcargs[name] for name in argnames] for funcargs in funcarglist]) -class TestNLTELTEApproximtion(object): +class TestNLTELTEApproximation(object): params = {"test_He_ltelevelpops" : [dict(ion_number = 0), dict(ion_number = 1)]} - + def setup(self): self.nlte_species=[(2,0),(2,1)] self.nlte_config = TARDISConfigurationNameSpace({'species': @@ -100,3 +100,5 @@ def test_He_dilutelevelpops(self, dummy): def test_He_dilutelevelpops_isnotLTE(self, ion_number): lte_pops = self.atom_data.levels["g"].ix[(2,ion_number)].values * np.exp(- self.atom_data.levels["energy"].ix[(2,ion_number)].values * u.erg / const.k_B / self.plasma.t_rads / u.K).value assert not np.allclose(lte_pops, self.atom_data.levels["g"].ix[(2,ion_number)][0]*self.plasma.level_populations[0].ix[(2,ion_number)].values, atol=0) + + diff --git a/tardis/tests/test_plasma_simple.py b/tardis/tests/test_plasma_simple.py new file mode 100644 index 00000000000..1076acb8139 --- /dev/null +++ b/tardis/tests/test_plasma_simple.py @@ -0,0 +1,24 @@ +from astropy import constants as const, units as u +import os +import tardis +from tardis import plasma_array, atomic +import pytest +#from numpy.testing import assert_allclose +data_path = os.path.join(tardis.__path__[0], 'tests', 'data') +helium_test_db = os.path.join(data_path, 'chianti_he_db.h5') + + +class TestNebularPlasma(object): + + def setup(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'), atom_data, 10 * u.day, + ionization_mode='nebular', excitation_mode='dilute-lte') + + def test_high_temperature(self): + with pytest.raises(ValueError) as excinfo: + self.plasma.update_radiationfield([100000.], [1.]) + + assert excinfo.value.message.startswith('t_rads outside of zeta ' + 'factor interpolation') \ No newline at end of file