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