1 from __future__
import absolute_import, division, print_function
3 __all__ = [
"LoadAstrometryNetObjectsTask",
"LoadAstrometryNetObjectsConfig"]
5 from builtins
import object
7 import lsst.pipe.base
as pipeBase
8 from lsst.meas.algorithms
import LoadReferenceObjectsTask, getRefFluxField
9 from .
import astrometry_net
10 from .multiindex
import AstrometryNetCatalog, getConfigFromEnvironment
12 LoadAstrometryNetObjectsConfig = LoadReferenceObjectsTask.ConfigClass
24 """!Load reference objects from astrometry.net index files 26 @anchor LoadAstrometryNetObjectsTask_ 28 @section meas_astrom_loadAstrometryNetObjects_Contents Contents 30 - @ref meas_astrom_loadAstrometryNetObjects_Purpose 31 - @ref meas_astrom_loadAstrometryNetObjects_Initialize 32 - @ref meas_astrom_loadAstrometryNetObjects_IO 33 - @ref meas_algorithms_loadReferenceObjects_Schema 34 - @ref meas_astrom_loadAstrometryNetObjects_Config 35 - @ref meas_astrom_loadAstrometryNetObjects_Example 36 - @ref meas_astrom_loadAstrometryNetObjects_Debug 38 @section meas_astrom_loadAstrometryNetObjects_Purpose Description 40 Load reference objects from astrometry.net index files. 42 @section meas_astrom_loadAstrometryNetObjects_Initialize Task initialisation 46 @section meas_astrom_loadAstrometryNetObjects_IO Invoking the Task 48 @copydoc loadObjectsInBBox 50 @section meas_astrom_loadAstrometryNetObjects_Config Configuration parameters 52 See @ref LoadAstrometryNetObjectsConfig 54 @section meas_astrom_loadAstrometryNetObjects_Example A complete example of using 55 LoadAstrometryNetObjectsTask 57 LoadAstrometryNetObjectsTask is a subtask of AstrometryTask, which is called by PhotoCalTask. 58 See \ref pipe_tasks_photocal_Example. 60 @section meas_astrom_loadAstrometryNetObjects_Debug Debug variables 62 LoadAstrometryNetObjectsTask does not support any debug variables. 64 ConfigClass = LoadAstrometryNetObjectsConfig
66 def __init__(self, config=None, andConfig=None, **kwargs):
67 """!Create a LoadAstrometryNetObjectsTask 69 @param[in] config configuration (an instance of self.ConfigClass); if None use self.ConfigClass() 70 @param[in] andConfig astrometry.net data config (an instance of AstromNetDataConfig, or None); 71 if None then use andConfig.py in the astrometry_net_data product (which must be setup) 72 @param[in] kwargs additional keyword arguments for pipe_base Task.\_\_init\_\_ 74 @throw RuntimeError if andConfig is None and the configuration cannot be found, 75 either because astrometry_net_data is not setup in eups 76 or because the setup version does not include the file "andConfig.py" 78 LoadReferenceObjectsTask.__init__(self, config=config, **kwargs)
85 """!Load reference objects that overlap a circular sky region 87 @param[in] ctrCoord center of search region (an afwGeom.Coord) 88 @param[in] radius radius of search region (an afwGeom.Angle) 89 @param[in] filterName name of filter, or None for the default filter; 90 used for flux values in case we have flux limits (which are not yet implemented) 92 @return an lsst.pipe.base.Struct containing: 93 - refCat a catalog of reference objects with the 94 \link meas_algorithms_loadReferenceObjects_Schema standard schema \endlink 95 as documented in LoadReferenceObjects, including photometric, resolved and variable; 96 hasCentroid is False for all objects. 97 - fluxField = name of flux field for specified filterName 104 for col, mcol
in self.
andConfig.magColumnMap.items():
107 ecols.append(self.
andConfig.magErrorColumnMap.get(col,
''))
108 margs = (names, mcols, ecols)
133 self.log.debug(
"search for objects at %s with radius %s deg", ctrCoord, radius.asDegrees())
137 inds = tuple(mi[0]
for mi
in multiInds)
138 refCat = solver.getCatalog(inds, *fixedArgTuple)
140 self._addFluxAliases(schema=refCat.schema)
142 fluxField = getRefFluxField(schema=refCat.schema, filterName=filterName)
144 self.log.debug(
"found %d objects", len(refCat))
145 return pipeBase.Struct(
151 def _readIndexFiles(self):
152 """!Read all astrometry.net index files, if not already read 157 self.log.debug(
"read index files")
165 def _getMIndexesWithinRange(self, ctrCoord, radius):
166 """!Get list of muti-index objects within range 168 @param[in] ctrCoord center of search region (an afwGeom.Coord) 169 @param[in] radius radius of search region (an afwGeom.Angle) 171 @return list of multiindex objects 173 return [mi
for mi
in self.
multiInds if mi.isWithinRange(ctrCoord, radius)]
175 def _getSolver(self):
176 solver = astrometry_net.Solver()
179 solver.setPixelScaleRange(lo, hi)
184 """Context manager for loading and unloading astrometry.net multi-index files
def _readIndexFiles(self)
Read all astrometry.net index files, if not already read.
def __init__(self, multiInds)
def _getMIndexesWithinRange(self, ctrCoord, radius)
Get list of muti-index objects within range.
def getConfigFromEnvironment()
def __exit__(self, typ, val, trace)
Load reference objects from astrometry.net index files.
def loadSkyCircle(self, ctrCoord, radius, filterName=None)
Load reference objects that overlap a circular sky region.
def __init__(self, config=None, andConfig=None, kwargs)
Create a LoadAstrometryNetObjectsTask.