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

tardis/base.py: Remove duplicate code from run_tardis #574

Merged
merged 1 commit into from
May 30, 2016
Merged
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
24 changes: 9 additions & 15 deletions tardis/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#functions that are important for the general usage of TARDIS
# functions that are important for the general usage of TARDIS

def run_tardis(config, atom_data=None):
"""
Expand All @@ -19,29 +19,23 @@ def run_tardis(config, atom_data=None):
atomic data will be loaded according to keywords set in the configuration
[default=None]
"""
import yaml

from tardis.io import config_reader
from tardis import model, simulation, atomic
import os

try:
config_dict = yaml.load(open(config))
config_dirname = os.path.dirname(config)
except TypeError:
config_dict = config
config_dirname = ''

if atom_data is not None:
try:
atom_data = atomic.AtomData.from_hdf5(atom_data)
except TypeError:
atom_data = atom_data

tardis_config = config_reader.Configuration.from_config_dict(
config_dict, atom_data=atom_data, config_dirname=config_dirname)
radial1d_mdl = model.Radial1DModel(tardis_config)
try:
tardis_config = config_reader.Configuration.from_yaml(
config, atom_data=atom_data)
except TypeError:
tardis_config = config_reader.Configuration.from_config_dict(
config, atom_data=atom_data)

radial1d_mdl = model.Radial1DModel(tardis_config)
simulation.run_radial1d(radial1d_mdl)

return radial1d_mdl
return radial1d_mdl