def command_log_settings_test(expected_pyroot_level, expected_pybutler_level, expected_lsstroot_level, expected_lsstbutler_level): if lsstLog is not None and not hasLsstLogHandler(logging.getLogger()): raise click.ClickException("Expected to find an lsst.log handler in the python root logger's " "handlers.") LogLevel = namedtuple("LogLevel", ("expected", "actual", "name")) logLevels = [LogLevel(expected_pyroot_level, logging.getLogger().level, "pyRoot"), LogLevel(expected_pybutler_level, logging.getLogger("lsst.daf.butler").level, "pyButler")] if lsstLog is not None: logLevels.extend([LogLevel(expected_lsstroot_level, lsstLog.getLogger("").getLevel(), "lsstRoot"), LogLevel(expected_lsstbutler_level, lsstLog.getLogger("lsst.daf.butler").getLevel(), "lsstButler")]) for expected, actual, name in logLevels: if expected != actual: raise(click.ClickException(f"expected {name} level to be {expected}, actual:{actual}"))
def main(): """Run AssociationTask for the repository. Run from /project/gkovacs/hits_instcals. """ # Log.getLogger('').setLevel(Log.DEBUG) Log.getLogger('association').setLevel(Log.DEBUG) assoc = RunAssociation("repo/rerun/imgDiff_2019-06-20/association.db") assoc.run((411420, 419802, 411371))
def __init__(self, bbox, wcs, badMaskPlanes, logName="coadd.utils.Coadd"): """ Creating a coadd Parameters ---------- bbox : `lsst.afw.geom.Box2I` bounding box of coadd Exposure with respect to parent coadd dimensions = bbox.getDimensions(); xy0 = bbox.getMin() wcs : `lsst.afw.geom.SKyWcs` WCS of coadd exposure badMaskPlanes : `Collection` mask planes to pay attention to when rejecting masked pixels. Specify as a collection of names. badMaskPlanes should always include "NO_DATA". logName : `str` name by which messages are logged """ self._log = log.getLogger(logName) self._bbox = bbox self._wcs = wcs self._badPixelMask = afwImage.Mask.getPlaneBitMask(badMaskPlanes) self._coadd = afwImage.ExposureF(bbox, wcs) self._weightMap = afwImage.ImageF(bbox) # dict of filter name: filter object for all filters seen so far self._filterDict = dict() self._statsControl = afwMath.StatisticsControl() self._statsControl.setNumSigmaClip(3.0) self._statsControl.setNumIter(2) self._statsControl.setAndMask(self._badPixelMask)
def __init__(self, db_file): """Create similar configuration for tasks ad in ap_pipe. """ self.log = Log.getLogger("RunAssociation") self.apdbConfig = ApdbConfig() self.apdbConfig.db_url = "sqlite:///" + db_file self.apdbConfig.isolation_level = "READ_UNCOMMITTED" self.apdbConfig.dia_object_index = "baseline" self.apdbConfig.dia_object_columns = [] self.apdbConfig.connection_timeout = 240 self.apdbConfig.schema_file = _data_file_name("apdb-schema.yaml", "dax_apdb") self.apdbConfig.column_map = _data_file_name( "apdb-ap-pipe-afw-map.yaml", "ap_association") self.apdbConfig.extra_schema_file = _data_file_name( "apdb-ap-pipe-schema-extra.yaml", "ap_association") self.apdb = Apdb(config=self.apdbConfig, afw_schemas=dict(DiaObject=make_dia_object_schema(), DiaSource=make_dia_source_schema())) # apdb.makeSchema() self.differencerConfig = ImageDifferenceConfig() # Schema is different if we do decorrelation self.differencerConfig.doDecorrelation = True self.differencerSchema = ImageDifferenceTask( config=self.differencerConfig).schema self.diaSourceDpddifier = MapDiaSourceTask( inputSchema=self.differencerSchema) self.associator = AssociationTask() self.diffType = "deep"
def main(): # Use logger "main" logger = log.getLogger("main") logger.info("In main") visits = [12345, 67890, 27182, 31415] pool = mp.Pool(processes=2) pool.map_async(a, [(visit, logger) for visit in visits]) pool.close() pool.join() b(logger) log.info("Leaving main")
def __init__(self, *, configFile=None, paramOverrides=None, supplementaryParameters=None, resetParameters=None): if configFile: print(f"Loading config from {configFile}") load_config(configFile) self.log = lsstLog.getLogger(__name__) if paramOverrides is not None: self.overrideParameters(paramOverrides) if supplementaryParameters is not None: self.supplementParameters(supplementaryParameters) if resetParameters is not None: self.resetParameters(resetParameters) return
def rotateExposure(exp, nDegrees, kernelName='lanczos4', logger=None): """Rotate an exposure by nDegrees clockwise. Parameters ---------- exp : `lsst.afw.image.exposure.Exposure` The exposure to rotate nDegrees : `float` Number of degrees clockwise to rotate by kernelName : `str` Name of the warping kernel, used to instantiate the warper. logger : `lsst.log.Log` Logger for logging warnings Returns ------- rotatedExp : `lsst.afw.image.exposure.Exposure` A copy of the input exposure, rotated by nDegrees """ nDegrees = nDegrees % 360 if not logger: logger = lsstLog.getLogger('atmospec.utils') wcs = exp.getWcs() if not wcs: logger.warn( "Can't rotate exposure without a wcs - returning exp unrotated") return exp.clone( ) # return a clone so it's always returning a copy as this is what default does warper = afwMath.Warper(kernelName) if isinstance(exp, afwImage.ExposureU): # TODO: remove once this bug is fixed - DM-20258 logger.info('Converting ExposureU to ExposureF due to bug') logger.info('Remove this workaround after DM-20258') exp = afwImage.ExposureF(exp, deep=True) affineRotTransform = geom.AffineTransform.makeRotation(nDegrees * geom.degrees) transformP2toP2 = afwGeom.makeTransform(affineRotTransform) rotatedWcs = afwGeom.makeModifiedWcs(transformP2toP2, wcs, False) rotatedExp = warper.warpExposure(rotatedWcs, exp) # rotatedExp.setXY0(geom.Point2I(0, 0)) # TODO: check no longer required return rotatedExp
def __init__(self, component): self.logger = lsstLog.getLogger(component) if lsstLog else None self.initialLevel = self.logger.getLevel() if lsstLog else None
def testRepr(self): logger = log.getLogger("a.b") logger.setLevel(log.DEBUG) self.assertEqual(repr(logger), "<lsst.log.Log 'a.b' (DEBUG)>")