-
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.
Merge pull request #25 from ehsteve/bug_fix
Bug fix
- Loading branch information
Showing
6 changed files
with
72 additions
and
5 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
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,26 @@ | ||
Checking on edges in the Mass Attenuation Coefficient | ||
===================================================== | ||
|
||
.. 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 | ||
|
||
e = np.linspace(1e-3, 1e-2, 1000)*u.MeV | ||
te = MassAttenuationCoefficient('Te') | ||
plt.plot(e, te.func(e), 'x', label='Interpolated') | ||
plt.plot(te.energy, te.data, color='black', label='Data') | ||
plt.loglog() | ||
plt.xlim(4e-3, 6e-3) | ||
plt.ylim(1e2, 1e3) | ||
plt.xlabel('Photon Energy (MeV)') | ||
plt.ylabel(r'$\mu / \rho$ (cm$^{2}$ g$^{-1}$)') | ||
plt.title('Te') | ||
plt.legend() | ||
plt.show() |
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,18 @@ | ||
import pytest | ||
|
||
from numpy.testing import assert_allclose | ||
|
||
import astropy.units as u | ||
|
||
from roentgen.absorption.material import MassAttenuationCoefficient | ||
|
||
|
||
def test_interpolate_matches_at_data(): | ||
for this_element in ['Te', 'Si', 'Ge', 'cdte']: | ||
te = MassAttenuationCoefficient(this_element) | ||
assert_allclose(te.data, te.func(te.energy)) | ||
|
||
# now change one point and make sure it no longer works | ||
te.energy[0] = 10 * u.keV | ||
with pytest.raises(AssertionError): | ||
assert_allclose(te.data, te.func(te.energy)) |