Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomic/fix reprepare #178

Merged
merged 3 commits into from
Aug 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tardis/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def prepare_atom_data(self, selected_atomic_numbers, line_interaction_type='scat
self.selected_atomic_numbers = selected_atomic_numbers

self.nlte_species = nlte_species

self._levels = self._levels.reset_index()
self._levels = self._levels[self._levels['atomic_number'].isin(self.selected_atomic_numbers)]
if max_ion_number is not None:
self._levels = self._levels[self._levels['ion_number'] <= max_ion_number]
Expand Down
16 changes: 16 additions & 0 deletions tardis/tests/test_atomic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from tardis import atomic
from numpy import testing
import pytest
import os

def test_atomic_h5_readin():
data = atomic.read_basic_atom_data(atomic.default_atom_h5_path)
Expand All @@ -26,3 +27,18 @@ def test_atomic_symbol():

def test_atomic_symbol_reverse():
assert atomic.symbol2atomic_number['Si'] == 14

@pytest.mark.skipif(not pytest.config.getvalue("atomic-dataset"),
reason='--atomic_database was not specified')
def test_atomic_reprepare():
atom_data_filename = os.path.expanduser(os.path.expandvars(
pytest.config.getvalue('atomic-dataset')))
assert os.path.exists(atom_data_filename), ("{0} atomic datafiles "
"does not seem to "
"exist".format(
atom_data_filename))
atom_data = atomic.AtomData.from_hdf5(atom_data_filename)
atom_data.prepare_atom_data([14])
atom_data.prepare_atom_data([20])