Skip to content

Instantly share code, notes, and snippets.

@cdeil
Created June 20, 2017 10: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/908864a9aa1f226dd3b2536606225b76 to your computer and use it in GitHub Desktop.
Save cdeil/908864a9aa1f226dd3b2536606225b76 to your computer and use it in GitHub Desktop.
$ python -m pytest gammapy/scripts/tests/test_cta_sensitivity.py
Gammapy test data availability:
gammapy-extra ... yes
hess ............ yes
Gammapy environment variables:
GAMMAPY_EXTRA = /Users/deil/code/gammapy-extra
Setting matplotlib backend to "agg" for the tests.
========================================================================= test session starts ==========================================================================
platform darwin -- Python 3.6.1, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
Running tests with gammapy version 0.7.dev4701.
Running tests in gammapy/scripts/tests/test_cta_sensitivity.py.
Date: 2017-06-20T12:00:38
Platform: Darwin-16.6.0-x86_64-i386-64bit
Executable: /opt/local/bin/python
Full Python Version:
3.6.1 (default, Apr 24 2017, 06:18:27)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15
Numpy: 1.13.0
Scipy: 0.19.0
Matplotlib: 2.0.2
h5py: 2.7.0
Pandas: 0.20.2
cython: 0.25.2
skimage: 0.13.0
sklearn: 0.18.1
uncertainties: 2.4.8.1
iminuit: 1.2
astropy: 2.0.dev19134
sherpa: 4.9.0+28.gaa98d19.dirty-py3.6-macosx-10.12-x86_64.egg
gammapy: 0.7.dev4701
naima: not available
reproject: 0.3.1
photutils: 0.3.2
aplpy: 1.1.1
regions: 0.2
astroplan: not available
Using Astropy options: remote_data: none.
rootdir: /Users/deil/code/gammapy, inifile: setup.cfg
collected 1 items
gammapy/scripts/tests/test_cta_sensitivity.py F
=============================================================================== FAILURES ===============================================================================
_________________________________________________________________________ test_cta_sensitivity _________________________________________________________________________
@requires_dependency('scipy')
@requires_data('gammapy-extra')
def test_cta_sensitivity():
"""Run sensitivity estimation for one CTA IRF example."""
filename = '$GAMMAPY_EXTRA/datasets/cta/perf_prod2/North_0.5h/irf_file.fits.gz'
> irf = CTAPerf.read(filename)
gammapy/scripts/tests/test_cta_sensitivity.py:13:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gammapy/scripts/cta_irf.py:391: in read
aeff = EffectiveAreaTable.from_hdulist(hdulist=hdulist)
gammapy/irf/effective_area.py:181: in from_hdulist
fits_table = hdulist[hdu]
../../Library/Python/3.6/lib/python/site-packages/astropy-2.0.dev19134-py3.6-macosx-10.12-x86_64.egg/astropy/io/fits/hdu/hdulist.py:313: in __getitem__
self._positive_index_of(key))
../../Library/Python/3.6/lib/python/site-packages/astropy-2.0.dev19134-py3.6-macosx-10.12-x86_64.egg/astropy/io/fits/hdu/hdulist.py:709: in _positive_index_of
index = self.index_of(key)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x10bc627b8>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x10bc...py.io.fits.hdu.table.BinTableHDU object at 0x10bcd09e8>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x10bcd6f28>]
key = 'SPECRESP'
def index_of(self, key):
"""
Get the index of an HDU from the `HDUList`.
Parameters
----------
key : int, str or tuple of (string, int)
The key identifying the HDU. If ``key`` is a tuple, it is of the
form ``(key, ver)`` where ``ver`` is an ``EXTVER`` value that must
match the HDU being searched for.
If the key is ambiguous (e.g. there are multiple 'SCI' extensions)
the first match is returned. For a more precise match use the
``(name, ver)`` pair.
If even the ``(name, ver)`` pair is ambiguous (it shouldn't be
but it's not impossible) the numeric index must be used to index
the duplicate HDU.
Returns
-------
index : int
The index of the HDU in the `HDUList`.
"""
if _is_int(key):
return key
elif isinstance(key, tuple):
_key, _ver = key
else:
_key = key
_ver = None
if not isinstance(_key, string_types):
raise KeyError(
'{} indices must be integers, extension names as strings, '
'or (extname, version) tuples; got {}'
''.format(self.__class__.__name__, _key))
_key = (_key.strip()).upper()
found = None
for idx, hdu in enumerate(self):
name = hdu.name
if isinstance(name, string_types):
name = name.strip().upper()
# 'PRIMARY' should always work as a reference to the first HDU
if ((name == _key or (_key == 'PRIMARY' and idx == 0)) and
(_ver is None or _ver == hdu.ver)):
found = idx
break
if (found is None):
> raise KeyError('Extension {!r} not found.'.format(key))
E KeyError: "Extension 'SPECRESP' not found."
../../Library/Python/3.6/lib/python/site-packages/astropy-2.0.dev19134-py3.6-macosx-10.12-x86_64.egg/astropy/io/fits/hdu/hdulist.py:690: KeyError
=========================================================================== warnings summary ===========================================================================
None
[pytest] section in setup.cfg files is deprecated, use [tool:pytest] instead.
-- Docs: http://doc.pytest.org/en/latest/warnings.html
================================================================= 1 failed, 1 warnings in 1.49 seconds =================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment