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

Fix energy_resolution method in EnergyDispersion class #1133

Merged
merged 2 commits into from Sep 14, 2017

Conversation

Projects
None yet
3 participants
@lmohrmann
Contributor

lmohrmann commented Sep 14, 2017

The energy_resolution method in EnergyDispersion could only handle 1-dimensional inputs so far (see also #1132). With this PR, N-dimensional inputs are allowed:

import numpy as np
import astropy.units as u
from gammapy.irf import EnergyDispersion
e_true = np.logspace(-1, 2, 30) * u.TeV
e_reco = np.logspace(-2, 2, 20) * u.TeV
edisp = EnergyDispersion.from_gauss(e_true, e_reco)
print(edisp.get_resolution([[10, 20],[30, 40]] * u.TeV))
print(edisp.get_resolution(10*u.TeV))
print(edisp.get_resolution(20*u.TeV))
print(edisp.get_resolution(30*u.TeV))
print(edisp.get_resolution(40*u.TeV))

[[ 0.20902851  0.20850442]
 [ 0.20678505  0.19102049]]
0.209028510522
0.208504420638
0.206785053106
0.191020494988
@joleroi

This comment has been minimized.

Show comment
Hide comment
@joleroi

joleroi Sep 14, 2017

Contributor

Thanks @lmohrmann
In the end, it would be nice to have tests for all these functions, maybe you can also have a look at #1122

Regarding this PR is does not seem to break anything, so go ahead if you'd like to merge it

Contributor

joleroi commented Sep 14, 2017

Thanks @lmohrmann
In the end, it would be nice to have tests for all these functions, maybe you can also have a look at #1122

Regarding this PR is does not seem to break anything, so go ahead if you'd like to merge it

@lmohrmann

This comment has been minimized.

Show comment
Hide comment
@lmohrmann

lmohrmann Sep 14, 2017

Contributor

Merging this now, although I agree that the tests should be improved. This is better done in line with #1122, I guess.

Contributor

lmohrmann commented Sep 14, 2017

Merging this now, although I agree that the tests should be improved. This is better done in line with #1122, I guess.

@lmohrmann lmohrmann merged commit 912eb78 into gammapy:master Sep 14, 2017

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@lmohrmann lmohrmann deleted the lmohrmann:fix-reso-comp branch Sep 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment