lsst.meas.algorithms  15.0-11-g7db6e543+4
htmIndexer.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 #
4 # Copyright 2008-2017 AURA/LSST.
5 #
6 # This product includes software developed by the
7 # LSST Project (http://www.lsst.org/).
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the LSST License Statement and
20 # the GNU General Public License along with this program. If not,
21 # see <https://www.lsstcorp.org/LegalNotices/>.
22 #
23 import esutil
24 
25 
26 class HtmIndexer:
27 
28  def __init__(self, depth=8):
29  """!Construct the indexer object
30 
31  @param[in] depth depth of the hierarchy to construct
32  """
33  self.htm = esutil.htm.HTM(depth)
34 
35  def get_pixel_ids(self, ctrCoord, radius):
36  """!Get all shards that touch a circular aperture
37 
38  @param[in] ctrCoord afwGeom.SpherePoint ICRS center of the aperture
39  @param[in] radius afwGeom.Angle object of the aperture radius
40  @param[out] A pipeBase.Struct with the list of shards, shards, and a boolean arry, boundary_mask,
41  indicating whether the shard touches the boundary (True) or is fully contained (False).
42  """
43  pixel_id_list = self.htm.intersect(ctrCoord.getLongitude().asDegrees(),
44  ctrCoord.getLatitude().asDegrees(),
45  radius.asDegrees(), inclusive=True)
46  covered_pixel_id_list = self.htm.intersect(ctrCoord.getLongitude().asDegrees(),
47  ctrCoord.getLatitude().asDegrees(),
48  radius.asDegrees(), inclusive=False)
49  is_on_boundary = (pixel_id not in covered_pixel_id_list for pixel_id in pixel_id_list)
50  return pixel_id_list, is_on_boundary
51 
52  def index_points(self, ra_list, dec_list):
53  """!Generate trixel ids for each row in an input file
54 
55  @param[in] ra_list List of RA coordinate in degrees
56  @param[in] dec_list List of Dec coordinate in degrees
57  @param[out] A list of pixel ids
58  """
59  return self.htm.lookup_id(ra_list, dec_list)
60 
61  @staticmethod
62  def make_data_id(pixel_id, dataset_name):
63  """!Make a data id. Meant to be overridden.
64  @param[in] pixel_id An identifier for the pixel in question.
65  @param[in] dataset_name Name of the dataset to use.
66  @param[out] dataId (dictionary)
67  """
68  if pixel_id is None:
69  # NoneType doesn't format, so make dummy pixel
70  pixel_id = 0
71  return {'pixel_id': pixel_id, 'name': dataset_name}
def get_pixel_ids(self, ctrCoord, radius)
Get all shards that touch a circular aperture.
Definition: htmIndexer.py:35
def make_data_id(pixel_id, dataset_name)
Make a data id.
Definition: htmIndexer.py:62
def __init__(self, depth=8)
Construct the indexer object.
Definition: htmIndexer.py:28
def index_points(self, ra_list, dec_list)
Generate trixel ids for each row in an input file.
Definition: htmIndexer.py:52