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 lsst.meas.algorithms.loadReferenceObjects
import convertToNanojansky
10 from .
import astrometry_net
11 from .multiindex
import AstrometryNetCatalog, getConfigFromEnvironment
13 LoadAstrometryNetObjectsConfig = LoadReferenceObjectsTask.ConfigClass
25 """!Load reference objects from astrometry.net index files 27 @anchor LoadAstrometryNetObjectsTask_ 29 @section meas_astrom_loadAstrometryNetObjects_Contents Contents 31 - @ref meas_astrom_loadAstrometryNetObjects_Purpose 32 - @ref meas_astrom_loadAstrometryNetObjects_Initialize 33 - @ref meas_astrom_loadAstrometryNetObjects_IO 34 - @ref meas_algorithms_loadReferenceObjects_Schema 35 - @ref meas_astrom_loadAstrometryNetObjects_Config 36 - @ref meas_astrom_loadAstrometryNetObjects_Example 37 - @ref meas_astrom_loadAstrometryNetObjects_Debug 39 @section meas_astrom_loadAstrometryNetObjects_Purpose Description 41 Load reference objects from astrometry.net index files. 43 @section meas_astrom_loadAstrometryNetObjects_Initialize Task initialisation 47 @section meas_astrom_loadAstrometryNetObjects_IO Invoking the Task 49 @copydoc loadObjectsInBBox 51 @section meas_astrom_loadAstrometryNetObjects_Config Configuration parameters 53 See @ref LoadAstrometryNetObjectsConfig 55 @section meas_astrom_loadAstrometryNetObjects_Example A complete example of using 56 LoadAstrometryNetObjectsTask 58 LoadAstrometryNetObjectsTask is a subtask of AstrometryTask, which is called by PhotoCalTask. 59 See \ref pipe_tasks_photocal_Example. 61 @section meas_astrom_loadAstrometryNetObjects_Debug Debug variables 63 LoadAstrometryNetObjectsTask does not support any debug variables. 65 ConfigClass = LoadAstrometryNetObjectsConfig
67 def __init__(self, config=None, andConfig=None, **kwargs):
68 """!Create a LoadAstrometryNetObjectsTask 70 @param[in] config configuration (an instance of self.ConfigClass); if None use self.ConfigClass() 71 @param[in] andConfig astrometry.net data config (an instance of AstromNetDataConfig, or None); 72 if None then use andConfig.py in the astrometry_net_data product (which must be setup) 73 @param[in] kwargs additional keyword arguments for pipe_base Task.\_\_init\_\_ 75 @throw RuntimeError if andConfig is None and the configuration cannot be found, 76 either because astrometry_net_data is not setup in eups 77 or because the setup version does not include the file "andConfig.py" 79 LoadReferenceObjectsTask.__init__(self, config=config, **kwargs)
85 def loadSkyCircle(self, ctrCoord, radius, filterName=None, epoch=None, centroids=True):
86 """!Load reference objects that overlap a circular sky region 88 @param[in] ctrCoord center of search region (an afwGeom.Coord) 89 @param[in] radius radius of search region (an afwGeom.Angle) 90 @param[in] filterName name of filter, or None for the default filter; 91 used for flux values in case we have flux limits (which are not yet implemented) 92 @param[in] epoch Epoch for proper motion and parallax correction 93 (an astropy.time.Time), or None 94 centroids : `bool` (optional) 95 Ignored: a.net refcats always have centroid fields. 97 No proper motion correction is made, since our astrometry.net catalogs 98 typically don't support that, and even if they do they format is uncertain. 99 Users interested in proper motion corrections should use the 100 lsst.meas.algorithms.LoadIndexedReferenceObjectsTask or they will need to 101 subclass and define how the proper motion correction is to be done. 103 @return an lsst.pipe.base.Struct containing: 104 - refCat a catalog of reference objects with the 105 \link meas_algorithms_loadReferenceObjects_Schema standard schema \endlink 106 as documented in LoadReferenceObjects, including photometric, resolved and variable; 107 hasCentroid is False for all objects. 108 - fluxField = name of flux field for specified filterName 115 for col, mcol
in self.
andConfig.magColumnMap.items():
118 ecols.append(self.
andConfig.magErrorColumnMap.get(col,
''))
119 margs = (names, mcols, ecols)
144 self.log.debug(
"search for objects at %s with radius %s deg", ctrCoord, radius.asDegrees())
148 inds = tuple(mi[0]
for mi
in multiInds)
149 refCat = solver.getCatalog(inds, *fixedArgTuple)
151 self._addFluxAliases(schema=refCat.schema)
153 fluxField = getRefFluxField(schema=refCat.schema, filterName=filterName)
157 if not refCat.isContiguous():
158 refCat = refCat.copy(deep=
True)
161 self.log.warn(
"Loading A.net reference catalog with old style units in schema.")
162 self.log.warn(
"A.net reference catalogs will not be supported in the future.")
163 self.log.warn(
"See RFC-562 and RFC-575 for more details.")
164 refCat = convertToNanojansky(refCat, self.log)
166 self.log.debug(
"found %d objects", len(refCat))
167 return pipeBase.Struct(
173 def _readIndexFiles(self):
174 """!Read all astrometry.net index files, if not already read 179 self.log.debug(
"read index files")
187 def _getMIndexesWithinRange(self, ctrCoord, radius):
188 """!Get list of muti-index objects within range 190 @param[in] ctrCoord center of search region (an afwGeom.Coord) 191 @param[in] radius radius of search region (an afwGeom.Angle) 193 @return list of multiindex objects 195 return [mi
for mi
in self.
multiInds if mi.isWithinRange(ctrCoord, radius)]
197 def _getSolver(self):
198 solver = astrometry_net.Solver()
201 solver.setPixelScaleRange(lo, hi)
206 """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, centroids=True)
Load reference objects that overlap a circular sky region.
def __init__(self, config=None, andConfig=None, kwargs)
Create a LoadAstrometryNetObjectsTask.