-
-
Notifications
You must be signed in to change notification settings - Fork 409
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
Dilution factor fix #956
Merged
Merged
Dilution factor fix #956
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
from tardis.io.util import HDFWriterMixin | ||
from tardis.io.decay import IsotopeAbundances | ||
from tardis.model.density import HomologousDensity | ||
from pyne import nucname | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
@@ -498,6 +499,9 @@ def from_csvy(cls, config): | |
Radial1DModel | ||
|
||
""" | ||
CSVY_SUPPORTED_COLUMNS = {'velocity', 'density', 't_rad', 'dilution_factor'} | ||
|
||
|
||
if os.path.isabs(config.csvy_model): | ||
csvy_model_fname = config.csvy_model | ||
else: | ||
|
@@ -507,9 +511,23 @@ def from_csvy(cls, config): | |
base_dir = os.path.abspath(os.path.dirname(__file__)) | ||
schema_dir = os.path.join(base_dir, '..', 'io', 'schemas') | ||
csvy_schema_file = os.path.join(schema_dir, 'csvy_model.yml') | ||
csvy_model_config = Configuration(validate_dict(csvy_model_config, | ||
csvy_model_config = Configuration(validate_dict(csvy_model_config, | ||
schemapath=csvy_schema_file)) | ||
|
||
if hasattr(csvy_model_data, 'columns'): | ||
abund_names = set([name for name in csvy_model_data.columns | ||
if nucname.iselement(name) or nucname.isnuclide(name)]) | ||
unsupported_columns = set(csvy_model_data.columns) - abund_names - CSVY_SUPPORTED_COLUMNS | ||
|
||
field_names = set([field['name'] for field in csvy_model_config.datatype.fields]) | ||
assert set(csvy_model_data.columns) - field_names == set(),\ | ||
'CSVY columns exist without field descriptions' | ||
assert field_names - set(csvy_model_data.columns) == set(),\ | ||
'CSVY field descriptions exist without corresponding csv data' | ||
if unsupported_columns != set(): | ||
logger.warning("The following columns are specified in the csvy" | ||
"model file, but are IGNORED by TARDIS: %s"%(str(unsupported_columns))) | ||
|
||
time_explosion = config.supernova.time_explosion.cgs | ||
|
||
electron_densities = None | ||
|
@@ -562,8 +580,8 @@ def from_csvy(cls, config): | |
|
||
dilution_factor = None | ||
if hasattr(csvy_model_data, 'columns'): | ||
if 'w' in csvy_model_data.columns: | ||
dilution_factor = csvy_model_data['w'].iloc[0:].to_numpy() | ||
if 'dilution_factor' in csvy_model_data.columns: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wkerzendorf is this what you meant by "shifting the dilution factor into the code?" This is the change that loads the given dilution factor profile into the csvy model. |
||
dilution_factor = csvy_model_data['dilution_factor'].iloc[0:].to_numpy() | ||
|
||
elif config.plasma.initial_t_rad > 0 * u.K: | ||
t_radiative = np.ones(no_of_shells) * config.plasma.initial_t_rad | ||
|
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.