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) 91 @param[in] epoch Epoch for proper motion and parallax correction 92 (an astropy.time.Time), or None 94 No proper motion correction is made, since our astrometry.net catalogs 95 typically don't support that, and even if they do they format is uncertain. 96 Users interested in proper motion corrections should use the 97 lsst.meas.algorithms.LoadIndexedReferenceObjectsTask or they will need to 98 subclass and define how the proper motion correction is to be done. 100 @return an lsst.pipe.base.Struct containing: 101 - refCat a catalog of reference objects with the 102 \link meas_algorithms_loadReferenceObjects_Schema standard schema \endlink 103 as documented in LoadReferenceObjects, including photometric, resolved and variable; 104 hasCentroid is False for all objects. 105 - fluxField = name of flux field for specified filterName 112 for col, mcol
in self.
andConfig.magColumnMap.items():
115 ecols.append(self.
andConfig.magErrorColumnMap.get(col,
''))
116 margs = (names, mcols, ecols)
141 self.log.debug(
"search for objects at %s with radius %s deg", ctrCoord, radius.asDegrees())
145 inds = tuple(mi[0]
for mi
in multiInds)
146 refCat = solver.getCatalog(inds, *fixedArgTuple)
148 self._addFluxAliases(schema=refCat.schema)
150 fluxField = getRefFluxField(schema=refCat.schema, filterName=filterName)
154 if not refCat.isContiguous():
155 refCat = refCat.copy(deep=
True)
157 self.log.debug(
"found %d objects", len(refCat))
158 return pipeBase.Struct(
164 def _readIndexFiles(self):
165 """!Read all astrometry.net index files, if not already read 170 self.log.debug(
"read index files")
178 def _getMIndexesWithinRange(self, ctrCoord, radius):
179 """!Get list of muti-index objects within range 181 @param[in] ctrCoord center of search region (an afwGeom.Coord) 182 @param[in] radius radius of search region (an afwGeom.Angle) 184 @return list of multiindex objects 186 return [mi
for mi
in self.
multiInds if mi.isWithinRange(ctrCoord, radius)]
188 def _getSolver(self):
189 solver = astrometry_net.Solver()
192 solver.setPixelScaleRange(lo, hi)
197 """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, epoch=None)
Load reference objects that overlap a circular sky region.
def __init__(self, config=None, andConfig=None, kwargs)
Create a LoadAstrometryNetObjectsTask.