Skip to content

Instantly share code, notes, and snippets.

@joleroi
Last active September 5, 2016 12:10
Show Gist options
  • Save joleroi/f7f4b798cf3d96f0af2488c5fb37d749 to your computer and use it in GitHub Desktop.
Save joleroi/f7f4b798cf3d96f0af2488c5fb37d749 to your computer and use it in GitHub Desktop.
running test
running build
running build_py
running build_ext
skipping 'gammapy/detect/_test_statistics_cython.c' Cython extension (up-to-date)
Gammapy test data availability:
gammapy-extra ... yes
hess ............ yes
Gammapy environment variables:
GAMMAPY_EXTRA = /home/kingj/Software/gammapy-extra
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-2.8.3, py-1.4.30, pluggy-0.3.1 -- /home/kingj/Software/miniconda3/envs/headversions/bin/python
cachedir: ../.cache
Running tests with gammapy version 0.5.dev3387.
Running tests in gammapy/scripts/tests/test_image_pipe.py.
Date: 2016-09-05T14:09:24
Platform: Linux-3.13.0-58-generic-x86_64-with-debian-jessie-sid
Executable: /home/kingj/Software/miniconda3/envs/headversions/bin/python
Full Python Version:
2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
encodings: sys: ascii, locale: UTF-8, filesystem: UTF-8, unicode bits: 20
byteorder: little
float info: dig: 15, mant_dig: 15
Numpy: 1.11.0
Scipy: 0.17.1
Matplotlib: 1.5.1
h5py: 2.5.0
Pandas: 0.18.1
cython: 0.23.2
pandas: 0.18.1
skimage: 0.11.3
sklearn: 0.16.1
uncertainties: 2.4.8.1
iminuit: not available
astropy: 1.2.dev15891
sherpa: 4.8.1+138.g6331045
gammapy: 0.5.dev3387
naima: 0.6.1
reproject: 0.1
photutils: 0.1
gwcs: not available
wcsaxes: 0.6
aplpy: 1.0
regions: 0.0.dev223
astroplan: not available
rootdir: /tmp/gammapy-test-ilUXTB, inifile: setup.cfg
plugins: nbval-0.3.2
collecting ... collected 1 items
gammapy/scripts/tests/test_image_pipe.py::test_image_pipe FAILED
=================================== FAILURES ===================================
_______________________________ test_image_pipe ________________________________
tmpdir = '/tmp/pytest-of-kingj/pytest-13/test_image_pipe0'
@requires_dependency('reproject')
@requires_data('gammapy-extra')
def test_image_pipe(tmpdir):
tmpdir = str(tmpdir)
from subprocess import call
outdir = tmpdir
outdir2 = outdir + '/background'
cmd = 'mkdir -p {}'.format(outdir2)
print('Executing: {}'.format(cmd))
call(cmd, shell=True)
ds = DataStore.from_dir("$GAMMAPY_EXTRA/datasets/hess-crab4-hd-hap-prod2")
ds.copy_obs(ds.obs_table, tmpdir)
data_store = DataStore.from_dir(tmpdir)
bgmaker = OffDataBackgroundMaker(data_store, outdir=outdir2)
bgmaker.select_observations(selection='all')
bgmaker.group_observations()
bgmaker.make_model("2D")
bgmaker.save_models("2D")
fn = outdir2 + '/group-def.fits'
hdu_index_table = bgmaker.make_total_index_table(
data_store=data_store,
modeltype='2D',
out_dir_background_model=outdir2,
filename_obs_group_table=fn
)
fn = outdir + '/hdu-index.fits.gz'
hdu_index_table.write(fn, overwrite=True)
tmpdir = str(tmpdir)
center = SkyCoord(83.63, 22.01, unit='deg').galactic
energy_band = Energy([1, 10], 'TeV')
offset_band = Angle([0, 2.49], 'deg')
data_store = DataStore.from_dir(tmpdir)
# TODO: fix `binarize` implementation
# exclusion_mask = exclusion_mask.binarize()
image = SkyImage.empty(nxpix=250, nypix=250, binsz=0.02, xref=center.l.deg,
yref=center.b.deg, proj='TAN', coordsys='GAL')
refheader = image.to_image_hdu().header
exclusion_mask = SkyMask.read('$GAMMAPY_EXTRA/datasets/exclusion_masks/tevcat_exclusion.fits')
exclusion_mask = exclusion_mask.reproject(reference=refheader)
# Pb with the load psftable for one of the run that is not implemented yet...
data_store.hdu_table.remove_row(14)
mosaic = MosaicImage(image, energy_band=energy_band, offset_band=offset_band, data_store=data_store,
obs_table=data_store.obs_table, exclusion_mask=exclusion_mask)
mosaic.make_images(make_background_image=True, for_integral_flux=True, radius=10.)
assert_allclose(mosaic.maps['counts'].data.sum(), 2334.0, atol=3)
> assert_allclose(mosaic.maps['bkg'].data.sum(), 1987.1513636663785, atol=3)
gammapy/scripts/tests/test_image_pipe.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x_id = True, y_id = False, hasval = 'nan'
def chk_same_position(x_id, y_id, hasval='nan'):
"""Handling nan/inf: check that x and y have the nan/inf at the same
locations."""
try:
assert_array_equal(x_id, y_id)
except AssertionError:
msg = build_err_msg([x, y],
err_msg + '\nx and y %s location mismatch:'
% (hasval), verbose=verbose, header=header,
names=('x', 'y'), precision=precision)
> raise AssertionError(msg)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=3
E
E x and y nan location mismatch:
E x: array(nan)
E y: array(1987.1513636663785)
/home/kingj/Software/miniconda3/envs/headversions/lib/python2.7/site-packages/numpy/testing/utils.py:676: AssertionError
----------------------------- Captured stdout call -----------------------------
Executing: mkdir -p /tmp/pytest-of-kingj/pytest-13/test_image_pipe0/background
----------------------------- Captured stderr call -----------------------------
INFO:gammapy.background.off_data_background_maker:Writing run.lis
INFO:gammapy.background.off_data_background_maker:ZEN_PNT edges [ 0 49 90]
INFO:gammapy.background.off_data_background_maker:Writing /tmp/pytest-of-kingj/pytest-13/test_image_pipe0/background/obs.fits
INFO:gammapy.background.off_data_background_maker:Writing /tmp/pytest-of-kingj/pytest-13/test_image_pipe0/background/group-def.fits
INFO:gammapy.background.off_data_background_maker:Groups: [0, 1]
INFO:gammapy.background.off_data_background_maker:Processing group 0 with 3 observations
INFO:gammapy.background.off_data_background_maker:Processing group 1 with 1 observations
WARNING: No safe energy thresholds found. Setting to default [gammapy.irf.psf_analytical]
WARNING:astropy:No safe energy thresholds found. Setting to default
WARNING:gammapy.irf.psf_king:No safe energy thresholds found. Setting to default
WARNING: No safe energy thresholds found. Setting to default [gammapy.irf.psf_analytical]
WARNING:astropy:No safe energy thresholds found. Setting to default
WARNING:gammapy.irf.psf_king:No safe energy thresholds found. Setting to default
=========================== 1 failed in 5.62 seconds ===========================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment