LSSTApplications  17.0+103,17.0+11,17.0+61,18.0.0+13,18.0.0+25,18.0.0+5,18.0.0+52,18.0.0-4-g68ffd23,18.1.0-1-g0001055+8,18.1.0-1-g03d53ef+1,18.1.0-1-g1349e88+28,18.1.0-1-g2505f39+22,18.1.0-1-g380d4d4+27,18.1.0-1-g5315e5e+1,18.1.0-1-g5e4b7ea+10,18.1.0-1-g7e8fceb+1,18.1.0-1-g85f8cd4+23,18.1.0-1-g9a6769a+13,18.1.0-1-ga1a4c1a+22,18.1.0-1-gd55f500+17,18.1.0-12-g42eabe8e+10,18.1.0-14-gd04256d+15,18.1.0-16-g430f6a53+1,18.1.0-17-gd2166b6e4,18.1.0-18-gb5d19ff+1,18.1.0-2-gfbf3545+7,18.1.0-2-gfefb8b5+16,18.1.0-3-g52aa583+13,18.1.0-3-g62b5e86+14,18.1.0-3-g8f4a2b1+17,18.1.0-3-g9bc06b8+7,18.1.0-3-gb69f684+9,18.1.0-4-g1ee41a7+1,18.1.0-5-g6dbcb01+13,18.1.0-5-gc286bb7+3,18.1.0-6-g48bdcd3+2,18.1.0-6-gd05e160+9,18.1.0-7-gc4d902b+2,18.1.0-7-gebc0338+8,18.1.0-9-gae7190a+10,w.2019.38
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | List of all members
lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache Class Reference

Public Member Functions

def __init__ (self, filenameList, healpix, nside)
 Constructor. More...
 
def fromFilenameList (cls, filenameList)
 
def read (self)
 
def reload (self)
 
def unload (self)
 
def isWithinRange (self, coord, distance)
 Is the index within range of the provided coordinates? More...
 
def __getitem__ (self, i)
 
def __len__ (self)
 
def __iter__ (self)
 

Public Attributes

 log
 

Detailed Description

A wrapper for the multiindex_t, which only reads the data when it
needs to

The MultiIndexCache may be instantiated directly, or via the
'fromFilenameList' class method, which loads it from a list of filenames.

Definition at line 58 of file multiindex.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.__init__ (   self,
  filenameList,
  healpix,
  nside 
)

Constructor.

Parameters
filenameListList of filenames; first is the multiindex, then follows the individual index files
healpixHealpix number
nsideHealpix nside

Definition at line 66 of file multiindex.py.

66  def __init__(self, filenameList, healpix, nside):
67  """!Constructor
68 
69  @param filenameList List of filenames; first is the multiindex, then
70  follows the individual index files
71  @param healpix Healpix number
72  @param nside Healpix nside
73  """
74  if len(filenameList) < 2:
75  raise RuntimeError("Insufficient filenames provided for multiindex (%s): expected >= 2" %
76  (filenameList,))
77  self._filenameList = filenameList
78  self._healpix = int(healpix)
79  self._nside = int(nside)
80  self._mi = None
81  self._loaded = False
82  self.log = Log.getDefaultLogger()
83 
def __init__(self, minimum, dataRange, Q)

Member Function Documentation

◆ __getitem__()

def lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.__getitem__ (   self,
  i 
)

Definition at line 153 of file multiindex.py.

153  def __getitem__(self, i):
154  self.reload()
155  return self._mi[i]
156 

◆ __iter__()

def lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.__iter__ (   self)

Definition at line 160 of file multiindex.py.

160  def __iter__(self):
161  self.reload()
162  return iter(self._mi)
163 
164 

◆ __len__()

def lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.__len__ (   self)

Definition at line 157 of file multiindex.py.

157  def __len__(self):
158  return len(self._filenameList) - 1 # The first is the multiindex; the rest are the indices
159 

◆ fromFilenameList()

def lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.fromFilenameList (   cls,
  filenameList 
)
Construct from a list of filenames

The list of filenames should contain the multiindex filename first,
then the individual index filenames.  The healpix and nside are
determined by reading the indices, so this is not very efficient.

Definition at line 85 of file multiindex.py.

85  def fromFilenameList(cls, filenameList):
86  """Construct from a list of filenames
87 
88  The list of filenames should contain the multiindex filename first,
89  then the individual index filenames. The healpix and nside are
90  determined by reading the indices, so this is not very efficient.
91  """
92  self = cls(filenameList, 0, 0)
93  self.reload()
94  healpixes = set(self[i].healpix for i in range(len(self)))
95  nsides = set(self[i].hpnside for i in range(len(self)))
96  assert len(healpixes) == 1
97  assert len(nsides) == 1
98  self._healpix = healpixes.pop()
99  self._nside = nsides.pop()
100  return self
101 
daf::base::PropertySet * set
Definition: fits.cc:884

◆ isWithinRange()

def lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.isWithinRange (   self,
  coord,
  distance 
)

Is the index within range of the provided coordinates?

Parameters
coordICRS coordinate to check (lsst.geom.SpherPoint)
distanceAngular distance (lsst.geom.Angle)

Definition at line 145 of file multiindex.py.

145  def isWithinRange(self, coord, distance):
146  """!Is the index within range of the provided coordinates?
147 
148  @param coord ICRS coordinate to check (lsst.geom.SpherPoint)
149  @param distance Angular distance (lsst.geom.Angle)
150  """
151  return (self._healpix == -1 or healpixDistance(self._healpix, self._nside, coord) <= distance)
152 
lsst::geom::Angle healpixDistance(int hp, int nside, lsst::geom::SpherePoint const &coord)
Calculate the distance from coordinates to a healpix.

◆ read()

def lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.read (   self)
Read the indices

Definition at line 102 of file multiindex.py.

102  def read(self):
103  """Read the indices"""
104  if self._mi is not None:
105  return
106  fn = getIndexPath(self._filenameList[0])
107  if not os.path.exists(fn):
108  raise RuntimeError(
109  "Unable to get filename for astrometry star file %s" % (self._filenameList[0],))
110  self._mi = MultiIndex(fn)
111  if self._mi is None:
112  # Can't proceed at all without stars
113  raise RuntimeError('Failed to read stars from astrometry multiindex filename "%s"' % fn)
114  for i, fn in enumerate(self._filenameList[1:]):
115  if fn is None:
116  self.log.debug('Unable to find index part of multiindex %s', fn)
117  continue
118  fn = getIndexPath(fn)
119  if not os.path.exists(fn):
120  self.log.warn("Unable to get filename for astrometry index %s", fn)
121  continue
122  self.log.debug('Reading index from multiindex file "%s"', fn)
123  self._mi.addIndex(fn, False)
124  ind = self._mi[i]
125  self.log.debug(' index %i, hp %i (nside %i), nstars %i, nquads %i',
126  ind.indexid, ind.healpix, ind.hpnside, ind.nstars, ind.nquads)
127 
def getIndexPath(fn)
Get the path to the specified astrometry.net index file.
Definition: multiindex.py:14

◆ reload()

def lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.reload (   self)
Reload the indices.

Definition at line 128 of file multiindex.py.

128  def reload(self):
129  """Reload the indices."""
130  if self._loaded:
131  return
132  if self._mi is None:
133  self.read()
134  else:
135  self._mi.reload()
136  self._loaded = True
137 

◆ unload()

def lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.unload (   self)
Unload the indices

Definition at line 138 of file multiindex.py.

138  def unload(self):
139  """Unload the indices"""
140  if not self._loaded:
141  return
142  self._mi.unload()
143  self._loaded = False
144 

Member Data Documentation

◆ log

lsst.meas.extensions.astrometryNet.multiindex.MultiIndexCache.log

Definition at line 82 of file multiindex.py.


The documentation for this class was generated from the following file: