Skip to content

Instantly share code, notes, and snippets.

@joleroi
Last active May 3, 2018 11:34
Show Gist options
  • Save joleroi/a2d0db5284700e464aa3a4ab4ddb2ad0 to your computer and use it in GitHub Desktop.
Save joleroi/a2d0db5284700e464aa3a4ab4ddb2ad0 to your computer and use it in GitHub Desktop.
pytest -vv gammapy/maps/tests/test_hpxmap.py
Internet access disabled
Gammapy test data availability:
gammapy-extra ... yes
hess ............ yes
Gammapy environment variables:
GAMMAPY_EXTRA = /home/kingj/Software/gammapy-extra
Setting matplotlib backend to "agg" for the tests.
============================= test session starts ==============================
platform linux -- Python 3.5.3, pytest-3.2.3, py-1.4.33, pluggy-0.4.0 -- /home/kingj/Software/miniconda3/envs/headversions/bin/python
cachedir: .
Running tests with gammapy version 0.8.dev5853.
Running tests in gammapy/maps/tests/test_hpxmap.py.
Date: 2018-05-03T13:31:33
Platform: Linux-3.13.0-144-generic-x86_64-with-debian-jessie-sid
Executable: /home/kingj/Software/miniconda3/envs/headversions/bin/python
Full Python Version:
3.5.3 |Continuum Analytics, Inc.| (default, Mar 6 2017, 11:58:13)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15
Numpy: 1.13.1
Scipy: 0.19.1
Matplotlib: 2.0.2
h5py: not available
Pandas: 0.20.3
cython: 0.25.2
skimage: 0.13.0
sklearn: 0.19.0
uncertainties: 3.0.1
iminuit: 1.2
astropy: 3.0.dev20201
regions: 0.3.dev475
healpy: 1.10.3
sherpa: ciao4.10b1-py3.5-linux-x86_64.egg
gammapy: 0.8.dev5853
naima: not available
reproject: 0.3.1
photutils: not available
aplpy: 1.1.1
Using Astropy options: remote_data: none.
rootdir: /home/kingj/Software/gammapy, inifile: setup.cfg
plugins: arraydiff-0.2
collecting ... collected 122 items
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_init[8-False-GAL-None-None] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_init[8-False-GAL-None-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_init[nside2-False-GAL-None-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_init[nside3-False-GAL-DISK(110.,75.,30.)-axes3] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_init[8-False-GAL-DISK(110.,75.,10.)-axes4] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_init[8-False-GAL-DISK(110.,75.,10.)-axes5] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[8-False-GAL-None-None-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[8-False-GAL-None-axes1-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[nside2-False-GAL-None-axes2-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[nside3-False-GAL-DISK(110.,75.,30.)-axes3-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[8-False-GAL-DISK(110.,75.,10.)-axes4-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[8-False-GAL-DISK(110.,75.,10.)-axes5-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[8-False-GAL-None-None-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[8-False-GAL-None-axes7-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[nside8-False-GAL-None-axes8-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[nside9-False-GAL-DISK(110.,75.,30.)-axes9-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[8-False-GAL-DISK(110.,75.,10.)-axes10-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_create[8-False-GAL-DISK(110.,75.,10.)-axes11-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[8-False-GAL-None-None-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[8-False-GAL-None-axes1-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[nside2-False-GAL-None-axes2-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[nside3-False-GAL-DISK(110.,75.,30.)-axes3-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[8-False-GAL-DISK(110.,75.,10.)-axes4-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[8-False-GAL-DISK(110.,75.,10.)-axes5-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[8-False-GAL-None-None-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[8-False-GAL-None-axes7-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[nside8-False-GAL-None-axes8-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[nside9-False-GAL-DISK(110.,75.,30.)-axes9-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[8-False-GAL-DISK(110.,75.,10.)-axes10-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write[8-False-GAL-DISK(110.,75.,10.)-axes11-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_read_write_fgst PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[8-False-GAL-None-None-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[8-False-GAL-None-axes1-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[nside2-False-GAL-None-axes2-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[nside3-False-GAL-DISK(110.,75.,30.)-axes3-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[8-False-GAL-DISK(110.,75.,10.)-axes4-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[8-False-GAL-DISK(110.,75.,10.)-axes5-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[8-False-GAL-None-None-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[8-False-GAL-None-axes7-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[nside8-False-GAL-None-axes8-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[nside9-False-GAL-DISK(110.,75.,30.)-axes9-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[8-False-GAL-DISK(110.,75.,10.)-axes10-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_pix[8-False-GAL-DISK(110.,75.,10.)-axes11-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[8-False-GAL-None-None-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[8-False-GAL-None-axes1-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[nside2-False-GAL-None-axes2-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[nside3-False-GAL-DISK(110.,75.,30.)-axes3-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes4-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes5-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[8-False-GAL-None-None-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[8-False-GAL-None-axes7-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[nside8-False-GAL-None-axes8-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[nside9-False-GAL-DISK(110.,75.,30.)-axes9-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes10-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_set_get_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes11-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_interp_by_coord[8-False-GAL-None-None] FAILED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_interp_by_coord[8-False-GAL-None-axes1] FAILED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_interp_by_coord[nside2-False-GAL-None-axes2] FAILED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_interp_by_coord[nside3-False-GAL-DISK(110.,75.,30.)-axes3] FAILED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_interp_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes4] FAILED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_interp_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes5] FAILED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[8-False-GAL-None-None-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[8-False-GAL-None-axes1-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[nside2-False-GAL-None-axes2-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[nside3-False-GAL-DISK(110.,75.,30.)-axes3-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes4-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes5-True] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[8-False-GAL-None-None-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[8-False-GAL-None-axes7-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[nside8-False-GAL-None-axes8-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[nside9-False-GAL-DISK(110.,75.,30.)-axes9-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes10-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_fill_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes11-False] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_iter[8-False-GAL-None-None] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_iter[8-False-GAL-None-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_iter[nside2-False-GAL-None-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_iter[nside3-False-GAL-DISK(110.,75.,30.)-axes3] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_iter[8-False-GAL-DISK(110.,75.,10.)-axes4] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_iter[8-False-GAL-DISK(110.,75.,10.)-axes5] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_to_wcs[8-False-GAL-None-None] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_to_wcs[8-False-GAL-None-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_to_wcs[nside2-False-GAL-None-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_to_wcs[nside3-False-GAL-DISK(110.,75.,30.)-axes3] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_to_wcs[8-False-GAL-DISK(110.,75.,10.)-axes4] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_to_wcs[8-False-GAL-DISK(110.,75.,10.)-axes5] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_swap_scheme[8-False-GAL-None-None] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_swap_scheme[8-False-GAL-None-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_swap_scheme[nside2-False-GAL-None-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_swap_scheme[nside3-False-GAL-DISK(110.,75.,30.)-axes3] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_swap_scheme[8-False-GAL-DISK(110.,75.,10.)-axes4] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_swap_scheme[8-False-GAL-DISK(110.,75.,10.)-axes5] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_ud_grade[8-False-GAL-None-None] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_ud_grade[8-False-GAL-None-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_ud_grade[nside2-False-GAL-None-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_ud_grade[nside3-False-GAL-DISK(110.,75.,30.)-axes3] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_ud_grade[8-False-GAL-DISK(110.,75.,10.)-axes4] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_ud_grade[8-False-GAL-DISK(110.,75.,10.)-axes5] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_pad[nside0-False-GAL-DISK(110.,75.,30.)-axes0] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_pad[8-False-GAL-DISK(110.,75.,10.)-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_pad[8-False-GAL-DISK(110.,75.,10.)-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_crop[nside0-False-GAL-DISK(110.,75.,30.)-axes0] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_crop[8-False-GAL-DISK(110.,75.,10.)-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_crop[8-False-GAL-DISK(110.,75.,10.)-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_upsample[8-False-GAL-None-None] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_upsample[8-False-GAL-None-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_upsample[nside2-False-GAL-None-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_upsample[nside3-False-GAL-DISK(110.,75.,30.)-axes3] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_upsample[8-False-GAL-DISK(110.,75.,10.)-axes4] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_upsample[8-False-GAL-DISK(110.,75.,10.)-axes5] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_downsample[8-False-GAL-None-None] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_downsample[8-False-GAL-None-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_downsample[nside2-False-GAL-None-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_downsample[nside3-False-GAL-DISK(110.,75.,30.)-axes3] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_downsample[8-False-GAL-DISK(110.,75.,10.)-axes4] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_downsample[8-False-GAL-DISK(110.,75.,10.)-axes5] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_sum_over_axes[8-False-GAL-None-None] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_sum_over_axes[8-False-GAL-None-axes1] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_sum_over_axes[nside2-False-GAL-None-axes2] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_sum_over_axes[nside3-False-GAL-DISK(110.,75.,30.)-axes3] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_sum_over_axes[8-False-GAL-DISK(110.,75.,10.)-axes4] PASSED
gammapy/maps/tests/test_hpxmap.py::test_hpxmap_sum_over_axes[8-False-GAL-DISK(110.,75.,10.)-axes5] PASSED
gammapy/maps/tests/test_hpxmap.py::test_coadd_unit PASSED
=================================== FAILURES ===================================
______________ test_hpxmap_interp_by_coord[8-False-GAL-None-None] ______________
nside = 8, nested = False, coordsys = 'GAL', region = None, axes = None
@pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
hpx_test_geoms)
def test_hpxmap_interp_by_coord(nside, nested, coordsys, region, axes):
m = HpxNDMap(HpxGeom(nside=nside, nest=nested,
coordsys=coordsys, region=region, axes=axes))
coords = m.geom.get_coord(flat=True)
m.set_by_coord(coords, coords[1])
assert_allclose(m.get_by_coord(coords),
> m.interp_by_coord(coords, interp='linear'))
gammapy/maps/tests/test_hpxmap.py:180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gammapy/maps/hpxnd.py:316: in interp_by_coord
return self._interp_by_coord(coords, order)
gammapy/maps/hpxnd.py:374: in _interp_by_coord
pix, wts = self._get_interp_weights(coords, idx_ax)
gammapy/maps/hpxnd.py:354: in _get_interp_weights
phi, nest=self.geom.nest)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
nside = array([8])
theta = array([ 0.10210642, 0.10210642, 0.10210642, 0.10210642, 0.2044802 ,
0.2044802 , 0.2044802 , 0.2044802 , ...
2.93711245, 2.93711245, 2.93711245, 2.93711245, 3.03948623,
3.03948623, 3.03948623, 3.03948623])
phi = array([ 0.78539816, 2.35619449, 3.92699082, 5.49778714, 0.39269908,
1.17809725, 1.96349541, 2.74889357, ...
3.53429174, 4.3196899 , 5.10508806, 5.89048623, 0.78539816,
2.35619449, 3.92699082, 5.49778714])
nest = False, lonlat = False
def get_interp_weights(nside,theta,phi=None,nest=False,lonlat=False):
"""Return the 4 closest pixels on the two rings above and below the
location and corresponding weights.
Weights are provided for bilinear interpolation along latitude and longitude
Parameters
----------
nside : int
the healpix nside
theta, phi : float, scalar or array-like
if phi is not given, theta is interpreted as pixel number,
otherwise theta[rad],phi[rad] are angular coordinates
nest : bool
if ``True``, NESTED ordering, otherwise RING ordering.
lonlat : bool
If True, input angles are assumed to be longitude and latitude in degree,
otherwise, they are co-latitude and longitude in radians.
Returns
-------
res : tuple of length 2
contains pixel numbers in res[0] and weights in res[1].
Usual numpy broadcasting rules apply.
See Also
--------
get_interp_val, get_all_neighbours
Examples
--------
>>> import healpy as hp
>>> hp.get_interp_weights(1, 0)
(array([0, 1, 4, 5]), array([ 1., 0., 0., 0.]))
>>> hp.get_interp_weights(1, 0, 0)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, 0, 90, lonlat=True)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, [0, np.pi/2], 0)
(array([[ 1, 4],
[ 2, 5],
[ 3, 11],
[ 0, 8]]), array([[ 0.25, 1. ],
[ 0.25, 0. ],
[ 0.25, 0. ],
[ 0.25, 0. ]]))
"""
check_nside(nside)
> if phi == None:
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
../miniconda3/envs/headversions/lib/python3.5/site-packages/healpy/pixelfunc.py:1295: ValueError
_____________ test_hpxmap_interp_by_coord[8-False-GAL-None-axes1] ______________
nside = 8, nested = False, coordsys = 'GAL', region = None
axes = [<gammapy.maps.geom.MapAxis object at 0x7f620c5cab70>]
@pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
hpx_test_geoms)
def test_hpxmap_interp_by_coord(nside, nested, coordsys, region, axes):
m = HpxNDMap(HpxGeom(nside=nside, nest=nested,
coordsys=coordsys, region=region, axes=axes))
coords = m.geom.get_coord(flat=True)
m.set_by_coord(coords, coords[1])
assert_allclose(m.get_by_coord(coords),
> m.interp_by_coord(coords, interp='linear'))
gammapy/maps/tests/test_hpxmap.py:180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gammapy/maps/hpxnd.py:316: in interp_by_coord
return self._interp_by_coord(coords, order)
gammapy/maps/hpxnd.py:374: in _interp_by_coord
pix, wts = self._get_interp_weights(coords, idx_ax)
gammapy/maps/hpxnd.py:354: in _get_interp_weights
phi, nest=self.geom.nest)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
nside = array([8])
theta = array([ 0.10210642, 0.10210642, 0.10210642, ..., 3.03948623,
3.03948623, 3.03948623])
phi = array([ 0.78539816, 2.35619449, 3.92699082, ..., 2.35619449,
3.92699082, 5.49778714])
nest = False, lonlat = False
def get_interp_weights(nside,theta,phi=None,nest=False,lonlat=False):
"""Return the 4 closest pixels on the two rings above and below the
location and corresponding weights.
Weights are provided for bilinear interpolation along latitude and longitude
Parameters
----------
nside : int
the healpix nside
theta, phi : float, scalar or array-like
if phi is not given, theta is interpreted as pixel number,
otherwise theta[rad],phi[rad] are angular coordinates
nest : bool
if ``True``, NESTED ordering, otherwise RING ordering.
lonlat : bool
If True, input angles are assumed to be longitude and latitude in degree,
otherwise, they are co-latitude and longitude in radians.
Returns
-------
res : tuple of length 2
contains pixel numbers in res[0] and weights in res[1].
Usual numpy broadcasting rules apply.
See Also
--------
get_interp_val, get_all_neighbours
Examples
--------
>>> import healpy as hp
>>> hp.get_interp_weights(1, 0)
(array([0, 1, 4, 5]), array([ 1., 0., 0., 0.]))
>>> hp.get_interp_weights(1, 0, 0)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, 0, 90, lonlat=True)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, [0, np.pi/2], 0)
(array([[ 1, 4],
[ 2, 5],
[ 3, 11],
[ 0, 8]]), array([[ 0.25, 1. ],
[ 0.25, 0. ],
[ 0.25, 0. ],
[ 0.25, 0. ]]))
"""
check_nside(nside)
> if phi == None:
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
../miniconda3/envs/headversions/lib/python3.5/site-packages/healpy/pixelfunc.py:1295: ValueError
___________ test_hpxmap_interp_by_coord[nside2-False-GAL-None-axes2] ___________
nside = [4, 8], nested = False, coordsys = 'GAL', region = None
axes = [<gammapy.maps.geom.MapAxis object at 0x7f620c5cab70>]
@pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
hpx_test_geoms)
def test_hpxmap_interp_by_coord(nside, nested, coordsys, region, axes):
m = HpxNDMap(HpxGeom(nside=nside, nest=nested,
coordsys=coordsys, region=region, axes=axes))
coords = m.geom.get_coord(flat=True)
m.set_by_coord(coords, coords[1])
assert_allclose(m.get_by_coord(coords),
> m.interp_by_coord(coords, interp='linear'))
gammapy/maps/tests/test_hpxmap.py:180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gammapy/maps/hpxnd.py:316: in interp_by_coord
return self._interp_by_coord(coords, order)
gammapy/maps/hpxnd.py:374: in _interp_by_coord
pix, wts = self._get_interp_weights(coords, idx_ax)
gammapy/maps/hpxnd.py:354: in _get_interp_weights
phi, nest=self.geom.nest)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
nside = array([4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,... 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8])
theta = array([ 0.2044802 , 0.2044802 , 0.2044802 , 0.2044802 , 0.41113786,
0.41113786, 0.41113786, 0.41113786, ...711245, 2.93711245, 2.93711245, 2.93711245,
2.93711245, 3.03948623, 3.03948623, 3.03948623, 3.03948623])
phi = array([ 0.78539816, 2.35619449, 3.92699082, 5.49778714, 0.39269908,
1.17809725, 1.96349541, 2.74889357, ...889357, 3.53429174, 4.3196899 , 5.10508806,
5.89048623, 0.78539816, 2.35619449, 3.92699082, 5.49778714])
nest = False, lonlat = False
def get_interp_weights(nside,theta,phi=None,nest=False,lonlat=False):
"""Return the 4 closest pixels on the two rings above and below the
location and corresponding weights.
Weights are provided for bilinear interpolation along latitude and longitude
Parameters
----------
nside : int
the healpix nside
theta, phi : float, scalar or array-like
if phi is not given, theta is interpreted as pixel number,
otherwise theta[rad],phi[rad] are angular coordinates
nest : bool
if ``True``, NESTED ordering, otherwise RING ordering.
lonlat : bool
If True, input angles are assumed to be longitude and latitude in degree,
otherwise, they are co-latitude and longitude in radians.
Returns
-------
res : tuple of length 2
contains pixel numbers in res[0] and weights in res[1].
Usual numpy broadcasting rules apply.
See Also
--------
get_interp_val, get_all_neighbours
Examples
--------
>>> import healpy as hp
>>> hp.get_interp_weights(1, 0)
(array([0, 1, 4, 5]), array([ 1., 0., 0., 0.]))
>>> hp.get_interp_weights(1, 0, 0)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, 0, 90, lonlat=True)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, [0, np.pi/2], 0)
(array([[ 1, 4],
[ 2, 5],
[ 3, 11],
[ 0, 8]]), array([[ 0.25, 1. ],
[ 0.25, 0. ],
[ 0.25, 0. ],
[ 0.25, 0. ]]))
"""
check_nside(nside)
> if phi == None:
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
../miniconda3/envs/headversions/lib/python3.5/site-packages/healpy/pixelfunc.py:1295: ValueError
____ test_hpxmap_interp_by_coord[nside3-False-GAL-DISK(110.,75.,30.)-axes3] ____
nside = [4, 8], nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,30.)'
axes = [<gammapy.maps.geom.MapAxis object at 0x7f620c5cab70>]
@pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
hpx_test_geoms)
def test_hpxmap_interp_by_coord(nside, nested, coordsys, region, axes):
m = HpxNDMap(HpxGeom(nside=nside, nest=nested,
coordsys=coordsys, region=region, axes=axes))
coords = m.geom.get_coord(flat=True)
m.set_by_coord(coords, coords[1])
assert_allclose(m.get_by_coord(coords),
> m.interp_by_coord(coords, interp='linear'))
gammapy/maps/tests/test_hpxmap.py:180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gammapy/maps/hpxnd.py:316: in interp_by_coord
return self._interp_by_coord(coords, order)
gammapy/maps/hpxnd.py:374: in _interp_by_coord
pix, wts = self._get_interp_weights(coords, idx_ax)
gammapy/maps/hpxnd.py:354: in _get_interp_weights
phi, nest=self.geom.nest)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
nside = array([4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8])
theta = array([ 0.2044802 , 0.2044802 , 0.2044802 , 0.2044802 , 0.41113786,
0.41113786, 0.41113786, 0.41113786, ...
0.62236849, 0.62236849, 0.62236849, 0.73057374, 0.73057374,
0.73057374, 0.73057374, 0.73057374])
phi = array([ 0.78539816, 2.35619449, 3.92699082, 5.49778714, 0.39269908,
1.17809725, 1.96349541, 2.74889357, ...
2.2252948 , 2.48709418, 2.74889357, 1.45859659, 1.68299606,
1.90739554, 2.13179501, 2.35619449])
nest = False, lonlat = False
def get_interp_weights(nside,theta,phi=None,nest=False,lonlat=False):
"""Return the 4 closest pixels on the two rings above and below the
location and corresponding weights.
Weights are provided for bilinear interpolation along latitude and longitude
Parameters
----------
nside : int
the healpix nside
theta, phi : float, scalar or array-like
if phi is not given, theta is interpreted as pixel number,
otherwise theta[rad],phi[rad] are angular coordinates
nest : bool
if ``True``, NESTED ordering, otherwise RING ordering.
lonlat : bool
If True, input angles are assumed to be longitude and latitude in degree,
otherwise, they are co-latitude and longitude in radians.
Returns
-------
res : tuple of length 2
contains pixel numbers in res[0] and weights in res[1].
Usual numpy broadcasting rules apply.
See Also
--------
get_interp_val, get_all_neighbours
Examples
--------
>>> import healpy as hp
>>> hp.get_interp_weights(1, 0)
(array([0, 1, 4, 5]), array([ 1., 0., 0., 0.]))
>>> hp.get_interp_weights(1, 0, 0)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, 0, 90, lonlat=True)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, [0, np.pi/2], 0)
(array([[ 1, 4],
[ 2, 5],
[ 3, 11],
[ 0, 8]]), array([[ 0.25, 1. ],
[ 0.25, 0. ],
[ 0.25, 0. ],
[ 0.25, 0. ]]))
"""
check_nside(nside)
> if phi == None:
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
../miniconda3/envs/headversions/lib/python3.5/site-packages/healpy/pixelfunc.py:1295: ValueError
______ test_hpxmap_interp_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes4] _______
nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)'
axes = [<gammapy.maps.geom.MapAxis object at 0x7f620c5cac18>]
@pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
hpx_test_geoms)
def test_hpxmap_interp_by_coord(nside, nested, coordsys, region, axes):
m = HpxNDMap(HpxGeom(nside=nside, nest=nested,
coordsys=coordsys, region=region, axes=axes))
coords = m.geom.get_coord(flat=True)
m.set_by_coord(coords, coords[1])
assert_allclose(m.get_by_coord(coords),
> m.interp_by_coord(coords, interp='linear'))
gammapy/maps/tests/test_hpxmap.py:180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gammapy/maps/hpxnd.py:316: in interp_by_coord
return self._interp_by_coord(coords, order)
gammapy/maps/hpxnd.py:374: in _interp_by_coord
pix, wts = self._get_interp_weights(coords, idx_ax)
gammapy/maps/hpxnd.py:354: in _get_interp_weights
phi, nest=self.geom.nest)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
nside = array([8])
theta = array([ 0.2044802 , 0.30739505, 0.30739505, 0.41113786, 0.41113786,
0.2044802 , 0.30739505, 0.30739505, 0.41113786, 0.41113786,
0.2044802 , 0.30739505, 0.30739505, 0.41113786, 0.41113786])
phi = array([ 1.96349541, 1.83259571, 2.35619449, 1.76714587, 2.15984495,
1.96349541, 1.83259571, 2.35619449, 1.76714587, 2.15984495,
1.96349541, 1.83259571, 2.35619449, 1.76714587, 2.15984495])
nest = False, lonlat = False
def get_interp_weights(nside,theta,phi=None,nest=False,lonlat=False):
"""Return the 4 closest pixels on the two rings above and below the
location and corresponding weights.
Weights are provided for bilinear interpolation along latitude and longitude
Parameters
----------
nside : int
the healpix nside
theta, phi : float, scalar or array-like
if phi is not given, theta is interpreted as pixel number,
otherwise theta[rad],phi[rad] are angular coordinates
nest : bool
if ``True``, NESTED ordering, otherwise RING ordering.
lonlat : bool
If True, input angles are assumed to be longitude and latitude in degree,
otherwise, they are co-latitude and longitude in radians.
Returns
-------
res : tuple of length 2
contains pixel numbers in res[0] and weights in res[1].
Usual numpy broadcasting rules apply.
See Also
--------
get_interp_val, get_all_neighbours
Examples
--------
>>> import healpy as hp
>>> hp.get_interp_weights(1, 0)
(array([0, 1, 4, 5]), array([ 1., 0., 0., 0.]))
>>> hp.get_interp_weights(1, 0, 0)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, 0, 90, lonlat=True)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, [0, np.pi/2], 0)
(array([[ 1, 4],
[ 2, 5],
[ 3, 11],
[ 0, 8]]), array([[ 0.25, 1. ],
[ 0.25, 0. ],
[ 0.25, 0. ],
[ 0.25, 0. ]]))
"""
check_nside(nside)
> if phi == None:
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
../miniconda3/envs/headversions/lib/python3.5/site-packages/healpy/pixelfunc.py:1295: ValueError
______ test_hpxmap_interp_by_coord[8-False-GAL-DISK(110.,75.,10.)-axes5] _______
nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)'
axes = [<gammapy.maps.geom.MapAxis object at 0x7f620c5d05c0>, <gammapy.maps.geom.MapAxis object at 0x7f620c5d05f8>]
@pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
hpx_test_geoms)
def test_hpxmap_interp_by_coord(nside, nested, coordsys, region, axes):
m = HpxNDMap(HpxGeom(nside=nside, nest=nested,
coordsys=coordsys, region=region, axes=axes))
coords = m.geom.get_coord(flat=True)
m.set_by_coord(coords, coords[1])
assert_allclose(m.get_by_coord(coords),
> m.interp_by_coord(coords, interp='linear'))
gammapy/maps/tests/test_hpxmap.py:180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gammapy/maps/hpxnd.py:316: in interp_by_coord
return self._interp_by_coord(coords, order)
gammapy/maps/hpxnd.py:374: in _interp_by_coord
pix, wts = self._get_interp_weights(coords, idx_ax)
gammapy/maps/hpxnd.py:354: in _get_interp_weights
phi, nest=self.geom.nest)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
nside = array([8])
theta = array([ 0.2044802 , 0.30739505, 0.30739505, 0.41113786, 0.41113786,
0.2044802 , 0.30739505, 0.30739505, ...739505, 0.30739505, 0.41113786, 0.41113786,
0.2044802 , 0.30739505, 0.30739505, 0.41113786, 0.41113786])
phi = array([ 1.96349541, 1.83259571, 2.35619449, 1.76714587, 2.15984495,
1.96349541, 1.83259571, 2.35619449, ...259571, 2.35619449, 1.76714587, 2.15984495,
1.96349541, 1.83259571, 2.35619449, 1.76714587, 2.15984495])
nest = False, lonlat = False
def get_interp_weights(nside,theta,phi=None,nest=False,lonlat=False):
"""Return the 4 closest pixels on the two rings above and below the
location and corresponding weights.
Weights are provided for bilinear interpolation along latitude and longitude
Parameters
----------
nside : int
the healpix nside
theta, phi : float, scalar or array-like
if phi is not given, theta is interpreted as pixel number,
otherwise theta[rad],phi[rad] are angular coordinates
nest : bool
if ``True``, NESTED ordering, otherwise RING ordering.
lonlat : bool
If True, input angles are assumed to be longitude and latitude in degree,
otherwise, they are co-latitude and longitude in radians.
Returns
-------
res : tuple of length 2
contains pixel numbers in res[0] and weights in res[1].
Usual numpy broadcasting rules apply.
See Also
--------
get_interp_val, get_all_neighbours
Examples
--------
>>> import healpy as hp
>>> hp.get_interp_weights(1, 0)
(array([0, 1, 4, 5]), array([ 1., 0., 0., 0.]))
>>> hp.get_interp_weights(1, 0, 0)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, 0, 90, lonlat=True)
(array([1, 2, 3, 0]), array([ 0.25, 0.25, 0.25, 0.25]))
>>> hp.get_interp_weights(1, [0, np.pi/2], 0)
(array([[ 1, 4],
[ 2, 5],
[ 3, 11],
[ 0, 8]]), array([[ 0.25, 1. ],
[ 0.25, 0. ],
[ 0.25, 0. ],
[ 0.25, 0. ]]))
"""
check_nside(nside)
> if phi == None:
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
../miniconda3/envs/headversions/lib/python3.5/site-packages/healpy/pixelfunc.py:1295: ValueError
===================== 6 failed, 116 passed in 8.06 seconds =====================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment