Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ______________________________________________ test_mapbase_create[0.1-10.0-hpx-skydir4-axes4] ______________________________________________
- binsz = 0.1, width = 10.0, map_type = 'hpx', skydir = <SkyCoord (ICRS): (ra, dec) in deg
- ( 0., 30.)>
- axes = [<gammapy.maps.geom.MapAxis object at 0x118027c50>]
- @pytest.mark.parametrize(('binsz', 'width', 'map_type', 'skydir', 'axes'),
- mapbase_args)
- def test_mapbase_create(binsz, width, map_type, skydir, axes):
- m = MapBase.create(binsz=binsz, width=width, map_type=map_type,
- > skydir=skydir, axes=axes)
- gammapy/maps/tests/test_base.py:31:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/base.py:100: in create
- return HpxMap.create(**kwargs)
- gammapy/maps/hpxmap.py:78: in create
- return HpxMapND(hpx, dtype=dtype)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpxcube.HpxMapND object at 0x1181acdd8>, hpx = <gammapy.maps.hpx.HpxGeom object at 0x118147748>
- data = array([[ nan, nan, nan, ..., nan, nan, nan],
- [ nan, nan, nan, ..., nan, nan, nan],
- [ nan, nan, nan, ..., nan, nan, nan]], dtype=float32)
- dtype = 'float32'
- def __init__(self, hpx, data=None, dtype='float32'):
- shape = tuple([np.max(hpx.npix)] + [ax.nbin for ax in hpx.axes])
- if data is None:
- if hpx.npix.size > 1:
- data = np.nan * np.ones(shape, dtype=dtype).T
- pix = hpx.get_pixels(local=True)
- > data[pix[::-1]] = 0.0
- E IndexError: index 6155 is out of bounds for axis 1 with size 6155
- gammapy/maps/hpxcube.py:41: IndexError
- ______________________________________________ test_mapbase_create[0.1-10.0-hpx-skydir5-axes5] ______________________________________________
- binsz = 0.1, width = 10.0, map_type = 'hpx', skydir = <SkyCoord (ICRS): (ra, dec) in deg
- ( 0., 30.)>
- axes = [<gammapy.maps.geom.MapAxis object at 0x118027c50>, <gammapy.maps.geom.MapAxis object at 0x118027da0>]
- @pytest.mark.parametrize(('binsz', 'width', 'map_type', 'skydir', 'axes'),
- mapbase_args)
- def test_mapbase_create(binsz, width, map_type, skydir, axes):
- m = MapBase.create(binsz=binsz, width=width, map_type=map_type,
- > skydir=skydir, axes=axes)
- gammapy/maps/tests/test_base.py:31:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/base.py:100: in create
- return HpxMap.create(**kwargs)
- gammapy/maps/hpxmap.py:78: in create
- return HpxMapND(hpx, dtype=dtype)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpxcube.HpxMapND object at 0x11843fef0>, hpx = <gammapy.maps.hpx.HpxGeom object at 0x1143d5b00>
- data = array([[[ nan, nan, nan, ..., nan, nan, nan],
- [ nan, nan, nan, ..., nan, nan, nan],
- [ nan, ...
- [ nan, nan, nan, ..., nan, nan, nan],
- [ nan, nan, nan, ..., nan, nan, nan]]], dtype=float32)
- dtype = 'float32'
- def __init__(self, hpx, data=None, dtype='float32'):
- shape = tuple([np.max(hpx.npix)] + [ax.nbin for ax in hpx.axes])
- if data is None:
- if hpx.npix.size > 1:
- data = np.nan * np.ones(shape, dtype=dtype).T
- pix = hpx.get_pixels(local=True)
- > data[pix[::-1]] = 0.0
- E IndexError: index 6155 is out of bounds for axis 2 with size 6155
- gammapy/maps/hpxcube.py:41: IndexError
- _________________________________________________________ test_hpx_global_to_local __________________________________________________________
- def test_hpx_global_to_local():
- ax0 = np.linspace(0., 1., 3)
- ax1 = np.linspace(0., 1., 3)
- # 2D All-sky
- hpx = HpxGeom(16, False, 'GAL')
- assert_allclose(hpx[0], np.array([0]))
- assert_allclose(hpx[633], np.array([633]))
- assert_allclose(hpx[0, 633], np.array([0, 633]))
- assert_allclose(hpx[np.array([0, 633])], np.array([0, 633]))
- # 3D All-sky
- hpx = HpxGeom(16, False, 'GAL', axes=[ax0])
- assert_allclose(hpx[(np.array([177, 177]), np.array([0, 1]))],
- np.array([177, 177 + 3072]))
- # 2D Partial-sky
- hpx = HpxGeom(64, False, 'GAL', region='DISK(110.,75.,2.)')
- > assert_allclose(hpx[0, 633, 706], np.array([-1, 0, 2]))
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 33.33333333333333%)
- E x: array([-1, 0, 0], dtype=int32)
- E y: array([-1, 0, 2])
- gammapy/maps/tests/test_hpx.py:87: AssertionError
- _______________________________________ test_hpxgeom_get_pixels[8-False-GAL-DISK(110.,75.,10.)-None] ________________________________________
- nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)', axes = None
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_get_pixels(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- pix = geom.get_pixels(local=False)
- pix_local = geom.get_pixels(local=True)
- > assert_allclose(pix, geom.local_to_global(pix_local))
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 66.66666666666666%)
- E x: array([[ 6, 1, 0, 5, 14, 15, 29, 16, 7, 28, 46, 27]])
- E y: array([[14, 5, 6, 5, 14, 28, 46, 28, 14, 28, 46, 28]])
- gammapy/maps/tests/test_hpx.py:175: AssertionError
- _______________________________________ test_hpxgeom_get_pixels[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 0x11808cc50>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_get_pixels(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- pix = geom.get_pixels(local=False)
- pix_local = geom.get_pixels(local=True)
- > assert_allclose(pix, geom.local_to_global(pix_local))
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 33.33333333333333%)
- E x: array([[ 6, 1, 0, 5, 14, 15, 29, 16, 7, 28, 46, 27, 6, 1, 0, 5, 14,
- E 15, 29, 16, 7, 28, 46, 27, 6, 1, 0, 5, 14, 15, 29, 16, 7, 28,
- E 46, 27],...
- E y: array([[14, 5, 6, 5, 14, 28, 46, 28, 14, 28, 46, 28, 14, 5, 6, 5, 14,
- E 28, 46, 28, 14, 28, 46, 28, 14, 5, 6, 5, 14, 28, 46, 28, 14, 28,
- E 46, 28],...
- gammapy/maps/tests/test_hpx.py:175: AssertionError
- ____________________________________ test_hpxgeom_get_pixels[nside6-False-GAL-DISK(110.,75.,10.)-axes6] _____________________________________
- nside = [8, 16, 32], nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)'
- axes = [<gammapy.maps.geom.MapAxis object at 0x11808cc88>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_get_pixels(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- pix = geom.get_pixels(local=False)
- > pix_local = geom.get_pixels(local=True)
- gammapy/maps/tests/test_hpx.py:174:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1363: in get_pixels
- return self.global_to_local(pix)
- gammapy/maps/hpx.py:536: in global_to_local
- retval = unravel_hpx_index(retval, self._npix)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- idx = array([ 4, 3, 0, 3, 9, 9, 12, 6, 4, 6, 12, 6, 35,
- 16, 12, 15, 35, 37, 39, 37, 17,...67, 76, 140, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48], dtype=int32)
- npix = array([ 12, 36, 119])
- def unravel_hpx_index(idx, npix):
- """Convert flattened global map index to an index tuple.
- Parameters
- ----------
- idx : `~numpy.ndarray`
- Flat index.
- npix : `~numpy.ndarray`
- Number of pixels in each band.
- Returns
- -------
- idx : tuple of `~numpy.ndarray`
- Index array for each dimension of the map.
- """
- if npix.size == 1:
- return tuple([idx])
- dpix = np.zeros(npix.size, dtype='i')
- dpix[1:] = np.cumsum(npix.flat[:-1])
- bidx = np.searchsorted(np.cumsum(npix.flat), idx + 1)
- > pix = idx - dpix[bidx]
- E IndexError: index 3 is out of bounds for axis 1 with size 3
- gammapy/maps/hpx.py:101: IndexError
- ____________________________________ test_hpxgeom_get_pixels[nside7-False-GAL-DISK(110.,75.,10.)-axes7] _____________________________________
- nside = [[8, 16, 32], [8, 8, 16]], nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)'
- axes = [<gammapy.maps.geom.MapAxis object at 0x11808ccc0>, <gammapy.maps.geom.MapAxis object at 0x11808ccf8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_get_pixels(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- pix = geom.get_pixels(local=False)
- > pix_local = geom.get_pixels(local=True)
- gammapy/maps/tests/test_hpx.py:174:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1363: in get_pixels
- return self.global_to_local(pix)
- gammapy/maps/hpx.py:536: in global_to_local
- retval = unravel_hpx_index(retval, self._npix)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- idx = array([ 4, 3, 0, 3, 4, 5, 12, 6, 4, 9, 10, 9, 33,
- 12, 12, 12, 16, 37, 39, 37, 17,... 191, 191, 212, 191, 212, 212, 214, 215, 216, 217, 220, 218, 220,
- 220, 227, 220, 227, 220, 218], dtype=int32)
- npix = array([[ 12, 36, 119],
- [ 12, 12, 36]])
- def unravel_hpx_index(idx, npix):
- """Convert flattened global map index to an index tuple.
- Parameters
- ----------
- idx : `~numpy.ndarray`
- Flat index.
- npix : `~numpy.ndarray`
- Number of pixels in each band.
- Returns
- -------
- idx : tuple of `~numpy.ndarray`
- Index array for each dimension of the map.
- """
- if npix.size == 1:
- return tuple([idx])
- dpix = np.zeros(npix.size, dtype='i')
- dpix[1:] = np.cumsum(npix.flat[:-1])
- bidx = np.searchsorted(np.cumsum(npix.flat), idx + 1)
- > pix = idx - dpix[bidx]
- E IndexError: index 6 is out of bounds for axis 1 with size 6
- gammapy/maps/hpx.py:101: IndexError
- __________________________________________ test_hpxgeom_coord_to_idx[nside2-False-GAL-None-axes2] ___________________________________________
- nside = array([2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4,
- 8, 2, 4, 8]), nested = False, coordsys = 'GAL'
- region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x11808cba8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_coord_to_idx(nside, nested, coordsys, region, axes):
- from astropy_healpix import healpy as hp
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- lon = np.array([112.5, 135., 105.])
- lat = np.array([75.3, 75.3, 74.6])
- coords = make_test_coords(geom, lon, lat)
- zidx = [ax.coord_to_idx(t) for t, ax in zip(coords[2:], geom.axes)]
- if geom.nside.size > 1:
- nside = geom.nside[zidx]
- else:
- nside = geom.nside
- phi, theta = lonlat_to_colat(coords[0], coords[1])
- > idx = geom.coord_to_idx(coords)
- gammapy/maps/tests/test_hpx.py:200:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/geom.py:808: in coord_to_idx
- pix = self.coord_to_pix(coords)
- gammapy/maps/hpx.py:612: in coord_to_pix
- pix = hp.ang2pix(nside, theta, phi, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:105: in ang2pix
- return lonlat_to_healpix(lon, lat, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- lon = array([ 1.96349541, 1.96349541, 1.96349541, 2.35619449, 2.35619449,
- 2.35619449, 1.83259571, 1.83259571, ... 1.96349541,
- 1.96349541, 2.35619449, 2.35619449, 2.35619449, 1.83259571,
- 1.83259571, 1.83259571])
- lat = array([ 1.31423293, 1.31423293, 1.31423293, 1.31423293, 1.31423293,
- 1.31423293, 1.31423293, 1.31423293, ... 1.30201562,
- 1.30201562, 1.30201562, 1.30201562, 1.30201562, 1.30201562,
- 1.30201562, 1.30201562])
- nside = array([2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4, 8, 2, 4,
- 8, 2, 4, 8]), return_offsets = False
- order = 'ring'
- def lonlat_to_healpix(lon, lat, nside, return_offsets=False, order='ring'):
- """
- Convert longitudes/latitudes to HEALPix indices
- Parameters
- ----------
- lon, lat : :class:`~astropy.units.Quantity`
- The longitude and latitude values as :class:`~astropy.units.Quantity`
- instances with angle units.
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- order : { 'nested' | 'ring' }
- Order of HEALPix pixels
- return_offsets : bool, optional
- If `True`, the returned values are the HEALPix pixel indices as well as
- ``dx`` and ``dy``, the fractional positions inside the pixels. If
- `False` (the default), only the HEALPix pixel indices is returned.
- Returns
- -------
- healpix_index : int or `~numpy.ndarray`
- The HEALPix indices
- dx, dy : `~numpy.ndarray`
- Offsets inside the HEALPix pixel in the range [0:1], where 0.5 is the
- center of the HEALPix pixels
- """
- lon = lon.to(u.rad).value
- lat = lat.to(u.rad).value
- lon, lat = np.broadcast_arrays(lon, lat)
- shape = np.shape(lon)
- lon = lon.astype(float).ravel()
- lat = lat.astype(float).ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:341: TypeError
- ___________________________________ test_hpxgeom_coord_to_idx[nside6-False-GAL-DISK(110.,75.,10.)-axes6] ____________________________________
- nside = array([ 8, 16, 32, 8, 16, 32, 8, 16, 32, 8, 16, 32, 8, 16, 32, 8, 16,
- 32, 8, 16, 32, 8, 16, 32, 8, 16, 32])
- nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)', axes = [<gammapy.maps.geom.MapAxis object at 0x11808cc88>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_coord_to_idx(nside, nested, coordsys, region, axes):
- from astropy_healpix import healpy as hp
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- lon = np.array([112.5, 135., 105.])
- lat = np.array([75.3, 75.3, 74.6])
- coords = make_test_coords(geom, lon, lat)
- zidx = [ax.coord_to_idx(t) for t, ax in zip(coords[2:], geom.axes)]
- if geom.nside.size > 1:
- nside = geom.nside[zidx]
- else:
- nside = geom.nside
- phi, theta = lonlat_to_colat(coords[0], coords[1])
- > idx = geom.coord_to_idx(coords)
- gammapy/maps/tests/test_hpx.py:200:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/geom.py:808: in coord_to_idx
- pix = self.coord_to_pix(coords)
- gammapy/maps/hpx.py:612: in coord_to_pix
- pix = hp.ang2pix(nside, theta, phi, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:105: in ang2pix
- return lonlat_to_healpix(lon, lat, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- lon = array([ 1.96349541, 1.96349541, 1.96349541, 2.35619449, 2.35619449,
- 2.35619449, 1.83259571, 1.83259571, ... 1.96349541,
- 1.96349541, 2.35619449, 2.35619449, 2.35619449, 1.83259571,
- 1.83259571, 1.83259571])
- lat = array([ 1.31423293, 1.31423293, 1.31423293, 1.31423293, 1.31423293,
- 1.31423293, 1.31423293, 1.31423293, ... 1.30201562,
- 1.30201562, 1.30201562, 1.30201562, 1.30201562, 1.30201562,
- 1.30201562, 1.30201562])
- nside = array([ 8, 16, 32, 8, 16, 32, 8, 16, 32, 8, 16, 32, 8, 16, 32, 8, 16,
- 32, 8, 16, 32, 8, 16, 32, 8, 16, 32])
- return_offsets = False, order = 'ring'
- def lonlat_to_healpix(lon, lat, nside, return_offsets=False, order='ring'):
- """
- Convert longitudes/latitudes to HEALPix indices
- Parameters
- ----------
- lon, lat : :class:`~astropy.units.Quantity`
- The longitude and latitude values as :class:`~astropy.units.Quantity`
- instances with angle units.
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- order : { 'nested' | 'ring' }
- Order of HEALPix pixels
- return_offsets : bool, optional
- If `True`, the returned values are the HEALPix pixel indices as well as
- ``dx`` and ``dy``, the fractional positions inside the pixels. If
- `False` (the default), only the HEALPix pixel indices is returned.
- Returns
- -------
- healpix_index : int or `~numpy.ndarray`
- The HEALPix indices
- dx, dy : `~numpy.ndarray`
- Offsets inside the HEALPix pixel in the range [0:1], where 0.5 is the
- center of the HEALPix pixels
- """
- lon = lon.to(u.rad).value
- lat = lat.to(u.rad).value
- lon, lat = np.broadcast_arrays(lon, lat)
- shape = np.shape(lon)
- lon = lon.astype(float).ravel()
- lat = lat.astype(float).ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:341: TypeError
- ___________________________________ test_hpxgeom_coord_to_idx[nside7-False-GAL-DISK(110.,75.,10.)-axes7] ____________________________________
- nside = array([ 8, 16, 32, 8, 8, 16, 8, 16, 32, 8, 8, 16, 8, 16, 32, 8, 8,
- 16, 8, 16, 32, 8, 8, 16, 8, 16, ... 8, 16, 8, 16, 32, 8,
- 8, 16, 8, 16, 32, 8, 8, 16, 8, 16, 32, 8, 8, 16, 8, 16, 32,
- 8, 8, 16])
- nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)'
- axes = [<gammapy.maps.geom.MapAxis object at 0x11808ccc0>, <gammapy.maps.geom.MapAxis object at 0x11808ccf8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_coord_to_idx(nside, nested, coordsys, region, axes):
- from astropy_healpix import healpy as hp
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- lon = np.array([112.5, 135., 105.])
- lat = np.array([75.3, 75.3, 74.6])
- coords = make_test_coords(geom, lon, lat)
- zidx = [ax.coord_to_idx(t) for t, ax in zip(coords[2:], geom.axes)]
- if geom.nside.size > 1:
- nside = geom.nside[zidx]
- else:
- nside = geom.nside
- phi, theta = lonlat_to_colat(coords[0], coords[1])
- > idx = geom.coord_to_idx(coords)
- gammapy/maps/tests/test_hpx.py:200:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/geom.py:808: in coord_to_idx
- pix = self.coord_to_pix(coords)
- gammapy/maps/hpx.py:612: in coord_to_pix
- pix = hp.ang2pix(nside, theta, phi, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:105: in ang2pix
- return lonlat_to_healpix(lon, lat, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- lon = array([ 1.96349541, 1.96349541, 1.96349541, 1.96349541, 1.96349541,
- 1.96349541, 2.35619449, 2.35619449, ...619449, 2.35619449, 2.35619449, 1.83259571, 1.83259571,
- 1.83259571, 1.83259571, 1.83259571, 1.83259571])
- lat = array([ 1.31423293, 1.31423293, 1.31423293, 1.31423293, 1.31423293,
- 1.31423293, 1.31423293, 1.31423293, ...201562, 1.30201562, 1.30201562, 1.30201562, 1.30201562,
- 1.30201562, 1.30201562, 1.30201562, 1.30201562])
- nside = array([ 8, 16, 32, 8, 8, 16, 8, 16, 32, 8, 8, 16, 8, 16, 32, 8, 8,
- 16, 8, 16, 32, 8, 8, 16, 8, 16, ... 8, 16, 8, 16, 32, 8,
- 8, 16, 8, 16, 32, 8, 8, 16, 8, 16, 32, 8, 8, 16, 8, 16, 32,
- 8, 8, 16])
- return_offsets = False, order = 'ring'
- def lonlat_to_healpix(lon, lat, nside, return_offsets=False, order='ring'):
- """
- Convert longitudes/latitudes to HEALPix indices
- Parameters
- ----------
- lon, lat : :class:`~astropy.units.Quantity`
- The longitude and latitude values as :class:`~astropy.units.Quantity`
- instances with angle units.
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- order : { 'nested' | 'ring' }
- Order of HEALPix pixels
- return_offsets : bool, optional
- If `True`, the returned values are the HEALPix pixel indices as well as
- ``dx`` and ``dy``, the fractional positions inside the pixels. If
- `False` (the default), only the HEALPix pixel indices is returned.
- Returns
- -------
- healpix_index : int or `~numpy.ndarray`
- The HEALPix indices
- dx, dy : `~numpy.ndarray`
- Offsets inside the HEALPix pixel in the range [0:1], where 0.5 is the
- center of the HEALPix pixels
- """
- lon = lon.to(u.rad).value
- lat = lat.to(u.rad).value
- lon, lat = np.broadcast_arrays(lon, lat)
- shape = np.shape(lon)
- lon = lon.astype(float).ravel()
- lat = lat.astype(float).ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:341: TypeError
- __________________________________________________________ test_hpxgeom_get_coords __________________________________________________________
- def test_hpxgeom_get_coords():
- ax0 = np.linspace(0., 3., 4)
- # 2D all-sky
- hpx = HpxGeom(16, False, 'GAL')
- c = hpx.get_coords()
- assert_allclose(c[0][:3], np.array([45., 135., 225.]))
- assert_allclose(c[1][:3], np.array([87.075819, 87.075819, 87.075819]))
- # 3D all-sky
- hpx = HpxGeom(16, False, 'GAL', axes=[ax0])
- c = hpx.get_coords()
- assert_allclose(c[0][:3], np.array([45., 135., 225.]))
- assert_allclose(c[1][:3], np.array([87.075819, 87.075819, 87.075819]))
- assert_allclose(c[2][:3], np.array([0.5, 0.5, 0.5]))
- # 2D partial-sky
- hpx = HpxGeom(64, False, 'GAL', region='DISK(110.,75.,2.)')
- c = hpx.get_coords()
- > assert_allclose(c[0][:3], np.array([107.5, 112.5, 106.57894737]))
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 100.0%)
- E x: array([ 110.25 , 111.315789, 107.5 ])
- E y: array([ 107.5 , 112.5 , 106.578947])
- gammapy/maps/tests/test_hpx.py:322: AssertionError
- _______________________________________________ test_hpxgeom_contains[8-False-GAL-None-axes1] _______________________________________________
- nside = 8, nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x11808cb70>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_contains(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- coords = geom.get_coords()
- assert_allclose(geom.contains(coords), np.ones(
- coords[0].shape, dtype=bool))
- if axes is not None:
- coords = [c[0] for c in coords[:2]] + \
- [ax.edges[-1] + 1.0 for ax in axes]
- > assert_allclose(geom.contains(coords), np.zeros((1,), dtype=bool))
- gammapy/maps/tests/test_hpx.py:353:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1374: in contains
- idx = self.coord_to_idx(coords)
- gammapy/maps/geom.py:809: in coord_to_idx
- return self.pix_to_idx(pix)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpx.HpxGeom object at 0x118538d30>, pix = (0, array([ 2.50111111]))
- def pix_to_idx(self, pix):
- # FIXME: Correctly apply bounds on non-spatial pixel
- # coordinates
- idx = list(pix_tuple_to_idx(pix))
- idx_local = self.global_to_local(idx)
- for i, _ in enumerate(idx):
- > idx[i][(idx_local[i] < 0) | (idx[i] < 0)] = -1
- E IndexError: too many indices for array
- gammapy/maps/hpx.py:654: IndexError
- ____________________________________________ test_hpxgeom_contains[nside2-False-GAL-None-axes2] _____________________________________________
- nside = [2, 4, 8], nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x11808cba8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_contains(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- > coords = geom.get_coords()
- gammapy/maps/tests/test_hpx.py:345:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1370: in get_coords
- return self.pix_to_coord(pix)
- gammapy/maps/hpx.py:637: in pix_to_coord
- theta, phi = hp.pix2ang(nside, ipix, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:98: in pix2ang
- lon, lat = healpix_to_lonlat(ipix, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- healpix_index = array([ 0, 1, 2, ..., 765, 766, 767]), nside = array([2, 2, 2, ..., 8, 8, 8]), dx = None, dy = None, order = 'ring'
- def healpix_to_lonlat(healpix_index, nside, dx=None, dy=None, order='ring'):
- """
- Convert HEALPix indices (optionally with offsets) to longitudes/latitudes.
- If no offsets (``dx`` and ``dy``) are provided, the coordinates will default
- to those at the center of the HEALPix pixels.
- Parameters
- ----------
- healpix_index : int or `~numpy.ndarray`
- HEALPix indices (as a scalar or array)
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- dx, dy : float or `~numpy.ndarray`, optional
- Offsets inside the HEALPix pixel, which must be in the range [0:1],
- where 0.5 is the center of the HEALPix pixels (as scalars or arrays)
- order : { 'nested' | 'ring' }, optional
- Order of HEALPix pixels
- Returns
- -------
- lon : :class:`~astropy.coordinates.Longitude`
- The longitude values
- lat : :class:`~astropy.coordinates.Latitude`
- The latitude values
- """
- if (dx is None and dy is not None) or (dx is not None and dy is None):
- raise ValueError('Either both or neither dx and dy must be specified')
- healpix_index = np.asarray(healpix_index, dtype=np.int64)
- if dx is None and dy is not None:
- dx = 0.5
- elif dx is not None and dy is None:
- dy = 0.5
- if dx is not None:
- dx = np.asarray(dx, dtype=np.float)
- dy = np.asarray(dy, dtype=np.float)
- _validate_offset('x', dx)
- _validate_offset('y', dy)
- healpix_index, dx, dy = np.broadcast_arrays(healpix_index, dx, dy)
- dx = dx.ravel()
- dy = dy.ravel()
- shape = healpix_index.shape
- healpix_index = healpix_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:287: TypeError
- _______________________________________________ test_hpxgeom_contains[8-False-GAL-None-axes3] _______________________________________________
- nside = 8, nested = False, coordsys = 'GAL', region = None
- axes = [<gammapy.maps.geom.MapAxis object at 0x11808cbe0>, <gammapy.maps.geom.MapAxis object at 0x11808cc18>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_contains(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- coords = geom.get_coords()
- assert_allclose(geom.contains(coords), np.ones(
- coords[0].shape, dtype=bool))
- if axes is not None:
- coords = [c[0] for c in coords[:2]] + \
- [ax.edges[-1] + 1.0 for ax in axes]
- > assert_allclose(geom.contains(coords), np.zeros((1,), dtype=bool))
- gammapy/maps/tests/test_hpx.py:353:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1374: in contains
- idx = self.coord_to_idx(coords)
- gammapy/maps/geom.py:809: in coord_to_idx
- return self.pix_to_idx(pix)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpx.HpxGeom object at 0x118407ac8>, pix = (0, array([ 1.50103266]), array([ 2.51274605]))
- def pix_to_idx(self, pix):
- # FIXME: Correctly apply bounds on non-spatial pixel
- # coordinates
- idx = list(pix_tuple_to_idx(pix))
- idx_local = self.global_to_local(idx)
- for i, _ in enumerate(idx):
- > idx[i][(idx_local[i] < 0) | (idx[i] < 0)] = -1
- E IndexError: too many indices for array
- gammapy/maps/hpx.py:654: IndexError
- ________________________________________ test_hpxgeom_contains[8-False-GAL-DISK(110.,75.,10.)-None] _________________________________________
- nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)', axes = None
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_contains(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- coords = geom.get_coords()
- assert_allclose(geom.contains(coords), np.ones(
- coords[0].shape, dtype=bool))
- if axes is not None:
- coords = [c[0] for c in coords[:2]] + \
- [ax.edges[-1] + 1.0 for ax in axes]
- assert_allclose(geom.contains(coords), np.zeros((1,), dtype=bool))
- if geom.region is not None:
- coords = [0.0, 0.0] + [ax.center[0] for ax in geom.axes]
- > assert_allclose(geom.contains(coords), np.zeros((1,), dtype=bool))
- gammapy/maps/tests/test_hpx.py:358:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1374: in contains
- idx = self.coord_to_idx(coords)
- gammapy/maps/geom.py:809: in coord_to_idx
- return self.pix_to_idx(pix)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpx.HpxGeom object at 0x1189f4a20>, pix = (336,)
- def pix_to_idx(self, pix):
- # FIXME: Correctly apply bounds on non-spatial pixel
- # coordinates
- idx = list(pix_tuple_to_idx(pix))
- idx_local = self.global_to_local(idx)
- for i, _ in enumerate(idx):
- > idx[i][(idx_local[i] < 0) | (idx[i] < 0)] = -1
- E IndexError: too many indices for array
- gammapy/maps/hpx.py:654: IndexError
- ________________________________________ test_hpxgeom_contains[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 0x11808cc50>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_contains(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- coords = geom.get_coords()
- assert_allclose(geom.contains(coords), np.ones(
- coords[0].shape, dtype=bool))
- if axes is not None:
- coords = [c[0] for c in coords[:2]] + \
- [ax.edges[-1] + 1.0 for ax in axes]
- > assert_allclose(geom.contains(coords), np.zeros((1,), dtype=bool))
- gammapy/maps/tests/test_hpx.py:353:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1374: in contains
- idx = self.coord_to_idx(coords)
- gammapy/maps/geom.py:809: in coord_to_idx
- return self.pix_to_idx(pix)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpx.HpxGeom object at 0x118a0c518>, pix = (6, array([ 2.50111111]))
- def pix_to_idx(self, pix):
- # FIXME: Correctly apply bounds on non-spatial pixel
- # coordinates
- idx = list(pix_tuple_to_idx(pix))
- idx_local = self.global_to_local(idx)
- for i, _ in enumerate(idx):
- > idx[i][(idx_local[i] < 0) | (idx[i] < 0)] = -1
- E IndexError: too many indices for array
- gammapy/maps/hpx.py:654: IndexError
- _____________________________________ test_hpxgeom_contains[nside6-False-GAL-DISK(110.,75.,10.)-axes6] ______________________________________
- nside = [8, 16, 32], nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)'
- axes = [<gammapy.maps.geom.MapAxis object at 0x11808cc88>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_contains(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- > coords = geom.get_coords()
- gammapy/maps/tests/test_hpx.py:345:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1370: in get_coords
- return self.pix_to_coord(pix)
- gammapy/maps/hpx.py:637: in pix_to_coord
- theta, phi = hp.pix2ang(nside, ipix, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:98: in pix2ang
- lon, lat = healpix_to_lonlat(ipix, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- healpix_index = array([ 6, 1, 0, 5, 14, 15, 29, 16, 7, 28, 46, 27, 46,
- 29, 15, 28, 45, 67, 93, 68, 47,..., 380, 326, 379, 276, 325, 45, 92, 67, 46, 28, 93,
- 68, 47, 29, 94, 69, 48, 30, 95, 70, 15, 27])
- nside = array([ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, ...32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32])
- dx = None, dy = None, order = 'ring'
- def healpix_to_lonlat(healpix_index, nside, dx=None, dy=None, order='ring'):
- """
- Convert HEALPix indices (optionally with offsets) to longitudes/latitudes.
- If no offsets (``dx`` and ``dy``) are provided, the coordinates will default
- to those at the center of the HEALPix pixels.
- Parameters
- ----------
- healpix_index : int or `~numpy.ndarray`
- HEALPix indices (as a scalar or array)
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- dx, dy : float or `~numpy.ndarray`, optional
- Offsets inside the HEALPix pixel, which must be in the range [0:1],
- where 0.5 is the center of the HEALPix pixels (as scalars or arrays)
- order : { 'nested' | 'ring' }, optional
- Order of HEALPix pixels
- Returns
- -------
- lon : :class:`~astropy.coordinates.Longitude`
- The longitude values
- lat : :class:`~astropy.coordinates.Latitude`
- The latitude values
- """
- if (dx is None and dy is not None) or (dx is not None and dy is None):
- raise ValueError('Either both or neither dx and dy must be specified')
- healpix_index = np.asarray(healpix_index, dtype=np.int64)
- if dx is None and dy is not None:
- dx = 0.5
- elif dx is not None and dy is None:
- dy = 0.5
- if dx is not None:
- dx = np.asarray(dx, dtype=np.float)
- dy = np.asarray(dy, dtype=np.float)
- _validate_offset('x', dx)
- _validate_offset('y', dy)
- healpix_index, dx, dy = np.broadcast_arrays(healpix_index, dx, dy)
- dx = dx.ravel()
- dy = dy.ravel()
- shape = healpix_index.shape
- healpix_index = healpix_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:287: TypeError
- _____________________________________ test_hpxgeom_contains[nside7-False-GAL-DISK(110.,75.,10.)-axes7] ______________________________________
- nside = [[8, 16, 32], [8, 8, 16]], nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)'
- axes = [<gammapy.maps.geom.MapAxis object at 0x11808ccc0>, <gammapy.maps.geom.MapAxis object at 0x11808ccf8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxgeom_contains(nside, nested, coordsys, region, axes):
- geom = HpxGeom(nside, nested, coordsys, region=region, axes=axes)
- > coords = geom.get_coords()
- gammapy/maps/tests/test_hpx.py:345:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1370: in get_coords
- return self.pix_to_coord(pix)
- gammapy/maps/hpx.py:637: in pix_to_coord
- theta, phi = hp.pix2ang(nside, ipix, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:98: in pix2ang
- lon, lat = healpix_to_lonlat(ipix, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- healpix_index = array([ 6, 1, 0, 5, 14, 15, 29, 16, 7, 28, 46, 27, 46,
- 29, 15, 28, 45, 67, 93, 68, 47,... 7, 6,
- 5, 14, 43, 27, 64, 44, 65, 66, 90, 91, 121, 92, 155,
- 122, 156, 123, 154, 120, 119])
- nside = array([ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, ... 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16])
- dx = None, dy = None, order = 'ring'
- def healpix_to_lonlat(healpix_index, nside, dx=None, dy=None, order='ring'):
- """
- Convert HEALPix indices (optionally with offsets) to longitudes/latitudes.
- If no offsets (``dx`` and ``dy``) are provided, the coordinates will default
- to those at the center of the HEALPix pixels.
- Parameters
- ----------
- healpix_index : int or `~numpy.ndarray`
- HEALPix indices (as a scalar or array)
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- dx, dy : float or `~numpy.ndarray`, optional
- Offsets inside the HEALPix pixel, which must be in the range [0:1],
- where 0.5 is the center of the HEALPix pixels (as scalars or arrays)
- order : { 'nested' | 'ring' }, optional
- Order of HEALPix pixels
- Returns
- -------
- lon : :class:`~astropy.coordinates.Longitude`
- The longitude values
- lat : :class:`~astropy.coordinates.Latitude`
- The latitude values
- """
- if (dx is None and dy is not None) or (dx is not None and dy is None):
- raise ValueError('Either both or neither dx and dy must be specified')
- healpix_index = np.asarray(healpix_index, dtype=np.int64)
- if dx is None and dy is not None:
- dx = 0.5
- elif dx is not None and dy is None:
- dy = 0.5
- if dx is not None:
- dx = np.asarray(dx, dtype=np.float)
- dy = np.asarray(dy, dtype=np.float)
- _validate_offset('x', dx)
- _validate_offset('y', dy)
- healpix_index, dx, dy = np.broadcast_arrays(healpix_index, dx, dy)
- dx = dx.ravel()
- dy = dy.ravel()
- shape = healpix_index.shape
- healpix_index = healpix_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:287: TypeError
- _______________________________________________________ test_make_hpx_to_wcs_mapping ________________________________________________________
- def test_make_hpx_to_wcs_mapping():
- ax0 = np.linspace(0., 1., 3)
- hpx = HpxGeom(16, False, 'GAL', region='DISK(110.,75.,2.)')
- # FIXME construct explicit WCS projection here
- wcs = hpx.make_wcs()
- hpx2wcs = make_hpx_to_wcs_mapping(hpx, wcs)
- assert_allclose(hpx2wcs[0],
- np.array([67, 46, 46, 46, 46, 29, 67, 67, 46, 46,
- 46, 46, 67, 67, 67, 46, 46, 46, 67, 67,
- 67, 28, 28, 28, 45, 45, 45, 45, 28, 28,
- 66, 45, 45, 45, 45, 28]))
- assert_allclose(hpx2wcs[1],
- np.array([0.11111111, 0.09090909, 0.09090909, 0.09090909,
- 0.09090909, 1., 0.11111111, 0.11111111, 0.09090909,
- 0.09090909, 0.09090909, 0.09090909, 0.11111111,
- 0.11111111, 0.11111111, 0.09090909, 0.09090909,
- 0.09090909, 0.11111111, 0.11111111, 0.11111111,
- 0.16666667, 0.16666667, 0.16666667, 0.125,
- 0.125, 0.125, 0.125, 0.16666667, 0.16666667,
- 1., 0.125, 0.125, 0.125, 0.125, 0.16666667]))
- hpx = HpxGeom([8, 16], False, 'GAL',
- region='DISK(110.,75.,2.)', axes=[ax0])
- > hpx2wcs = make_hpx_to_wcs_mapping(hpx, wcs)
- gammapy/maps/tests/test_hpx.py:384:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:289: in make_hpx_to_wcs_mapping
- hpx.nest).flatten()
- ../astropy-healpix/astropy_healpix/healpy.py:105: in ang2pix
- return lonlat_to_healpix(lon, lat, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- lon = array([ 2.06399919, 2.07237334, 2.08180679, 2.09251182, 2.10476085,
- 2.118909 , 2.00669982, 2.0117912 , ... 1.80816208, 1.79948062,
- 1.77572516, 1.76735101, 1.75791757, 1.74721254, 1.73496351,
- 1.72081536])
- lat = array([ 1.26231867, 1.27959765, 1.29685147, 1.31407677, 1.33126886,
- 1.34842119, 1.26426183, 1.28165346, ... 1.33376308, 1.35110788,
- 1.26231867, 1.27959765, 1.29685147, 1.31407677, 1.33126886,
- 1.34842119])
- nside = array([[ 8],
- [16]]), return_offsets = False, order = 'ring'
- def lonlat_to_healpix(lon, lat, nside, return_offsets=False, order='ring'):
- """
- Convert longitudes/latitudes to HEALPix indices
- Parameters
- ----------
- lon, lat : :class:`~astropy.units.Quantity`
- The longitude and latitude values as :class:`~astropy.units.Quantity`
- instances with angle units.
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- order : { 'nested' | 'ring' }
- Order of HEALPix pixels
- return_offsets : bool, optional
- If `True`, the returned values are the HEALPix pixel indices as well as
- ``dx`` and ``dy``, the fractional positions inside the pixels. If
- `False` (the default), only the HEALPix pixel indices is returned.
- Returns
- -------
- healpix_index : int or `~numpy.ndarray`
- The HEALPix indices
- dx, dy : `~numpy.ndarray`
- Offsets inside the HEALPix pixel in the range [0:1], where 0.5 is the
- center of the HEALPix pixels
- """
- lon = lon.to(u.rad).value
- lat = lat.to(u.rad).value
- lon, lat = np.broadcast_arrays(lon, lat)
- shape = np.shape(lon)
- lon = lon.astype(float).ravel()
- lat = lat.astype(float).ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:341: TypeError
- _______________________________________ test_hpxcube_read_write[8-False-GAL-DISK(110.,75.,10.)-axes3] _______________________________________
- tmpdir = local('/private/var/folders/sb/4qv5j4m90pz1rw7m70rj1b1r0000gn/T/pytest-of-deil/pytest-27/test_hpxcube_read_write_8_Fals2')
- nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)', axes = [<gammapy.maps.geom.MapAxis object at 0x1180da7f0>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_read_write(tmpdir, nside, nested, coordsys, region, axes):
- filename = str(tmpdir / 'skycube.fits')
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- m.fill_poisson(0.5)
- m.write(filename)
- m2 = HpxMapND.read(filename)
- assert_allclose(m.data, m2.data)
- m.write(filename, sparse=True)
- m2 = HpxMapND.read(filename)
- > assert_allclose(m.data, m2.data)
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 13.333333333333329%)
- E x: array([ 0., 1., 3., 1., 2., 0., 0., 2., 1., 1., 1., 0., 0.,
- E 0., 1.], dtype=float32)
- E y: array([ 0., 1., 3., 1., 2., 0., 0., 2., 1., 1., 0., 0., 1.,
- E 0., 1.], dtype=float32)
- gammapy/maps/tests/test_hpxcube.py:62: AssertionError
- _______________________________________ test_hpxcube_read_write[8-False-GAL-DISK(110.,75.,10.)-axes4] _______________________________________
- tmpdir = local('/private/var/folders/sb/4qv5j4m90pz1rw7m70rj1b1r0000gn/T/pytest-of-deil/pytest-27/test_hpxcube_read_write_8_Fals3')
- nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)'
- axes = [<gammapy.maps.geom.MapAxis object at 0x1180da828>, <gammapy.maps.geom.MapAxis object at 0x1180da860>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_read_write(tmpdir, nside, nested, coordsys, region, axes):
- filename = str(tmpdir / 'skycube.fits')
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- m.fill_poisson(0.5)
- m.write(filename)
- m2 = HpxMapND.read(filename)
- assert_allclose(m.data, m2.data)
- m.write(filename, sparse=True)
- m2 = HpxMapND.read(filename)
- > assert_allclose(m.data, m2.data)
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 6.666666666666671%)
- E x: array([ 0., 0., 3., 1., 1., 1., 0., 1., 1., 0., 1., 1., 1.,
- E 6., 3., 0., 1., 1., 4., 1., 0., 0., 3., 3., 0., 0.,
- E 1., 2., 3., 0.], dtype=float32)
- E y: array([ 0., 0., 3., 1., 1., 0., 0., 1., 1., 0., 0., 1., 1.,
- E 6., 3., 0., 1., 1., 4., 1., 0., 0., 3., 3., 0., 0.,
- E 1., 2., 3., 0.], dtype=float32)
- gammapy/maps/tests/test_hpxcube.py:62: AssertionError
- _________________________________________ test_hpxcube_set_get_by_pix[nside2-False-GAL-None-axes2] __________________________________________
- nside = [4, 8], nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x1180da6d8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_set_get_by_pix(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- > coords = m.hpx.get_coords()
- gammapy/maps/tests/test_hpxcube.py:70:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1370: in get_coords
- return self.pix_to_coord(pix)
- gammapy/maps/hpx.py:637: in pix_to_coord
- theta, phi = hp.pix2ang(nside, ipix, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:98: in pix2ang
- lon, lat = healpix_to_lonlat(ipix, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- healpix_index = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20,..., 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756,
- 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767])
- 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])
- dx = None, dy = None, order = 'ring'
- def healpix_to_lonlat(healpix_index, nside, dx=None, dy=None, order='ring'):
- """
- Convert HEALPix indices (optionally with offsets) to longitudes/latitudes.
- If no offsets (``dx`` and ``dy``) are provided, the coordinates will default
- to those at the center of the HEALPix pixels.
- Parameters
- ----------
- healpix_index : int or `~numpy.ndarray`
- HEALPix indices (as a scalar or array)
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- dx, dy : float or `~numpy.ndarray`, optional
- Offsets inside the HEALPix pixel, which must be in the range [0:1],
- where 0.5 is the center of the HEALPix pixels (as scalars or arrays)
- order : { 'nested' | 'ring' }, optional
- Order of HEALPix pixels
- Returns
- -------
- lon : :class:`~astropy.coordinates.Longitude`
- The longitude values
- lat : :class:`~astropy.coordinates.Latitude`
- The latitude values
- """
- if (dx is None and dy is not None) or (dx is not None and dy is None):
- raise ValueError('Either both or neither dx and dy must be specified')
- healpix_index = np.asarray(healpix_index, dtype=np.int64)
- if dx is None and dy is not None:
- dx = 0.5
- elif dx is not None and dy is None:
- dy = 0.5
- if dx is not None:
- dx = np.asarray(dx, dtype=np.float)
- dy = np.asarray(dy, dtype=np.float)
- _validate_offset('x', dx)
- _validate_offset('y', dy)
- healpix_index, dx, dy = np.broadcast_arrays(healpix_index, dx, dy)
- dx = dx.ravel()
- dy = dy.ravel()
- shape = healpix_index.shape
- healpix_index = healpix_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:287: TypeError
- _____________________________________ test_hpxcube_set_get_by_pix[8-False-GAL-DISK(110.,75.,10.)-axes3] _____________________________________
- nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)', axes = [<gammapy.maps.geom.MapAxis object at 0x1180da7f0>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_set_get_by_pix(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- coords = m.hpx.get_coords()
- pix = m.hpx.get_pixels()
- m.set_by_pix(pix, coords[0])
- > assert_allclose(coords[0], m.get_by_pix(pix))
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 58.333333333333336%)
- E x: array([ 112.5 , 135. , 45. , 67.5 , 75. , 105. , 123.75,
- E 135. , 157.5 , 101.25, 117. , 78.75, 112.5 , 135. ,
- E 45. , 67.5 , 75. , 105. , 123.75, 135. , 157.5 ,...
- E y: array([ 157.5 , 67.5 , 45. , 67.5 , 157.5 , 78.75, 117. ,
- E 78.75, 157.5 , 78.75, 117. , 78.75, 157.5 , 67.5 ,
- E 45. , 67.5 , 157.5 , 78.75, 117. , 78.75, 157.5 ,...
- gammapy/maps/tests/test_hpxcube.py:73: AssertionError
- _____________________________________ test_hpxcube_set_get_by_pix[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 0x1180da828>, <gammapy.maps.geom.MapAxis object at 0x1180da860>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_set_get_by_pix(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- coords = m.hpx.get_coords()
- pix = m.hpx.get_pixels()
- m.set_by_pix(pix, coords[0])
- > assert_allclose(coords[0], m.get_by_pix(pix))
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 58.333333333333336%)
- E x: array([ 112.5 , 135. , 45. , 67.5 , 75. , 105. , 123.75,
- E 135. , 157.5 , 101.25, 117. , 78.75, 112.5 , 135. ,
- E 45. , 67.5 , 75. , 105. , 123.75, 135. , 157.5 ,...
- E y: array([ 157.5 , 67.5 , 45. , 67.5 , 157.5 , 78.75, 117. ,
- E 78.75, 157.5 , 78.75, 117. , 78.75, 157.5 , 67.5 ,
- E 45. , 67.5 , 157.5 , 78.75, 117. , 78.75, 157.5 ,...
- gammapy/maps/tests/test_hpxcube.py:73: AssertionError
- ________________________________________ test_hpxcube_set_get_by_coords[nside2-False-GAL-None-axes2] ________________________________________
- nside = [4, 8], nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x1180da6d8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_set_get_by_coords(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- > coords = m.hpx.get_coords()
- gammapy/maps/tests/test_hpxcube.py:81:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1370: in get_coords
- return self.pix_to_coord(pix)
- gammapy/maps/hpx.py:637: in pix_to_coord
- theta, phi = hp.pix2ang(nside, ipix, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:98: in pix2ang
- lon, lat = healpix_to_lonlat(ipix, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- healpix_index = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20,..., 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756,
- 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767])
- 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])
- dx = None, dy = None, order = 'ring'
- def healpix_to_lonlat(healpix_index, nside, dx=None, dy=None, order='ring'):
- """
- Convert HEALPix indices (optionally with offsets) to longitudes/latitudes.
- If no offsets (``dx`` and ``dy``) are provided, the coordinates will default
- to those at the center of the HEALPix pixels.
- Parameters
- ----------
- healpix_index : int or `~numpy.ndarray`
- HEALPix indices (as a scalar or array)
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- dx, dy : float or `~numpy.ndarray`, optional
- Offsets inside the HEALPix pixel, which must be in the range [0:1],
- where 0.5 is the center of the HEALPix pixels (as scalars or arrays)
- order : { 'nested' | 'ring' }, optional
- Order of HEALPix pixels
- Returns
- -------
- lon : :class:`~astropy.coordinates.Longitude`
- The longitude values
- lat : :class:`~astropy.coordinates.Latitude`
- The latitude values
- """
- if (dx is None and dy is not None) or (dx is not None and dy is None):
- raise ValueError('Either both or neither dx and dy must be specified')
- healpix_index = np.asarray(healpix_index, dtype=np.int64)
- if dx is None and dy is not None:
- dx = 0.5
- elif dx is not None and dy is None:
- dy = 0.5
- if dx is not None:
- dx = np.asarray(dx, dtype=np.float)
- dy = np.asarray(dy, dtype=np.float)
- _validate_offset('x', dx)
- _validate_offset('y', dy)
- healpix_index, dx, dy = np.broadcast_arrays(healpix_index, dx, dy)
- dx = dx.ravel()
- dy = dy.ravel()
- shape = healpix_index.shape
- healpix_index = healpix_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:287: TypeError
- ___________________________________ test_hpxcube_set_get_by_coords[8-False-GAL-DISK(110.,75.,10.)-axes3] ____________________________________
- nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)', axes = [<gammapy.maps.geom.MapAxis object at 0x1180da7f0>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_set_get_by_coords(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- coords = m.hpx.get_coords()
- m.set_by_coords(coords, coords[0])
- > assert_allclose(coords[0], m.get_by_coords(coords))
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 58.333333333333336%)
- E x: array([ 112.5 , 135. , 45. , 67.5 , 75. , 105. , 123.75,
- E 135. , 157.5 , 101.25, 117. , 78.75, 112.5 , 135. ,
- E 45. , 67.5 , 75. , 105. , 123.75, 135. , 157.5 ,...
- E y: array([ 157.5 , 67.5 , 45. , 67.5 , 157.5 , 78.75, 117. ,
- E 78.75, 157.5 , 78.75, 117. , 78.75, 157.5 , 67.5 ,
- E 45. , 67.5 , 157.5 , 78.75, 117. , 78.75, 157.5 ,...
- gammapy/maps/tests/test_hpxcube.py:83: AssertionError
- ___________________________________ test_hpxcube_set_get_by_coords[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 0x1180da828>, <gammapy.maps.geom.MapAxis object at 0x1180da860>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_set_get_by_coords(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- coords = m.hpx.get_coords()
- m.set_by_coords(coords, coords[0])
- > assert_allclose(coords[0], m.get_by_coords(coords))
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 58.333333333333336%)
- E x: array([ 112.5 , 135. , 45. , 67.5 , 75. , 105. , 123.75,
- E 135. , 157.5 , 101.25, 117. , 78.75, 112.5 , 135. ,
- E 45. , 67.5 , 75. , 105. , 123.75, 135. , 157.5 ,...
- E y: array([ 157.5 , 67.5 , 45. , 67.5 , 157.5 , 78.75, 117. ,
- E 78.75, 157.5 , 78.75, 117. , 78.75, 157.5 , 67.5 ,
- E 45. , 67.5 , 157.5 , 78.75, 117. , 78.75, 157.5 ,...
- gammapy/maps/tests/test_hpxcube.py:83: AssertionError
- _________________________________________ test_hpxcube_fill_by_coords[nside2-False-GAL-None-axes2] __________________________________________
- nside = [4, 8], nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x1180da6d8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_fill_by_coords(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- > coords = m.hpx.get_coords()
- gammapy/maps/tests/test_hpxcube.py:103:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1370: in get_coords
- return self.pix_to_coord(pix)
- gammapy/maps/hpx.py:637: in pix_to_coord
- theta, phi = hp.pix2ang(nside, ipix, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:98: in pix2ang
- lon, lat = healpix_to_lonlat(ipix, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- healpix_index = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20,..., 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756,
- 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767])
- 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])
- dx = None, dy = None, order = 'ring'
- def healpix_to_lonlat(healpix_index, nside, dx=None, dy=None, order='ring'):
- """
- Convert HEALPix indices (optionally with offsets) to longitudes/latitudes.
- If no offsets (``dx`` and ``dy``) are provided, the coordinates will default
- to those at the center of the HEALPix pixels.
- Parameters
- ----------
- healpix_index : int or `~numpy.ndarray`
- HEALPix indices (as a scalar or array)
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- dx, dy : float or `~numpy.ndarray`, optional
- Offsets inside the HEALPix pixel, which must be in the range [0:1],
- where 0.5 is the center of the HEALPix pixels (as scalars or arrays)
- order : { 'nested' | 'ring' }, optional
- Order of HEALPix pixels
- Returns
- -------
- lon : :class:`~astropy.coordinates.Longitude`
- The longitude values
- lat : :class:`~astropy.coordinates.Latitude`
- The latitude values
- """
- if (dx is None and dy is not None) or (dx is not None and dy is None):
- raise ValueError('Either both or neither dx and dy must be specified')
- healpix_index = np.asarray(healpix_index, dtype=np.int64)
- if dx is None and dy is not None:
- dx = 0.5
- elif dx is not None and dy is None:
- dy = 0.5
- if dx is not None:
- dx = np.asarray(dx, dtype=np.float)
- dy = np.asarray(dy, dtype=np.float)
- _validate_offset('x', dx)
- _validate_offset('y', dy)
- healpix_index, dx, dy = np.broadcast_arrays(healpix_index, dx, dy)
- dx = dx.ravel()
- dy = dy.ravel()
- shape = healpix_index.shape
- healpix_index = healpix_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:287: TypeError
- _____________________________________ test_hpxcube_fill_by_coords[8-False-GAL-DISK(110.,75.,10.)-axes3] _____________________________________
- nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)', axes = [<gammapy.maps.geom.MapAxis object at 0x1180da7f0>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_fill_by_coords(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- coords = m.hpx.get_coords()
- m.fill_by_coords(coords, coords[1])
- m.fill_by_coords(coords, coords[1])
- > assert_allclose(m.get_by_coords(coords), 2.0 * coords[1])
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 91.66666666666667%)
- E x: array([ 457.911713, 324.867767, 168.299469, 324.867767, 457.911713,
- E 555.324402, 253.755951, 555.324402, 457.911713, 555.324402,
- E 253.755951, 555.324402, 457.911713, 324.867767, 168.299469,...
- E y: array([ 156.568295, 168.299466, 168.299466, 156.568295, 144.775122,
- E 144.775122, 132.887071, 144.775122, 156.568295, 132.887071,
- E 120.868878, 132.887071, 156.568295, 168.299466, 168.299466,...
- gammapy/maps/tests/test_hpxcube.py:106: AssertionError
- _____________________________________ test_hpxcube_fill_by_coords[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 0x1180da828>, <gammapy.maps.geom.MapAxis object at 0x1180da860>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_fill_by_coords(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- coords = m.hpx.get_coords()
- m.fill_by_coords(coords, coords[1])
- m.fill_by_coords(coords, coords[1])
- > assert_allclose(m.get_by_coords(coords), 2.0 * coords[1])
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 91.66666666666667%)
- E x: array([ 457.911713, 324.867767, 168.299469, 324.867767, 457.911713,
- E 555.324402, 253.755951, 555.324402, 457.911713, 555.324402,
- E 253.755951, 555.324402, 457.911713, 324.867767, 168.299469,...
- E y: array([ 156.568295, 168.299466, 168.299466, 156.568295, 144.775122,
- E 144.775122, 132.887071, 144.775122, 156.568295, 132.887071,
- E 120.868878, 132.887071, 156.568295, 168.299466, 168.299466,...
- gammapy/maps/tests/test_hpxcube.py:106: AssertionError
- ______________________________________________ test_hpxcube_iter[nside2-False-GAL-None-axes2] _______________________________________________
- nside = [4, 8], nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x1180da6d8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_iter(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- > coords = m.geom.get_coords()
- gammapy/maps/tests/test_hpxcube.py:114:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1370: in get_coords
- return self.pix_to_coord(pix)
- gammapy/maps/hpx.py:637: in pix_to_coord
- theta, phi = hp.pix2ang(nside, ipix, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:98: in pix2ang
- lon, lat = healpix_to_lonlat(ipix, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- healpix_index = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20,..., 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756,
- 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767])
- 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])
- dx = None, dy = None, order = 'ring'
- def healpix_to_lonlat(healpix_index, nside, dx=None, dy=None, order='ring'):
- """
- Convert HEALPix indices (optionally with offsets) to longitudes/latitudes.
- If no offsets (``dx`` and ``dy``) are provided, the coordinates will default
- to those at the center of the HEALPix pixels.
- Parameters
- ----------
- healpix_index : int or `~numpy.ndarray`
- HEALPix indices (as a scalar or array)
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- dx, dy : float or `~numpy.ndarray`, optional
- Offsets inside the HEALPix pixel, which must be in the range [0:1],
- where 0.5 is the center of the HEALPix pixels (as scalars or arrays)
- order : { 'nested' | 'ring' }, optional
- Order of HEALPix pixels
- Returns
- -------
- lon : :class:`~astropy.coordinates.Longitude`
- The longitude values
- lat : :class:`~astropy.coordinates.Latitude`
- The latitude values
- """
- if (dx is None and dy is not None) or (dx is not None and dy is None):
- raise ValueError('Either both or neither dx and dy must be specified')
- healpix_index = np.asarray(healpix_index, dtype=np.int64)
- if dx is None and dy is not None:
- dx = 0.5
- elif dx is not None and dy is None:
- dy = 0.5
- if dx is not None:
- dx = np.asarray(dx, dtype=np.float)
- dy = np.asarray(dy, dtype=np.float)
- _validate_offset('x', dx)
- _validate_offset('y', dy)
- healpix_index, dx, dy = np.broadcast_arrays(healpix_index, dx, dy)
- dx = dx.ravel()
- dy = dy.ravel()
- shape = healpix_index.shape
- healpix_index = healpix_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:287: TypeError
- __________________________________________ test_hpxcube_iter[8-False-GAL-DISK(110.,75.,10.)-axes3] __________________________________________
- nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)', axes = [<gammapy.maps.geom.MapAxis object at 0x1180da7f0>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_iter(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- coords = m.geom.get_coords()
- m.fill_by_coords(coords, coords[0])
- > for vals, pix in m.iter_by_pix(buffersize=100):
- gammapy/maps/tests/test_hpxcube.py:116:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpxcube.HpxMapND object at 0x1185381d0>, buffersize = 100
- def iter_by_pix(self, buffersize=1):
- pix = list(self.geom.get_pixels())
- vals = self.data[np.isfinite(self.data)]
- return unpack_seq(np.nditer([vals] + pix,
- flags=['external_loop', 'buffered'],
- > buffersize=buffersize))
- E ValueError: operands could not be broadcast together with shapes (15,) (36,) (36,)
- gammapy/maps/hpxcube.py:175: ValueError
- __________________________________________ test_hpxcube_iter[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 0x1180da828>, <gammapy.maps.geom.MapAxis object at 0x1180da860>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_iter(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- coords = m.geom.get_coords()
- m.fill_by_coords(coords, coords[0])
- > for vals, pix in m.iter_by_pix(buffersize=100):
- gammapy/maps/tests/test_hpxcube.py:116:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpxcube.HpxMapND object at 0x118301470>, buffersize = 100
- def iter_by_pix(self, buffersize=1):
- pix = list(self.geom.get_pixels())
- vals = self.data[np.isfinite(self.data)]
- return unpack_seq(np.nditer([vals] + pix,
- flags=['external_loop', 'buffered'],
- > buffersize=buffersize))
- E ValueError: operands could not be broadcast together with shapes (30,) (72,) (72,) (72,)
- gammapy/maps/hpxcube.py:175: ValueError
- _____________________________________________ test_hpxcube_to_wcs[nside2-False-GAL-None-axes2] ______________________________________________
- nside = [4, 8], nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x1180da6d8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_to_wcs(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- > m_wcs = m.to_wcs(sum_bands=False, oversample=2, normalize=False)
- gammapy/maps/tests/test_hpxcube.py:127:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpxcube.py:135: in to_wcs
- self.make_wcs_mapping(oversample=oversample, proj=proj)
- gammapy/maps/hpxcube.py:123: in make_wcs_mapping
- self._hpx2wcs = HpxToWcsMapping.create(self.hpx, self._wcs2d)
- gammapy/maps/hpx.py:1481: in create
- ipix, mult_val, npix = make_hpx_to_wcs_mapping(hpx, wcs)
- gammapy/maps/hpx.py:289: in make_hpx_to_wcs_mapping
- hpx.nest).flatten()
- ../astropy-healpix/astropy_healpix/healpy.py:105: in ang2pix
- return lonlat_to_healpix(lon, lat, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- lon = array([ 3.14025542, 3.13047409, 3.12316943, ..., 3.16001588,
- 3.15271122, 3.14292989])
- lat = array([-0.11133886, -0.08673701, -0.06202949, ..., 0.06202949,
- 0.08673701, 0.11133886]), nside = array([[4],
- [8]])
- return_offsets = False, order = 'ring'
- def lonlat_to_healpix(lon, lat, nside, return_offsets=False, order='ring'):
- """
- Convert longitudes/latitudes to HEALPix indices
- Parameters
- ----------
- lon, lat : :class:`~astropy.units.Quantity`
- The longitude and latitude values as :class:`~astropy.units.Quantity`
- instances with angle units.
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- order : { 'nested' | 'ring' }
- Order of HEALPix pixels
- return_offsets : bool, optional
- If `True`, the returned values are the HEALPix pixel indices as well as
- ``dx`` and ``dy``, the fractional positions inside the pixels. If
- `False` (the default), only the HEALPix pixel indices is returned.
- Returns
- -------
- healpix_index : int or `~numpy.ndarray`
- The HEALPix indices
- dx, dy : `~numpy.ndarray`
- Offsets inside the HEALPix pixel in the range [0:1], where 0.5 is the
- center of the HEALPix pixels
- """
- lon = lon.to(u.rad).value
- lat = lat.to(u.rad).value
- lon, lat = np.broadcast_arrays(lon, lat)
- shape = np.shape(lon)
- lon = lon.astype(float).ravel()
- lat = lat.astype(float).ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:341: TypeError
- ___________________________________________ test_hpxcube_swap_scheme[nside2-False-GAL-None-axes2] ___________________________________________
- nside = [4, 8], nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x1180da6d8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_swap_scheme(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- m.fill_poisson(1.0)
- > m2 = m.to_swapped_scheme()
- gammapy/maps/tests/test_hpxcube.py:137:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpxcube.py:391: in to_swapped_scheme
- idx_new = tuple([hp.ring2nest(nside, idx[0])] + idx[1:])
- ../astropy-healpix/astropy_healpix/healpy.py:117: in ring2nest
- return ring_to_nested(ipix, nside)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- ring_index = array([ 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 17, 18, 20, 21, 22, 23,...740, 741, 742, 743,
- 744, 746, 747, 749, 750, 751, 752, 753, 755, 756, 757, 759, 761,
- 762, 764, 765, 766])
- 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])
- def ring_to_nested(ring_index, nside):
- """
- Convert a HEALPix 'ring' index to a HEALPix 'nested' index
- Parameters
- ----------
- ring_index : int or `~numpy.ndarray`
- Healpix index using the 'ring' ordering
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- Returns
- -------
- nested_index : int or `~numpy.ndarray`
- Healpix index using the 'nested' ordering
- """
- ring_index = np.asarray(ring_index, dtype=np.int64)
- shape = ring_index.shape
- ring_index = ring_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:402: TypeError
- ______________________________________ test_hpxcube_swap_scheme[8-False-GAL-DISK(110.,75.,10.)-axes3] _______________________________________
- nside = 8, nested = False, coordsys = 'GAL', region = 'DISK(110.,75.,10.)', axes = [<gammapy.maps.geom.MapAxis object at 0x1180da7f0>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_swap_scheme(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- m.fill_poisson(1.0)
- > m2 = m.to_swapped_scheme()
- gammapy/maps/tests/test_hpxcube.py:137:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpxcube.py:376: in to_swapped_scheme
- map_out = self.__class__(hpx_out)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpxcube.HpxMapND object at 0x118b6af60>, hpx = <gammapy.maps.hpx.HpxGeom object at 0x118b6ad68>
- data = array([[ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
- nan],
- [ nan, nan, nan, na... nan],
- [ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
- nan]], dtype=float32)
- dtype = 'float32'
- def __init__(self, hpx, data=None, dtype='float32'):
- shape = tuple([np.max(hpx.npix)] + [ax.nbin for ax in hpx.axes])
- if data is None:
- if hpx.npix.size > 1:
- data = np.nan * np.ones(shape, dtype=dtype).T
- pix = hpx.get_pixels(local=True)
- > data[pix[::-1]] = 0.0
- E IndexError: index 12 is out of bounds for axis 1 with size 12
- gammapy/maps/hpxcube.py:41: IndexError
- ______________________________________ test_hpxcube_swap_scheme[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 0x1180da828>, <gammapy.maps.geom.MapAxis object at 0x1180da860>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_swap_scheme(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- m.fill_poisson(1.0)
- > m2 = m.to_swapped_scheme()
- gammapy/maps/tests/test_hpxcube.py:137:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpxcube.py:376: in to_swapped_scheme
- map_out = self.__class__(hpx_out)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- self = <gammapy.maps.hpxcube.HpxMapND object at 0x1189aa0b8>, hpx = <gammapy.maps.hpx.HpxGeom object at 0x1189aa860>
- data = array([[[ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
- nan],
- [ nan, nan, nan, ... nan],
- [ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
- nan]]], dtype=float32)
- dtype = 'float32'
- def __init__(self, hpx, data=None, dtype='float32'):
- shape = tuple([np.max(hpx.npix)] + [ax.nbin for ax in hpx.axes])
- if data is None:
- if hpx.npix.size > 1:
- data = np.nan * np.ones(shape, dtype=dtype).T
- pix = hpx.get_pixels(local=True)
- > data[pix[::-1]] = 0.0
- E IndexError: index 12 is out of bounds for axis 2 with size 12
- gammapy/maps/hpxcube.py:41: IndexError
- ____________________________________________ test_hpxcube_ud_grade[nside2-False-GAL-None-axes2] _____________________________________________
- nside = [4, 8], nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x1180da6d8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_ud_grade(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- > m.to_ud_graded(4)
- gammapy/maps/tests/test_hpxcube.py:147:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpxcube.py:410: in to_ud_graded
- coords = self.hpx.get_coords()
- gammapy/maps/hpx.py:1370: in get_coords
- return self.pix_to_coord(pix)
- gammapy/maps/hpx.py:637: in pix_to_coord
- theta, phi = hp.pix2ang(nside, ipix, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:98: in pix2ang
- lon, lat = healpix_to_lonlat(ipix, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- healpix_index = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20,..., 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756,
- 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767])
- 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])
- dx = None, dy = None, order = 'ring'
- def healpix_to_lonlat(healpix_index, nside, dx=None, dy=None, order='ring'):
- """
- Convert HEALPix indices (optionally with offsets) to longitudes/latitudes.
- If no offsets (``dx`` and ``dy``) are provided, the coordinates will default
- to those at the center of the HEALPix pixels.
- Parameters
- ----------
- healpix_index : int or `~numpy.ndarray`
- HEALPix indices (as a scalar or array)
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- dx, dy : float or `~numpy.ndarray`, optional
- Offsets inside the HEALPix pixel, which must be in the range [0:1],
- where 0.5 is the center of the HEALPix pixels (as scalars or arrays)
- order : { 'nested' | 'ring' }, optional
- Order of HEALPix pixels
- Returns
- -------
- lon : :class:`~astropy.coordinates.Longitude`
- The longitude values
- lat : :class:`~astropy.coordinates.Latitude`
- The latitude values
- """
- if (dx is None and dy is not None) or (dx is not None and dy is None):
- raise ValueError('Either both or neither dx and dy must be specified')
- healpix_index = np.asarray(healpix_index, dtype=np.int64)
- if dx is None and dy is not None:
- dx = 0.5
- elif dx is not None and dy is None:
- dy = 0.5
- if dx is not None:
- dx = np.asarray(dx, dtype=np.float)
- dy = np.asarray(dy, dtype=np.float)
- _validate_offset('x', dx)
- _validate_offset('y', dy)
- healpix_index, dx, dy = np.broadcast_arrays(healpix_index, dx, dy)
- dx = dx.ravel()
- dy = dy.ravel()
- shape = healpix_index.shape
- healpix_index = healpix_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:287: TypeError
- __________________________________________ test_hpxcube_sum_over_axes[nside2-False-GAL-None-axes2] __________________________________________
- nside = [4, 8], nested = False, coordsys = 'GAL', region = None, axes = [<gammapy.maps.geom.MapAxis object at 0x1180da6d8>]
- @pytest.mark.parametrize(('nside', 'nested', 'coordsys', 'region', 'axes'),
- hpx_test_geoms)
- def test_hpxcube_sum_over_axes(nside, nested, coordsys, region, axes):
- m = HpxMapND(HpxGeom(nside=nside, nest=nested,
- coordsys=coordsys, region=region, axes=axes))
- > coords = m.geom.get_coords()
- gammapy/maps/tests/test_hpxcube.py:155:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- gammapy/maps/hpx.py:1370: in get_coords
- return self.pix_to_coord(pix)
- gammapy/maps/hpx.py:637: in pix_to_coord
- theta, phi = hp.pix2ang(nside, ipix, nest=self.nest)
- ../astropy-healpix/astropy_healpix/healpy.py:98: in pix2ang
- lon, lat = healpix_to_lonlat(ipix, nside, order='nested' if nest else 'ring')
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- healpix_index = array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20,..., 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756,
- 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767])
- 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])
- dx = None, dy = None, order = 'ring'
- def healpix_to_lonlat(healpix_index, nside, dx=None, dy=None, order='ring'):
- """
- Convert HEALPix indices (optionally with offsets) to longitudes/latitudes.
- If no offsets (``dx`` and ``dy``) are provided, the coordinates will default
- to those at the center of the HEALPix pixels.
- Parameters
- ----------
- healpix_index : int or `~numpy.ndarray`
- HEALPix indices (as a scalar or array)
- nside : int
- Number of pixels along the side of each of the 12 top-level HEALPix tiles
- dx, dy : float or `~numpy.ndarray`, optional
- Offsets inside the HEALPix pixel, which must be in the range [0:1],
- where 0.5 is the center of the HEALPix pixels (as scalars or arrays)
- order : { 'nested' | 'ring' }, optional
- Order of HEALPix pixels
- Returns
- -------
- lon : :class:`~astropy.coordinates.Longitude`
- The longitude values
- lat : :class:`~astropy.coordinates.Latitude`
- The latitude values
- """
- if (dx is None and dy is not None) or (dx is not None and dy is None):
- raise ValueError('Either both or neither dx and dy must be specified')
- healpix_index = np.asarray(healpix_index, dtype=np.int64)
- if dx is None and dy is not None:
- dx = 0.5
- elif dx is not None and dy is None:
- dy = 0.5
- if dx is not None:
- dx = np.asarray(dx, dtype=np.float)
- dy = np.asarray(dy, dtype=np.float)
- _validate_offset('x', dx)
- _validate_offset('y', dy)
- healpix_index, dx, dy = np.broadcast_arrays(healpix_index, dx, dy)
- dx = dx.ravel()
- dy = dy.ravel()
- shape = healpix_index.shape
- healpix_index = healpix_index.ravel()
- > nside = int(nside)
- E TypeError: only length-1 arrays can be converted to Python scalars
- ../astropy-healpix/astropy_healpix/core.py:287: TypeError
- ======================================= 39 failed, 200 passed, 11 xfailed, 2 xpassed in 14.61 seconds =======================================
Add Comment
Please, Sign In to add comment