-
Notifications
You must be signed in to change notification settings - Fork 3
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 #109 from fact-project/units
Use astropy units consistently, fix spectral_index madness
- Loading branch information
Showing
6 changed files
with
176 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.19.1 | ||
0.20.0 |
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 |
---|---|---|
@@ -1,12 +1,28 @@ | ||
import astropy.units as u | ||
from pytest import approx, raises | ||
|
||
|
||
def test_proton_obstime(): | ||
from fact.analysis.statistics import calc_proton_obstime | ||
n_simulated = 780046520 | ||
t = calc_proton_obstime( | ||
n_events=n_simulated, | ||
spectral_index=2.7, | ||
max_impact=400, | ||
viewcone=5, | ||
e_min=100, | ||
e_max=200e3, | ||
spectral_index=-2.7, | ||
max_impact=400 * u.m, | ||
viewcone=5 * u.deg, | ||
e_min=100 * u.GeV, | ||
e_max=200 * u.TeV, | ||
) | ||
assert int(t) == 15397 | ||
assert t.to(u.s).value == approx(15397.82) | ||
|
||
|
||
def test_power(): | ||
from fact.analysis.statistics import random_power | ||
|
||
a = random_power(-2.7, e_min=5 * u.GeV, e_max=10 * u.TeV, size=1000) | ||
|
||
assert a.shape == (1000, ) | ||
assert a.unit == u.TeV | ||
|
||
with raises(ValueError): | ||
random_power(2.7, 5 * u.GeV, 10 * u.GeV, e_ref=1 * u.GeV, size=1) |
Oops, something went wrong.