1 from __future__
import absolute_import, division, print_function
8 from .
import astrometry_net
as astromNet
9 from .astrometryNetDataConfig
import AstrometryNetDataConfig
10 from .multiindex
import AstrometryNetCatalog, getConfigFromEnvironment
12 __all__ = [
"LoadAstrometryNetObjectsTask",
"LoadAstrometryNetObjectsConfig"]
14 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 LoadAstrometryNetObjectsTask
57 LoadAstrometryNetObjectsTask is a subtask of AstrometryTask, which is called by PhotoCalTask.
58 See \ref meas_photocal_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, andConfig=None, **kwargs):
67 """!Create a LoadAstrometryNetObjectsTask
69 @param[in] config configuration (an instance of 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)
73 @throw RuntimeError if andConfig is None and the configuration cannot be found,
74 either because astrometry_net_data is not setup in eups
75 or because the setup version does not include the file "andConfig.py"
77 LoadReferenceObjectsTask.__init__(self, config=config, **kwargs)
84 """!Load reference objects that overlap a circular sky region
86 @param[in] ctrCoord center of search region (an afwGeom.Coord)
87 @param[in] radius radius of search region (an afwGeom.Angle)
88 @param[in] filterName name of filter, or None for the default filter;
89 used for flux values in case we have flux limits (which are not yet implemented)
91 @return an lsst.pipe.base.Struct containing:
92 - refCat a catalog of reference objects with the
93 \link meas_algorithms_loadReferenceObjects_Schema standard schema \endlink
94 as documented in LoadReferenceObjects, including photometric, resolved and variable;
95 hasCentroid is False for all objects.
96 - fluxField = name of flux field for specified filterName
103 for col, mcol
in self.andConfig.magColumnMap.items():
106 ecols.append(self.andConfig.magErrorColumnMap.get(col,
''))
107 margs = (names, mcols, ecols)
125 self.andConfig.idColumn,
127 self.andConfig.starGalaxyColumn,
128 self.andConfig.variableColumn,
132 self.log.logdebug(
"search for objects at %s with radius %s deg" % (ctrCoord, radius.asDegrees()))
136 inds = tuple(mi[0]
for mi
in multiInds)
137 refCat = solver.getCatalog(inds, *fixedArgTuple)
139 self._addFluxAliases(schema=refCat.schema)
141 fluxField =
getRefFluxField(schema=refCat.schema, filterName=filterName)
143 self.log.logdebug(
"found %d objects" % (len(refCat),))
144 return pipeBase.Struct(
146 fluxField = fluxField,
151 """!Read all astrometry.net index files, if not already read
156 self.log.logdebug(
"read index files")
165 """!Get list of muti-index objects within range
167 @param[in] ctrCoord center of search region (an afwGeom.Coord)
168 @param[in] radius radius of search region (an afwGeom.Angle)
170 @return list of multiindex objects
172 return [mi
for mi
in self.
multiInds if mi.isWithinRange(ctrCoord, radius)]
175 solver = astromNet.solver_new()
178 solver.setPixelScaleRange(lo, hi)
183 """Context manager for loading and unloading astrometry.net multi-index files
def _getMIndexesWithinRange
Get list of muti-index objects within range.
def __init__
Create a LoadAstrometryNetObjectsTask.
def getRefFluxField
Get name of flux field in schema.
def getConfigFromEnvironment
Load reference objects from astrometry.net index files.
def _readIndexFiles
Read all astrometry.net index files, if not already read.
def loadSkyCircle
Load reference objects that overlap a circular sky region.