def _calc_hpx_indexes(nside):
"""Calculate HEALPix element indexes for the HPX projection scheme.
Parameters
----------
nside : int
Nside of the input/output HEALPix data
Returns
-------
indexes : 2D `~numpy.ndarray`
2D integer array of same size as the input/output HPX FITS image,
with elements tracking the indexes of the HPX pixels in the
HEALPix 1D array, while elements with value "-1" indicating
null/empty HPX pixels.
NOTE
----
* The indexes are 0-based;
* Currently only HEALPix RING ordering supported;
* The null/empty elements in the HPX projection are filled with "-1".
"""
# number of horizontal/vertical facet
nfacet = 5
# Facets layout of the HPX projection scheme.
# Note that this appears to be upside-down, and the blank facets
# are marked with "-1".
# Ref: ref.[2], Fig.4
#
# XXX:
# Cannot use the nested list here, which fails with ``numba`` error:
# ``NotImplementedError: unsupported nested memory-managed object``
FACETS_LAYOUT = np.zeros((nfacet, nfacet), dtype=np.int64)
FACETS_LAYOUT[0, :] = [6, 9, -1, -1, -1]
FACETS_LAYOUT[1, :] = [1, 5, 8, -1, -1]
FACETS_LAYOUT[2, :] = [-1, 0, 4, 11, -1]
FACETS_LAYOUT[3, :] = [-1, -1, 3, 7, 10]
FACETS_LAYOUT[4, :] = [-1, -1, -1, 2, 6]
#
shape = (nfacet*nside, nfacet*nside)
indexes = -np.ones(shape, dtype=np.int64)
#
# Loop vertically facet-by-facet
for jfacet in range(nfacet):
# Loop row-by-row
for j in range(nside):
row = jfacet * nside + j
# Loop horizontally facet-by-facet
for ifacet in range(nfacet):
facet = FACETS_LAYOUT[jfacet, ifacet]
if facet < 0:
# blank facet
pass
else:
idx = _calc_hpx_row_idx(nside, facet, j)
col = ifacet * nside
indexes[row, col:(col+nside)] = idx
#
return indexes
评论列表
文章目录