1 from __future__
import absolute_import, division, print_function
5 from .
import astrometry_net
as astromNet
6 from .multiindex
import AstrometryNetCatalog, getConfigFromEnvironment
8 __all__ = [
"LoadAstrometryNetObjectsTask",
"LoadAstrometryNetObjectsConfig"]
10 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 LoadAstrometryNetObjectsTask
53 LoadAstrometryNetObjectsTask is a subtask of AstrometryTask, which is called by PhotoCalTask.
54 See \ref meas_photocal_photocal_Example.
56 @section meas_astrom_loadAstrometryNetObjects_Debug Debug variables
58 LoadAstrometryNetObjectsTask does not support any debug variables.
60 ConfigClass = LoadAstrometryNetObjectsConfig
62 def __init__(self, config, andConfig=None, **kwargs):
63 """!Create a LoadAstrometryNetObjectsTask
65 @param[in] config configuration (an instance of self.ConfigClass)
66 @param[in] andConfig astrometry.net data config (an instance of AstromNetDataConfig, or None);
67 if None then use andConfig.py in the astrometry_net_data product (which must be setup)
68 @param[in] kwargs additional keyword arguments for pipe_base Task.\_\_init\_\_
70 @throw RuntimeError if andConfig is None and the configuration cannot be found,
71 either because astrometry_net_data is not setup in eups
72 or because the setup version does not include the file "andConfig.py"
74 LoadReferenceObjectsTask.__init__(self, config=config, **kwargs)
81 """!Load reference objects that overlap a circular sky region
83 @param[in] ctrCoord center of search region (an afwGeom.Coord)
84 @param[in] radius radius of search region (an afwGeom.Angle)
85 @param[in] filterName name of filter, or None for the default filter;
86 used for flux values in case we have flux limits (which are not yet implemented)
88 @return an lsst.pipe.base.Struct containing:
89 - refCat a catalog of reference objects with the
90 \link meas_algorithms_loadReferenceObjects_Schema standard schema \endlink
91 as documented in LoadReferenceObjects, including photometric, resolved and variable;
92 hasCentroid is False for all objects.
93 - fluxField = name of flux field for specified filterName
100 for col, mcol
in self.andConfig.magColumnMap.items():
103 ecols.append(self.andConfig.magErrorColumnMap.get(col,
''))
104 margs = (names, mcols, ecols)
122 self.andConfig.idColumn,
124 self.andConfig.starGalaxyColumn,
125 self.andConfig.variableColumn,
129 self.log.logdebug(
"search for objects at %s with radius %s deg" % (ctrCoord, radius.asDegrees()))
133 inds = tuple(mi[0]
for mi
in multiInds)
134 refCat = solver.getCatalog(inds, *fixedArgTuple)
136 self._addFluxAliases(schema=refCat.schema)
138 fluxField =
getRefFluxField(schema=refCat.schema, filterName=filterName)
140 self.log.logdebug(
"found %d objects" % (len(refCat),))
141 return pipeBase.Struct(
143 fluxField = fluxField,
148 """!Read all astrometry.net index files, if not already read
153 self.log.logdebug(
"read index files")
162 """!Get list of muti-index objects within range
164 @param[in] ctrCoord center of search region (an afwGeom.Coord)
165 @param[in] radius radius of search region (an afwGeom.Angle)
167 @return list of multiindex objects
169 return [mi
for mi
in self.
multiInds if mi.isWithinRange(ctrCoord, radius)]
172 solver = astromNet.solver_new()
175 solver.setPixelScaleRange(lo, hi)
180 """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.