Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-6999: Logging framework migration #42

Merged
merged 3 commits into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions python/lsst/meas/algorithms/algorithmsLib.i
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ Python bindings for meas/algorithms module
# include <map>
# include <memory>
# include "lsst/pex/logging.h"
# include "lsst/pex/logging/BlockTimingLog.h"
# include "lsst/pex/logging/DualLog.h"
# include "lsst/pex/logging/ScreenLog.h"
# include "lsst/afw.h"
# include "lsst/afw/detection/Peak.h"
# include "lsst/afw/detection/Psf.h"
Expand Down
12 changes: 6 additions & 6 deletions python/lsst/meas/algorithms/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import sys
from argparse import ArgumentParser, Namespace
import lsst.pex.logging as pexLog
from lsst.log import Log
from lsst.pex.config import Config, ConfigurableField, Field, ListField
from lsst.pipe.base import CmdLineTask, ConfigValueAction, ConfigFileAction, TaskRunner, Struct
import lsst.afw.image as afwImage
Expand Down Expand Up @@ -65,7 +65,7 @@ def parse_args(self, config, args=None, log=None, override=None):
namespace.config = config
namespace.clobberConfig = False
namespace.butler = None
namespace.log = log if log is not None else pexLog.Log.getDefaultLog()
namespace.log = log if log is not None else Log.getDefaultLogger()
namespace = super(MeasurementDebuggerArgumentParser, self).parse_args(args=args, namespace=namespace)
del namespace.configfile
return namespace
Expand Down Expand Up @@ -98,12 +98,12 @@ def run(self, dataRef, image, catalog):

def readImage(self, image):
exp = afwImage.ExposureF(image)
self.log.info("Read %dx%d image" % (exp.getWidth(), exp.getHeight()))
self.log.info("Read %dx%d image", exp.getWidth(), exp.getHeight())
return exp

def readSources(self, catalog):
sources = afwTable.SourceCatalog.readFits(catalog)
self.log.info("Read %d sources" % len(sources))
self.log.info("Read %d sources", len(sources))
return sources

def mapSchemas(self, sources):
Expand Down Expand Up @@ -138,12 +138,12 @@ def subsetSources(self, sources):
parent = ss.getParent()
if parent:
identifiers.add(parent)
self.log.info("Subset to %d sources" % len(subset))
self.log.info("Subset to %d sources", len(subset))
return subset

def writeSources(self, sources):
sources.writeFits(self.config.outputName)
self.log.info("Wrote %s" % self.config.outputName)
self.log.info("Wrote %s", self.config.outputName)

def writeConfig(self, *args, **kwargs):
pass
Expand Down
14 changes: 7 additions & 7 deletions python/lsst/meas/algorithms/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ def detectFootprints(self, exposure, doSmooth=True, sigma=None, clearMask=True):
fpSets.numNeg = len(fpSets.negative.getFootprints()) if fpSets.negative is not None else 0

if self.config.thresholdPolarity != "negative":
self.log.log(self.log.INFO, "Detected %d positive sources to %g sigma." %
(fpSets.numPos, self.config.thresholdValue*self.config.includeThresholdMultiplier))
self.log.info("Detected %d positive sources to %g sigma.",
fpSets.numPos, self.config.thresholdValue*self.config.includeThresholdMultiplier)

if self.config.doTempLocalBackground:
maskedImage += tempLocalBkgdImage
Expand All @@ -398,11 +398,11 @@ def detectFootprints(self, exposure, doSmooth=True, sigma=None, clearMask=True):
bkgd = self.background.fitBackground(mi)

if self.config.adjustBackground:
self.log.log(self.log.WARN, "Fiddling the background by %g" % self.config.adjustBackground)
self.log.warn("Fiddling the background by %g", self.config.adjustBackground)

bkgd += self.config.adjustBackground
fpSets.background = bkgd
self.log.log(self.log.INFO, "Resubtracting the background after object detection")
self.log.info("Resubtracting the background after object detection")

mi -= bkgd.getImageF()
del mi
Expand All @@ -414,9 +414,9 @@ def detectFootprints(self, exposure, doSmooth=True, sigma=None, clearMask=True):
del mask
fpSets.negative = None
else:
self.log.log(self.log.INFO, "Detected %d negative sources to %g %s" %
(fpSets.numNeg, self.config.thresholdValue,
("DN" if self.config.thresholdType == "value" else "sigma")))
self.log.info("Detected %d negative sources to %g %s",
fpSets.numNeg, self.config.thresholdValue,
("DN" if self.config.thresholdType == "value" else "sigma"))

if display:
ds9.mtv(exposure, frame=0, title="detection")
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/meas/algorithms/installGaussianPsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def run(self, exposure):
if psfSigma <= 0:
raise RuntimeError("psfSigma = %s <= 0" % (psfSigma,))

self.log.logdebug("installing a simple Gaussian PSF model with width=%s, height=%s, FWHM=%0.3f" %
(width, height, psfSigma*FwhmPerSigma))
self.log.debug("installing a simple Gaussian PSF model with width=%s, height=%s, FWHM=%0.3f",
width, height, psfSigma*FwhmPerSigma)
psfModel = SingleGaussianPsf(width, height, psfSigma)
exposure.setPsf(psfModel)
4 changes: 2 additions & 2 deletions python/lsst/meas/algorithms/loadReferenceObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def loadPixelBox(self, bbox, wcs, filterName=None, calib=None):
# trim objects outside bbox
refCat = self._trimToBBox(refCat=refCat, bbox=bbox, wcs=wcs)
numTrimmed = numFound - len(refCat)
self.log.logdebug("trimmed %d out-of-bbox objects, leaving %d" % (numTrimmed, len(refCat)))
self.log.info("Loaded %d reference objects" % (len(refCat),))
self.log.debug("trimmed %d out-of-bbox objects, leaving %d", numTrimmed, len(refCat))
self.log.info("Loaded %d reference objects", len(refCat))

loadRes.refCat = refCat # should be a no-op, but just in case
return loadRes
Expand Down
7 changes: 4 additions & 3 deletions python/lsst/meas/algorithms/objectSizeStarSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
pyplot = None

from lsst.afw.table import SourceCatalog
from lsst.log import Log
from lsst.pipe.base import Struct
from lsst.afw.cameraGeom import TAN_PIXELS
from lsst.afw.geom.ellipses import Quadrupole
import lsst.afw.geom as afwGeom
import lsst.pex.config as pexConfig
import lsst.pex.logging as log
import lsst.afw.display.ds9 as ds9
from .starSelector import BaseStarSelectorTask, starSelectorRegistry

Expand Down Expand Up @@ -140,7 +140,8 @@ def _assignClusters(yvec, centers):
minDist = numpy.nan*numpy.ones_like(yvec)
clusterId = numpy.empty_like(yvec)
clusterId.dtype = int # zeros_like(..., dtype=int) isn't in numpy 1.5
dbl = log.Debug("objectSizeStarSelector._assignClusters", 0)
dbl = Log.getLogger("objectSizeStarSelector._assignClusters")
dbl.setLevel(dbl.INFO)

# Make sure we are logging aall numpy warnings...
oldSettings = numpy.seterr(all="warn")
Expand All @@ -153,7 +154,7 @@ def _assignClusters(yvec, centers):
else:
update = dist < minDist
if w: # Only do if w is not empty i.e. contains a warning message
dbl.debug(2, str(w[-1]))
dbl.trace(str(w[-1]))

minDist[update] = dist[update]
clusterId[update] = i
Expand Down
16 changes: 7 additions & 9 deletions python/lsst/meas/algorithms/pcaPsfDeterminer.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def determinePsf(self, exposure, psfCandidateList, metadata=None, flagKey=None):
try:
psfCellSet.insertCandidate(psfCandidate)
except Exception as e:
self.log.log(-2, "Skipping PSF candidate %d of %d: %s" % (i, len(psfCandidateList), e))
self.log.debug("Skipping PSF candidate %d of %d: %s", i, len(psfCandidateList), e)
continue
source = psfCandidate.getSource()

Expand All @@ -239,11 +239,9 @@ def determinePsf(self, exposure, psfCandidateList, metadata=None, flagKey=None):
nEigenComponents = self.config.nEigenComponents # initial version

if self.config.kernelSize >= 15:
self.log.log(-1,
"WARNING: NOT scaling kernelSize by stellar quadrupole moment " +
"because config.kernelSize=%s >= 15; using config.kernelSize as as the width, instead"
% (self.config.kernelSize,)
)
self.log.warn("WARNING: NOT scaling kernelSize by stellar quadrupole moment " +
"because config.kernelSize=%s >= 15; using config.kernelSize as as the width, instead",
self.config.kernelSize)
actualKernelSize = int(self.config.kernelSize)
else:
medSize = numpy.median(sizes)
Expand All @@ -255,7 +253,7 @@ def determinePsf(self, exposure, psfCandidateList, metadata=None, flagKey=None):

if display:
print("Median size=%s" % (medSize,))
self.log.log(-3, "Kernel size=%s" % (actualKernelSize,))
self.log.trace("Kernel size=%s", actualKernelSize)

# Set size of image returned around candidate
psfCandidateList[0].setHeight(actualKernelSize)
Expand Down Expand Up @@ -350,8 +348,8 @@ def determinePsf(self, exposure, psfCandidateList, metadata=None, flagKey=None):
# Guilty prima facie
awfulCandidates.append(cand)
cleanChi2 = False
self.log.log(-2, "chi^2=%s; id=%s" %
(cand.getChi2(), cand.getSource().getId()))
self.log.debug("chi^2=%s; id=%s",
cand.getChi2(), cand.getSource().getId())
for cand in awfulCandidates:
if display:
print("Removing bad candidate: id=%d, chi^2=%f" % \
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/meas/algorithms/subtractBackground.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def fitBackground(self, maskedImage, nx=0, ny=0, algorithm=None):
self.config.ignoredPixelMask, 0x0))
sctrl.setNanSafe(self.config.isNanSafe)

self.log.logdebug("Ignoring mask planes: %s" % ", ".join(self.config.ignoredPixelMask))
self.log.debug("Ignoring mask planes: %s" % ", ".join(self.config.ignoredPixelMask))

if algorithm is None:
algorithm = self.config.algorithm
Expand Down
1 change: 1 addition & 0 deletions ups/meas_algorithms.table
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ setupRequired(daf_base)
setupRequired(daf_persistence)
setupRequired(afw)
setupRequired(esutil)
setupRequired(log)
setupRequired(meas_base)
setupRequired(obs_test)
setupRequired(minuit2)
Expand Down