LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
LSSTDataManagementBasePackage
htmIndexer.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2008-2016 AURA/LSST.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <https://www.lsstcorp.org/LegalNotices/>.
21 #
22 from __future__ import absolute_import, division, print_function
23 from builtins import object
24 import esutil
25 
26 
27 class HtmIndexer(object):
28 
29  def __init__(self, depth=8):
30  """!Construct the indexer object
31 
32  @param[in] depth depth of the hierarchy to construct
33  """
34  self.htm = esutil.htm.HTM(depth)
35  # HACK need to call intersect first otherwise it segfaults
36  self.htm.intersect(1., 2., 0.00001)
37 
38  def get_pixel_ids(self, ctrCoord, radius):
39  """!Get all shards that touch a circular aperture
40 
41  @param[in] ctrCoord afwCoord.Coord object of the center of the aperture
42  @param[in] radius afwGeom.Angle object of the aperture radius
43  @param[out] A pipeBase.Struct with the list of shards, shards, and a boolean arry, boundary_mask,
44  indicating whether the shard touches the boundary (True) or is fully contained (False).
45  """
46  pixel_id_list = self.htm.intersect(ctrCoord.getLongitude().asDegrees(),
47  ctrCoord.getLatitude().asDegrees(),
48  radius.asDegrees(), inclusive=True)
49  covered_pixel_id_list = self.htm.intersect(ctrCoord.getLongitude().asDegrees(),
50  ctrCoord.getLatitude().asDegrees(),
51  radius.asDegrees(), inclusive=False)
52  is_on_boundary = (pixel_id not in covered_pixel_id_list for pixel_id in pixel_id_list)
53  return pixel_id_list, is_on_boundary
54 
55  def index_points(self, ra_list, dec_list):
56  """!Generate trixel ids for each row in an input file
57 
58  @param[in] ra_list List of RA coordinate in degrees
59  @param[in] dec_list List of Dec coordinate in degrees
60  @param[out] A list of pixel ids
61  """
62  return self.htm.lookup_id(ra_list, dec_list)
def get_pixel_ids
Get all shards that touch a circular aperture.
Definition: htmIndexer.py:38
def index_points
Generate trixel ids for each row in an input file.
Definition: htmIndexer.py:55
def __init__
Construct the indexer object.
Definition: htmIndexer.py:29