LSSTApplications  11.0-22-g33de520,12.1+25,13.0+25,13.0+30,13.0-1-g174df6e+3,13.0-1-g41367f3+3,13.0-1-g47a359c+3,13.0-1-g52a7baa+3,13.0-1-g976b40b+3,13.0-10-gcc6134a+6,13.0-10-gf7c21d5+2,13.0-13-gdd29b46+5,13.0-14-gc9904b0,13.0-2-g15de9a1+3,13.0-2-ga4f5e85+6,13.0-2-gf5c5ced+6,13.0-2-gf9e84ea+5,13.0-22-g8f1d162,13.0-3-g7fa07e0+4,13.0-34-ga37f01a,13.0-4-g0bde1de,13.0-5-g0db1a30+1,13.0-5-g6708b9e+9,13.0-6-g7b63e3f+6,13.0-8-gba0f85f,13.0-9-gc47bba1,master-gb637561bb9
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | Private Attributes | List of all members
lsst.meas.astrom.multiindex.MultiIndexCache Class Reference
Inheritance diagram for lsst.meas.astrom.multiindex.MultiIndexCache:

Public Member Functions

def __init__
 Constructor. More...
 
def fromFilenameList
 
def read
 
def reload
 
def unload
 
def isWithinRange
 Is the index within range of the provided coordinates? More...
 
def __getitem__
 
def __len__
 
def __iter__
 

Public Attributes

 log
 

Private Attributes

 _filenameList
 
 _healpix
 
 _nside
 
 _mi
 
 _loaded
 

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 60 of file multiindex.py.

Constructor & Destructor Documentation

def lsst.meas.astrom.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 67 of file multiindex.py.

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

Member Function Documentation

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

Definition at line 154 of file multiindex.py.

155  def __getitem__(self, i):
156  self.reload()
157  return self._mi[i]
def lsst.meas.astrom.multiindex.MultiIndexCache.__iter__ (   self)

Definition at line 161 of file multiindex.py.

162  def __iter__(self):
163  self.reload()
164  return iter(self._mi)
165 
int iter
def lsst.meas.astrom.multiindex.MultiIndexCache.__len__ (   self)

Definition at line 158 of file multiindex.py.

159  def __len__(self):
160  return len(self._filenameList) - 1 # The first is the multiindex; the rest are the indices
def lsst.meas.astrom.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 86 of file multiindex.py.

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

Is the index within range of the provided coordinates?

Parameters
coordCoordinate to check (lsst.afw.coord.Coord)
distanceAngular distance (lsst.afw.geom.Angle)

Definition at line 146 of file multiindex.py.

147  def isWithinRange(self, coord, distance):
148  """!Is the index within range of the provided coordinates?
149 
150  @param coord Coordinate to check (lsst.afw.coord.Coord)
151  @param distance Angular distance (lsst.afw.geom.Angle)
152  """
153  return (self._healpix == -1 or healpixDistance(self._healpix, self._nside, coord) <= distance)
def isWithinRange
Is the index within range of the provided coordinates?
Definition: multiindex.py:146
lsst::afw::geom::Angle healpixDistance(int hp, int nside, lsst::afw::coord::Coord const &coord)
Calculate the distance from coordinates to a healpix.
def lsst.meas.astrom.multiindex.MultiIndexCache.read (   self)
Read the indices

Definition at line 103 of file multiindex.py.

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

Definition at line 129 of file multiindex.py.

130  def reload(self):
131  """Reload the indices."""
132  if self._loaded:
133  return
134  if self._mi is None:
135  self.read()
136  else:
137  self._mi.reload()
138  self._loaded = True
def lsst.meas.astrom.multiindex.MultiIndexCache.unload (   self)
Unload the indices

Definition at line 139 of file multiindex.py.

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

Member Data Documentation

lsst.meas.astrom.multiindex.MultiIndexCache._filenameList
private

Definition at line 78 of file multiindex.py.

lsst.meas.astrom.multiindex.MultiIndexCache._healpix
private

Definition at line 79 of file multiindex.py.

lsst.meas.astrom.multiindex.MultiIndexCache._loaded
private

Definition at line 82 of file multiindex.py.

lsst.meas.astrom.multiindex.MultiIndexCache._mi
private

Definition at line 81 of file multiindex.py.

lsst.meas.astrom.multiindex.MultiIndexCache._nside
private

Definition at line 80 of file multiindex.py.

lsst.meas.astrom.multiindex.MultiIndexCache.log

Definition at line 83 of file multiindex.py.


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