-
Notifications
You must be signed in to change notification settings - Fork 22
compute mu #278
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
compute mu #278
Changes from 1 commit
5180eeb
5ff2c23
1826221
e54f9bb
be7c275
9e4bc0d
1879f44
a108205
0bdbbb4
00f36ad
255c603
5492ad8
a4a217d
953e187
dd52ad9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,6 +211,14 @@ def get_package_info(package_names, metadata=None): | |
return metadata | ||
|
||
|
||
def get_density_from_cloud(sample_composition, mp_token=""): | ||
"""Function to get material density from the MP database. | ||
|
||
It is not implemented yet. | ||
""" | ||
raise NotImplementedError | ||
|
||
|
||
def compute_mu_using_xraydb(sample_composition, energy, sample_mass_density=None, packing_fraction=None): | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""Compute the attenuation coefficient (mu) using the XrayDB database. | ||
|
||
|
@@ -242,14 +250,15 @@ def compute_mu_using_xraydb(sample_composition, energy, sample_mass_density=None | |
"You must specify either sample_mass_density or packing_fraction, but not both. " | ||
"Please rerun specifying only one." | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
if sample_mass_density is not None: | ||
mu = material_mu(sample_composition, energy * 1000, density=sample_mass_density, kind="total") / 10 | ||
else: | ||
warnings.warn( | ||
"Warning: Density is set to None if a packing fraction is specified, " | ||
"which may cause errors for some materials. " | ||
"We recommend specifying sample mass density for now. " | ||
"Auto-density calculation is coming soon." | ||
) | ||
mu = material_mu(sample_composition, energy * 1000, density=None, kind="total") * packing_fraction / 10 | ||
if packing_fraction is None: | ||
packing_fraction = 1 | ||
try: | ||
sample_mass_density = get_density_from_cloud(sample_composition) * packing_fraction | ||
except NotImplementedError: | ||
sbillinge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
warnings.warn( | ||
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. I think this needs to be an error not a warning, no? We need to interrupt execution. Also, let's apologise... "So sorry, Density computation from composition is not implemented right now. We hope to have this implemented in the next release. Please rerun specifying a sample mass density. 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. Got it! I will add the COD database and change the error message |
||
"Density computation is not implemented right now. " | ||
"Please rerun specifying a sample mass density." | ||
) | ||
energy_eV = energy * 1000 | ||
mu = material_mu(sample_composition, energy_eV, density=sample_mass_density, kind="total") / 10 | ||
return mu |
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.
add new function - not implemented
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.
Do we want to also go to the COD database (doesn't require a token).