lsst.meas.algorithms  13.0-24-g22030a45+10
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 from __future__ import absolute_import, division, print_function
24 from builtins import object
25 import esutil
26 
27 
28 class HtmIndexer(object):
29 
30  def __init__(self, depth=8):
31  """!Construct the indexer object
32 
33  @param[in] depth depth of the hierarchy to construct
34  """
35  self.htm = esutil.htm.HTM(depth)
36 
37  def get_pixel_ids(self, ctrCoord, radius):
38  """!Get all shards that touch a circular aperture
39 
40  @param[in] ctrCoord afwCoord.Coord object of the center of the aperture
41  @param[in] radius afwGeom.Angle object of the aperture radius
42  @param[out] A pipeBase.Struct with the list of shards, shards, and a boolean arry, boundary_mask,
43  indicating whether the shard touches the boundary (True) or is fully contained (False).
44  """
45  pixel_id_list = self.htm.intersect(ctrCoord.getLongitude().asDegrees(),
46  ctrCoord.getLatitude().asDegrees(),
47  radius.asDegrees(), inclusive=True)
48  covered_pixel_id_list = self.htm.intersect(ctrCoord.getLongitude().asDegrees(),
49  ctrCoord.getLatitude().asDegrees(),
50  radius.asDegrees(), inclusive=False)
51  is_on_boundary = (pixel_id not in covered_pixel_id_list for pixel_id in pixel_id_list)
52  return pixel_id_list, is_on_boundary
53 
54  def index_points(self, ra_list, dec_list):
55  """!Generate trixel ids for each row in an input file
56 
57  @param[in] ra_list List of RA coordinate in degrees
58  @param[in] dec_list List of Dec coordinate in degrees
59  @param[out] A list of pixel ids
60  """
61  return self.htm.lookup_id(ra_list, dec_list)
62 
63  @staticmethod
64  def make_data_id(pixel_id, dataset_name):
65  """!Make a data id. Meant to be overridden.
66  @param[in] pixel_id An identifier for the pixel in question.
67  @param[in] dataset_name Name of the dataset to use.
68  @param[out] dataId (dictionary)
69  """
70  if pixel_id is None:
71  # NoneType doesn't format, so make dummy pixel
72  pixel_id = 0
73  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:37
def make_data_id(pixel_id, dataset_name)
Make a data id.
Definition: htmIndexer.py:64
def __init__(self, depth=8)
Construct the indexer object.
Definition: htmIndexer.py:30
def index_points(self, ra_list, dec_list)
Generate trixel ids for each row in an input file.
Definition: htmIndexer.py:54