如何在指定坐标内找到所有像素索引?

时间:2015-11-16 12:28:20

标签: healpy

有许多Healpix IDL程序被设计用于找到属于由其顶点定义的某个几何区域(例如球形三角形,球形多边形)的像素索引。有query_*个例程(例如query_triangle)。请参阅此处的文档:

http://healpix.jpl.nasa.gov/html/idlnode45.htm

我希望在我的healpy程序中使用这些像素索引。任

(A)我可以以query_*格式保存来自IDL data_file.save例程的像素索引的输出列表。然后,您可以使用各种模块将此.sav像素索引文件导入Python,例如http://www.astropython.org/packages/idlsave94/

(B)以某种方式不使用IDL会更方便! Healpy有几个与像素相关的函数,但似乎无法单独使用healpy来“转换”IDL query_*例程。

有没有办法让query_polygon使用healpy?是否有可能做到这一点?

1 个答案:

答案 0 :(得分:1)

有点不清楚你想要什么,但你可以使用query_polygon中的healpy。例如:

nside = 512
vertices = numpy.array([[....]])
healpy.query_polygon(nside, vertices)

将返回多边形内的像素。 vertices是多边形顶点的(N, 3)数组。

来自内置帮助:

query_polygon(nside, vertices, inclusive=False, fact=4, nest=False, ndarray buff=None
Returns the pixels whose centers lie within the convex polygon
defined by the *vertices* array (if *inclusive* is False), or which
overlap with this polygon (if *inclusive* is True).

Parameters
----------
nside : int
  The nside of the Healpix map.
vertices : float, array-like
  Vertex array containing the vertices of the polygon, shape (N, 3).
inclusive : bool, optional
  If False, return the exact set of pixels whose pixel centers lie
  within the polygon; if True, return all pixels that overlap with the
  polygon, and maybe a few more. Default: False.
fact : int, optional
  Only used when inclusive=True. The overlapping test will be done at
  the resolution fact*nside. For NESTED ordering, fact must be a power of 2, less than 2**30,
  else it can be any positive integer. Default: 4.
nest: bool, optional
  if True, assume NESTED pixel ordering, otherwise, RING pixel ordering
buff: int array, optional
  if provided, this numpy array is used to contain the return values and must be
  at least long enough to do so

Returns
-------
ipix : int, array
  The pixels which lie within the given polygon.

Note
----
This method is more efficient in the RING scheme.
For inclusive=True, the algorithm may return some pixels which don't overlap
with the disk at all. The higher fact is chosen, the fewer false positives
are returned, at the cost of increased run time.