|
1 | 1 | import importlib.metadata |
2 | 2 | import json |
3 | | -import warnings |
4 | 3 | from copy import copy |
5 | 4 | from pathlib import Path |
6 | 5 |
|
@@ -212,11 +211,15 @@ def get_package_info(package_names, metadata=None): |
212 | 211 |
|
213 | 212 |
|
214 | 213 | def get_density_from_cloud(sample_composition, mp_token=""): |
215 | | - """Function to get material density from the MP database. |
| 214 | + """Function to get material density from the MP or COD database. |
216 | 215 |
|
217 | 216 | It is not implemented yet. |
218 | 217 | """ |
219 | | - raise NotImplementedError |
| 218 | + raise NotImplementedError( |
| 219 | + "So sorry, density computation from composition is not implemented right now. " |
| 220 | + "We hope to have this implemented in the next release. " |
| 221 | + "Please rerun specifying a sample mass density." |
| 222 | + ) |
220 | 223 |
|
221 | 224 |
|
222 | 225 | def compute_mu_using_xraydb(sample_composition, energy, sample_mass_density=None, packing_fraction=None): |
@@ -250,15 +253,8 @@ def compute_mu_using_xraydb(sample_composition, energy, sample_mass_density=None |
250 | 253 | "You must specify either sample_mass_density or packing_fraction, but not both. " |
251 | 254 | "Please rerun specifying only one." |
252 | 255 | ) |
253 | | - if packing_fraction is None: |
254 | | - packing_fraction = 1 |
255 | | - try: |
256 | | - sample_mass_density = get_density_from_cloud(sample_composition) * packing_fraction |
257 | | - except NotImplementedError: |
258 | | - warnings.warn( |
259 | | - "Density computation is not implemented right now. " |
260 | | - "Please rerun specifying a sample mass density." |
261 | | - ) |
| 256 | + if packing_fraction is not None: |
| 257 | + sample_mass_density = get_density_from_cloud(sample_composition) * packing_fraction |
262 | 258 | energy_eV = energy * 1000 |
263 | 259 | mu = material_mu(sample_composition, energy_eV, density=sample_mass_density, kind="total") / 10 |
264 | 260 | return mu |
0 commit comments