-
-
Notifications
You must be signed in to change notification settings - Fork 423
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
As simpler run_tardis
#205
Merged
wkerzendorf
merged 4 commits into
tardis-sn:master
from
wkerzendorf:general/run_tardis_enhancement
Dec 5, 2014
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
778f2e3
small restructure of run_tardis
wkerzendorf 6458a29
added new run_tardis to the tests and started some documentation
wkerzendorf 9279881
added some documentation how to use the new run_tardis
wkerzendorf 7be54f3
fixed premature import
wkerzendorf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#functions that are important for the general usage of TARDIS | ||
|
||
import yaml | ||
|
||
from tardis.io import config_reader | ||
from tardis import model, simulation, atomic | ||
|
||
|
||
def run_tardis(config, atom_data=None): | ||
""" | ||
This function is one of the core functions to run TARDIS from a given | ||
config object. | ||
|
||
It will return a model object containing | ||
|
||
Parameters | ||
---------- | ||
|
||
config: ~str or ~dict | ||
filename of configuration yaml file or dictionary | ||
|
||
atom_data: ~str or ~tardis.atomic.AtomData | ||
if atom_data is a string it is interpreted as a path to a file storing | ||
the atomic data. Atomic data to use for this TARDIS simulation. If set to None, the | ||
atomic data will be loaded according to keywords set in the configuration | ||
[default=None] | ||
""" | ||
|
||
try: | ||
config_dict = yaml.load(open(config)) | ||
except TypeError: | ||
config_dict = config | ||
|
||
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) | ||
radial1d_mdl = model.Radial1DModel(tardis_config) | ||
|
||
simulation.run_radial1d(radial1d_mdl) | ||
|
||
return radial1d_mdl |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mklauser You were interested in duck-typing. This is a classic example. You could do a type check to see if is as string, but one simply opts to give it to the python
open
command and then sees if it works. This means also unicode strings can work, or other things that open can read.