Skip to content

Instantly share code, notes, and snippets.

@cdeil
Created February 20, 2018 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdeil/5c46676b760ddfe1a40061641a19b551 to your computer and use it in GitHub Desktop.
Save cdeil/5c46676b760ddfe1a40061641a19b551 to your computer and use it in GitHub Desktop.
__________________________________________________________________ TestFermiLATBasicImageEstimator.test_run __________________________________________________________________
self = <gammapy.image.tests.test_basic.TestFermiLATBasicImageEstimator object at 0x11d627ac8>
def test_run(self):
if 'FERMI_DIFFUSE_DIR' in os.environ:
which = 'all'
else:
which = ['counts', 'exposure', 'psf']
results = self.estimator.run(
self.dataset,
> which=which,
)
gammapy/image/tests/test_basic.py:40:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gammapy/image/basic.py:600: in run
images['background'] = self.background(dataset)
gammapy/image/basic.py:486: in background
exposure_cube = reproject_exposure(dataset.exposure, background_cube)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
exposure = <gammapy.maps.hpxnd.HpxNDMap object at 0x11a89cd68>, ref_cube = <gammapy.cube.core.SkyCube object at 0x11c8ae9e8>
def reproject_exposure(exposure, ref_cube):
"""Helper function to reproject exposure to a reference cube.
TODO: this is a temp solution, as long as we use HpxNDMap objects for exposure
and SkyCube objects otherwise. This should be changed to use WCSMapND
instead of SkyCube in the future.
Parameters
----------
exposure : `~gammapy.maps.HpxNDMap`
Exposure cube from gtexmpcube2
ref_cube : `~gammapy.cube.SkyCube`
Reference cube to reproject to
Returns
-------
exposure : `~gammapy.cube.SkyCube`
Exposure reprojected onto reference cube.
"""
from ..cube import SkyCube
exposure_cube = SkyCube.empty_like(ref_cube)
ref_image = ref_cube.sky_image_ref
geom = ref_image.to_wcs_nd_map().geom
coords = geom.get_coord()
for idx, energy in enumerate(ref_cube.energies().value):
coords_hpx = coords[0], coords[1], energy
> vals = exposure.get_by_coord(coords_hpx, interp='linear')
E TypeError: get_by_coord() got an unexpected keyword argument 'interp'
gammapy/image/basic.py:644: TypeError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment