-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a ValueError if trying to extrapolate and update to documentati…
…on (#41) * added example to illustrate interpolation of edges * added info about interpolation and custom materials * added info on energy range for NIST data * typo on energy range * change to error if outside energy range * Update CHANGELOG.rst * black reformat * changed ranges to remove now ValueErrors * Update docs/examples/tutorial1b.rst Co-authored-by: Shane Maloney <shane.maloney@dias.ie> Co-authored-by: Shane Maloney <shane.maloney@dias.ie>
- Loading branch information
Showing
8 changed files
with
220 additions
and
9 deletions.
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
File renamed without changes.
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,92 @@ | ||
Edges in the Mass Attenuation Coefficient and Interpolation | ||
=========================================================== | ||
|
||
Some elements have complex features in their mass attentuation coefficients. | ||
The mass attenuation coefficients are interpolated between data points so be careful to include sufficient points to resolve those features if you are looking for high accuracy. | ||
|
||
.. plot:: | ||
:include-source: | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
import astropy.units as u | ||
from astropy.visualization import quantity_support | ||
quantity_support() | ||
from roentgen.absorption import MassAttenuationCoefficient | ||
|
||
cdte_atten = MassAttenuationCoefficient('cdte') | ||
|
||
energy = u.Quantity(np.arange(3, 6, 0.1), 'keV') | ||
atten = cdte_atten.func(energy) | ||
|
||
plt.plot(energy, atten) | ||
plt.plot(cdte_atten.energy, cdte_atten.data, 'o') | ||
plt.yscale('log') | ||
plt.xscale('log') | ||
plt.ylim(300, 1000) | ||
plt.xlim(3, 6) | ||
plt.xlabel('Energy [' + str(energy.unit) + ']') | ||
plt.ylabel('Mass attenuation Coefficient [' + str(atten.unit) + ']') | ||
plt.title(cdte_atten.name + ' undersampling!') | ||
plt.show() | ||
|
||
The above example is clearly undersampled. Let's add better sampling. | ||
|
||
.. plot:: | ||
:include-source: | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
import astropy.units as u | ||
from astropy.visualization import quantity_support | ||
quantity_support() | ||
from roentgen.absorption import MassAttenuationCoefficient | ||
|
||
cdte_atten = MassAttenuationCoefficient('cdte') | ||
|
||
energy = u.Quantity(np.arange(3, 6, 0.01), 'keV') | ||
atten = cdte_atten.func(energy) | ||
|
||
plt.plot(energy, atten) | ||
plt.plot(cdte_atten.energy, cdte_atten.data, 'o') | ||
plt.yscale('log') | ||
plt.xscale('log') | ||
plt.ylim(300, 1000) | ||
plt.xlim(3, 6) | ||
plt.xlabel('Energy [' + str(energy.unit) + ']') | ||
plt.ylabel('Mass attenuation Coefficient [' + str(atten.unit) + ']') | ||
plt.title(cdte_atten.name + ' better sampling!') | ||
plt.show() | ||
|
||
This looks much better! Though if we look very closely, we see that we are still undersampling. | ||
|
||
.. plot:: | ||
:include-source: | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
import astropy.units as u | ||
from astropy.visualization import quantity_support | ||
quantity_support() | ||
from roentgen.absorption import MassAttenuationCoefficient | ||
|
||
cdte_atten = MassAttenuationCoefficient('cdte') | ||
|
||
energy = u.Quantity(np.arange(3, 6, 0.01), 'keV') | ||
atten = cdte_atten.func(energy) | ||
|
||
plt.plot(energy, atten) | ||
plt.plot(cdte_atten.energy, cdte_atten.data, 'o') | ||
plt.yscale('log') | ||
plt.xscale('log') | ||
plt.ylim(600, 900) | ||
plt.xlim(3.95, 4.1) | ||
plt.xlabel('Energy [' + str(energy.unit) + ']') | ||
plt.ylabel('Mass attenuation Coefficient [' + str(atten.unit) + ']') | ||
plt.title(cdte_atten.name + ' still undersampled') | ||
plt.show() | ||
|
||
For many calculations, this small difference may not matter. |
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