def main(): defVerbosity = 5 usage = """usage: %%prog [options] snap1 snap2 snapdiff Notes: - image arguments are paths to Expsosure (calexp) fits files - snap1 is convolved """ parser = optparse.OptionParser(usage) parser.add_option('--s1', help='snap1') parser.add_option('--s2', help='snap2') parser.add_option('--sdiff', help='snap2 - snap1.x.kernel') parser.add_option('--warp', action='store_true', default=False, help='astrometrically warp snap1') parser.add_option('-v', '--verbosity', type=int, default=defVerbosity, help='verbosity of Trace messages') (options, args) = parser.parse_args() if None in (options.s1, options.s2, options.sdiff): parser.print_help() sys.exit(1) print('Verbosity =', options.verbosity) logUtils.traceSetAt("ip.diffim", options.verbosity) snap1Exp = afwImage.ExposureF(options.s1) snap2Exp = afwImage.ExposureF(options.s2) config = ipDiffim.SnapPsfMatchTask.ConfigClass() config.kernel.name = "AL" subconfig = config.kernel.active snapDiff = subtractSnaps(snap1Exp, snap2Exp, subconfig, doWarping=options.warp) snapDiff.writeFits(options.sdiff)
def main(): DefKernel = "lanczos4" DefVerbosity = 1 usage = """usage: %%prog [options] srcExposure refExposure destExposure Computes destExposure = srcExposure warped to match refExposure's WCS and bounding box, where exposure arguments are paths to Exposure fits files""" parser = optparse.OptionParser(usage) parser.add_option( "-k", "--kernel", type=str, default=DefKernel, help="kernel type: bilinear or lancszosN where N = order; default=%s" % (DefKernel, )) parser.add_option( "-v", "--verbosity", type=int, default=DefVerbosity, help= "verbosity of diagnostic trace messages; 1 for just TRACE1, more for more" + " information; default=%s" % (DefVerbosity, )) (opt, args) = parser.parse_args() log.configure() kernelName = opt.kernel.lower() if len(args) != 3: parser.error("You must supply three arguments") srcExposurePath = args[0] refExposurePath = args[1] destExposurePath = args[2] print("Remapping exposure :", srcExposurePath) print("to match wcs and bbox of:", refExposurePath) print("using", kernelName, "kernel") warpingControl = afwMath.WarpingControl(kernelName) srcExposure = afwImage.ExposureF(srcExposurePath) destExposure = afwImage.ExposureF(refExposurePath) if opt.verbosity > 0: print("Verbosity =", opt.verbosity) logUtils.traceSetAt("afw.math.warp", opt.verbosity) numGoodPixels = afwMath.warpExposure(destExposure, srcExposure, warpingControl) print("Warped exposure has %s good pixels" % (numGoodPixels)) print("Writing warped exposure to %s" % (destExposurePath, )) destExposure.writeFits(destExposurePath)
def main(): DefKernel = "lanczos4" DefVerbosity = 1 usage = """usage: %%prog [options] srcExposure refExposure destExposure Computes destExposure = srcExposure warped to match refExposure's WCS and bounding box, where exposure arguments are paths to Exposure fits files""" parser = optparse.OptionParser(usage) parser.add_option("-k", "--kernel", type=str, default=DefKernel, help="kernel type: bilinear or lancszosN where N = order; default=%s" % (DefKernel,)) parser.add_option("-v", "--verbosity", type=int, default=DefVerbosity, help="verbosity of diagnostic trace messages; 1 for just TRACE1, more for more" " information; default=%s" % (DefVerbosity,)) (opt, args) = parser.parse_args() log.configure() kernelName = opt.kernel.lower() if len(args) != 3: parser.error("You must supply three arguments") srcExposurePath = args[0] refExposurePath = args[1] destExposurePath = args[2] print("Remapping exposure :", srcExposurePath) print("to match wcs and bbox of:", refExposurePath) print("using", kernelName, "kernel") warpingControl = afwMath.WarpingControl(kernelName) srcExposure = afwImage.ExposureF(srcExposurePath) destExposure = afwImage.ExposureF(refExposurePath) if opt.verbosity > 0: print("Verbosity =", opt.verbosity) logUtils.traceSetAt("afw.math.warp", opt.verbosity) numGoodPixels = afwMath.warpExposure( destExposure, srcExposure, warpingControl) print("Warped exposure has %s good pixels" % (numGoodPixels)) print("Writing warped exposure to %s" % (destExposurePath,)) destExposure.writeFits(destExposurePath)
def trace_set_at(name: str, number: int) -> None: """Adjust logging level to display messages with the trace number being less than or equal to the provided value. Parameters ---------- name : `str` Name of the logger. number : `int` The trace number threshold for display. Examples -------- .. code-block:: python lsst.utils.logging.trace_set_at("lsst.afw", 3) This will set loggers ``TRACE0.lsst.afw`` to ``TRACE3.lsst.afw`` to ``DEBUG`` and ``TRACE4.lsst.afw`` and ``TRACE5.lsst.afw`` to ``INFO``. Notes ----- Loggers ``TRACE0.`` to ``TRACE5.`` are set. All loggers above the specified threshold are set to ``INFO`` and those below the threshold are set to ``DEBUG``. The expectation is that ``TRACE`` loggers only issue ``DEBUG`` log messages. If ``lsst.log`` is installed, this function will also call `lsst.log.utils.traceSetAt` to ensure that non-Python loggers are also configured correctly. """ for i in range(6): level = logging.INFO if i > number else logging.DEBUG getTraceLogger(name, i).setLevel(level) # if lsst log is available also set the trace loggers there. if logUtils is not None: logUtils.traceSetAt(name, number)
import os import sys import unittest import lsst.geom import lsst.afw.image as afwImage import lsst.afw.math as afwMath import lsst.log.utils as logUtils import lsst.meas.algorithms as algorithms import lsst.meas.algorithms.defects as defects import lsst.pex.config as pexConfig import lsst.utils import lsst.utils.tests # Increase the number for more verbose messages logUtils.traceSetAt("algorithms.CR", 3) try: display except NameError: display = False else: import lsst.afw.display as afwDisplay afwDisplay.setDefaultMaskTransparency(75) try: afwdataDir = lsst.utils.getPackageDir('afwdata') imageFile0 = os.path.join(afwdataDir, "CFHT", "D4", "cal-53535-i-797722_1.fits") except Exception: imageFile0 = None
import unittest import numpy as num import lsst.utils.tests import lsst.afw.image as afwImage import lsst.afw.math as afwMath import lsst.ip.diffim as ipDiffim import lsst.log.utils as logUtils import lsst.pex.config as pexConfig import lsst.pex.exceptions # Increase the number for more verbose messages logUtils.traceSetAt("ip.diffim", 0) class DiffimTestCases(unittest.TestCase): def setUp(self): self.configAL = ipDiffim.ImagePsfMatchTask.ConfigClass() self.configAL.kernel.name = "AL" self.subconfigAL = self.configAL.kernel.active self.configDF = ipDiffim.ImagePsfMatchTask.ConfigClass() self.configDF.kernel.name = "DF" self.subconfigDF = self.configDF.kernel.active self.policyAL = pexConfig.makePolicy(self.subconfigAL) self.policyDF = pexConfig.makePolicy(self.subconfigDF) self.kSize = self.policyAL.getInt("kernelSize")
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. import lsst.afw.image as afwImage import lsst.afw.geom as afwGeom import lsst.afw.math as afwMath import lsst.ip.diffim as ipDiffim import numpy as num import lsst.log.utils as logUtils import lsst.pex.config as pexConfig import lsst.afw.display as afwDisplay verbosity = 4 logUtils.traceSetAt("ip.diffim", verbosity) imSize = 75 rdm = afwMath.Random(afwMath.Random.MT19937, 10101) writeFits = False def makeTest1(doAddNoise): gaussian1 = afwMath.GaussianFunction2D(1., 1., 0.) kernel1 = afwMath.AnalyticKernel(imSize, imSize, gaussian1) image1 = afwImage.ImageD(kernel1.getDimensions()) kernel1.computeImage(image1, False) image1 *= 10000 image1 = image1.convertF() mask1 = afwImage.Mask(kernel1.getDimensions()) var1 = afwImage.ImageF(image1, True)
import lsst.afw.image as afwImage import lsst.afw.math as afwMath import lsst.ip.diffim as ipDiffim import lsst.ip.diffim.diffimTools as diffimTools import lsst.log.utils as logUtils import lsst.afw.display.ds9 as ds9 import lsst.afw.display.utils as displayUtils subBackground = True display = True fwhm = 6.8 warp = True verbosity = 4 logUtils.traceSetAt("ip.diffim", verbosity) defDataDir = lsst.utils.getPackageDir('afwdata') imageProcDir = lsst.utils.getPackageDir('ip_diffim') if len(sys.argv) == 1: defSciencePath = os.path.join(defDataDir, "DC3a-Sim", "sci", "v26-e0", "v26-e0-c011-a10.sci") defTemplatePath = os.path.join(defDataDir, "DC3a-Sim", "sci", "v5-e0", "v5-e0-c011-a10.sci") elif len(sys.argv) == 3: defSciencePath = sys.argv[1] defTemplatePath = sys.argv[2] else: sys.exit(1)
import unittest import lsst.utils.tests import lsst.afw.geom as afwGeom import lsst.afw.image as afwImage import lsst.afw.math as afwMath import lsst.ip.diffim as ipDiffim import lsst.log.utils as logUtils import lsst.pex.config as pexConfig logUtils.traceSetAt("ip.diffim", 4) class DiffimTestCases(unittest.TestCase): def setUp(self): self.config = ipDiffim.ImagePsfMatchTask.ConfigClass() self.config.kernel.name = "DF" self.subconfig = self.config.kernel.active self.policy = pexConfig.makePolicy(self.subconfig) self.policy.set("useRegularization", False) self.policy.set("checkConditionNumber", False) # I am making shady kernels by hand self.policy.set("useCoreStats", False) # I am making off-center resids self.kList = ipDiffim.makeKernelBasisList(self.subconfig) self.size = 51 def makeCandidate(self, kSum, x, y): mi1 = afwImage.MaskedImageF(afwGeom.Extent2I(self.size, self.size))
def main(): imageProcDir = lsst.utils.getPackageDir('ip_diffim') defSciencePath = None defTemplatePath = None defOutputPath = 'diffImage.fits' defVerbosity = 5 defFwhm = 3.5 usage = """usage: %%prog [options] [scienceImage [templateImage [outputImage]]]] Notes: - image arguments are paths to MaskedImage fits files - image arguments must NOT include the final _img.fits - the result is science image - template image - the template image is convolved, the science image is not - default scienceMaskedImage=%s - default templateMaskedImage=%s - default outputImage=%s """ % (defSciencePath, defTemplatePath, defOutputPath) parser = optparse.OptionParser(usage) parser.add_option('-v', '--verbosity', type=int, default=defVerbosity, help='verbosity of Trace messages') parser.add_option('-d', '--display', action='store_true', default=False, help='display the images') parser.add_option('-b', '--bg', action='store_true', default=False, help='subtract backgrounds') parser.add_option('--fwhmS', type=float, help='Science Image Psf Fwhm (pixel)') parser.add_option('--fwhmT', type=float, help='Template Image Psf Fwhm (pixel)') (options, args) = parser.parse_args() def getArg(ind, defValue): if ind < len(args): return args[ind] return defValue sciencePath = getArg(0, defSciencePath) templatePath = getArg(1, defTemplatePath) outputPath = getArg(2, defOutputPath) if sciencePath == None or templatePath == None: parser.print_help() sys.exit(1) print('Science image: ', sciencePath) print('Template image:', templatePath) print('Output image: ', outputPath) fwhmS = defFwhm if options.fwhmS: print('FwhmS =', options.fwhmS) fwhmS = options.fwhmS fwhmT = defFwhm if options.fwhmT: print('Fwhmt =', options.fwhmT) fwhmT = options.fwhmT display = False if options.display: print('Display =', options.display) display = True bgSub = False if options.bg: print('Background subtract =', options.bg) bgSub = True if options.verbosity > 0: print('Verbosity =', options.verbosity) logUtils.traceSetAt("ip.diffim", options.verbosity) #### templateMaskedImage = afwImage.MaskedImageF(templatePath) scienceMaskedImage = afwImage.MaskedImageF(sciencePath) config = ipDiffim.ImagePsfMatchTask.ConfigClass() config.kernel.name = "AL" subconfig = config.kernel.active if bgSub: diffimTools.backgroundSubtract( subconfig.afwBackgroundConfig, [templateMaskedImage, scienceMaskedImage]) else: if subconfig.fitForBackground == False: print('NOTE: no background subtraction at all is requested') psfmatch = ipDiffim.ImagePsfMatchTask(subconfig) results = psfmatch.run(templateMaskedImage, scienceMaskedImage, "subtractMaskedImages", templateFwhmPix=fwhmT, scienceFwhmPix=fwhmS) differenceMaskedImage = results.subtractedImage differenceMaskedImage.writeFits(outputPath) if False: spatialKernel = results.psfMatchingKernel print(spatialKernel.getSpatialParameters()) if display: ds9.mtv(differenceMaskedImage)
def main(): defDataDir = lsst.utils.getPackageDir('afwdata') defSciencePath = os.path.join(defDataDir, "DC3a-Sim", "sci", "v26-e0", "v26-e0-c011-a10.sci.fits") defTemplatePath = os.path.join(defDataDir, "DC3a-Sim", "sci", "v5-e0", "v5-e0-c011-a10.sci.fits") defOutputPath = 'diffExposure.fits' defVerbosity = 0 defFwhm = 3.5 sigma2fwhm = 2. * np.sqrt(2. * np.log(2.)) usage = """usage: %%prog [options] [scienceExposure [templateExposure [outputExposure]]]] Notes: - image arguments are paths to Expoure fits files - image arguments must NOT include the final _img.fits - the result is science image - template image - the template exposure is convolved, the science exposure is not - default scienceExposure=%s - default templateExposure=%s - default outputExposure=%s """ % (defSciencePath, defTemplatePath, defOutputPath) parser = optparse.OptionParser(usage) parser.add_option('-v', '--verbosity', type=int, default=defVerbosity, help='verbosity of Trace messages') parser.add_option('-d', '--display', action='store_true', default=False, help='display the images') parser.add_option('-b', '--bg', action='store_true', default=False, help='subtract backgrounds using afw') parser.add_option('--fwhmS', type=float, help='Science Image Psf Fwhm (pixel)') parser.add_option('--fwhmT', type=float, help='Template Image Psf Fwhm (pixel)') (options, args) = parser.parse_args() def getArg(ind, defValue): if ind < len(args): return args[ind] return defValue sciencePath = getArg(0, defSciencePath) templatePath = getArg(1, defTemplatePath) outputPath = getArg(2, defOutputPath) if sciencePath is None or templatePath is None: parser.print_help() sys.exit(1) print('Science exposure: ', sciencePath) print('Template exposure:', templatePath) print('Output exposure: ', outputPath) templateExposure = afwImage.ExposureF(templatePath) scienceExposure = afwImage.ExposureF(sciencePath) config = ipDiffim.ImagePsfMatchTask.ConfigClass() config.kernel.name = "AL" subconfig = config.kernel.active fwhmS = defFwhm if options.fwhmS: if scienceExposure.hasPsf(): fwhm = scienceExposure.getPsf().computeShape().getDeterminantRadius() * sigma2fwhm print('NOTE: Embedded Psf has FwhmS =', fwhm) print('USING: FwhmS =', options.fwhmS) fwhmS = options.fwhmS fwhmT = defFwhm if options.fwhmT: if templateExposure.hasPsf(): fwhm = templateExposure.getPsf().computeShape().getDeterminantRadius() * sigma2fwhm print('NOTE: Embedded Psf has FwhmT =', fwhm) print('USING: FwhmT =', options.fwhmT) fwhmT = options.fwhmT bgSub = False if options.bg: print('Background subtract =', options.bg) bgSub = True if options.verbosity > 0: print('Verbosity =', options.verbosity) logUtils.traceSetAt("ip.diffim", options.verbosity) #### if bgSub: diffimTools.backgroundSubtract(subconfig.afwBackgroundConfig, [templateExposure.getMaskedImage(), scienceExposure.getMaskedImage()]) else: if not subconfig.fitForBackground: print('NOTE: no background subtraction at all is requested') # ImagePsfMatchTask requires a candidateList or that the exposoure have a PSF for detection if not scienceExposure.hasPsf(): sigmaS = fwhmS/sigma2fwhm kSize = int(6 * sigmaS) # minimum kernel size for FWHM oddKSize = kSize + 1 if kSize % 2 == 0 else kSize scienceExposure.setPsf(SingleGaussianPsf(oddKSize, oddKSize, sigmaS)) psfmatch = ipDiffim.ImagePsfMatchTask(config) results = psfmatch.subtractExposures(templateExposure, scienceExposure, templateFwhmPix=fwhmT, scienceFwhmPix=fwhmS) differenceExposure = results.subtractedExposure differenceExposure.writeFits(outputPath) if False: psfMatchingKernel = results.psfMatchingKernel backgroundModel = results.backgroundModel kernelCellSet = results.kernelCellSet diffimTools.writeKernelCellSet(kernelCellSet, psfMatchingKernel, backgroundModel, re.sub('.fits', '', outputPath))
lsst.log.Log.getLogger('afw').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger('afw.math').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger('afw.image').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger('afw.math.convolve').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger( 'TRACE5.afw.math.convolve.convolveWithInterpolation').setLevel( lsst.log.ERROR) lsst.log.Log.getLogger('TRACE2.afw.math.convolve.basicConvolve').setLevel( lsst.log.ERROR) lsst.log.Log.getLogger( 'TRACE4.afw.math.convolve.convolveWithBruteForce').setLevel( lsst.log.ERROR) log_level = lsst.log.ERROR # INFO import lsst.log.utils as logUtils logUtils.traceSetAt('afw', 0) except Exception as e: if not silent: print e print "LSSTSW has not been set up." # print 'HERE' from .utils import * from .exposure import * from .diffimTests import * from .catalog import * from .plot import * from . import multi #from . import afw #from . import tasks
def main(): defDataDir = lsst.utils.getPackageDir('afwdata') defSciencePath = os.path.join(defDataDir, "DC3a-Sim", "sci", "v26-e0", "v26-e0-c011-a10.sci.fits") defTemplatePath = os.path.join(defDataDir, "DC3a-Sim", "sci", "v5-e0", "v5-e0-c011-a10.sci.fits") defOutputPath = 'diffExposure.fits' defVerbosity = 0 defFwhm = 3.5 sigma2fwhm = 2. * np.sqrt(2. * np.log(2.)) usage = """usage: %%prog [options] [scienceExposure [templateExposure [outputExposure]]]] Notes: - image arguments are paths to Expoure fits files - image arguments must NOT include the final _img.fits - the result is science image - template image - the template exposure is convolved, the science exposure is not - default scienceExposure=%s - default templateExposure=%s - default outputExposure=%s """ % (defSciencePath, defTemplatePath, defOutputPath) parser = optparse.OptionParser(usage) parser.add_option('-v', '--verbosity', type=int, default=defVerbosity, help='verbosity of Trace messages') parser.add_option('-d', '--display', action='store_true', default=False, help='display the images') parser.add_option('-b', '--bg', action='store_true', default=False, help='subtract backgrounds using afw') parser.add_option('--fwhmS', type=float, help='Science Image Psf Fwhm (pixel)') parser.add_option('--fwhmT', type=float, help='Template Image Psf Fwhm (pixel)') (options, args) = parser.parse_args() def getArg(ind, defValue): if ind < len(args): return args[ind] return defValue sciencePath = getArg(0, defSciencePath) templatePath = getArg(1, defTemplatePath) outputPath = getArg(2, defOutputPath) if sciencePath is None or templatePath is None: parser.print_help() sys.exit(1) print('Science exposure: ', sciencePath) print('Template exposure:', templatePath) print('Output exposure: ', outputPath) templateExposure = afwImage.ExposureF(templatePath) scienceExposure = afwImage.ExposureF(sciencePath) config = ipDiffim.ImagePsfMatchTask.ConfigClass() config.kernel.name = "AL" subconfig = config.kernel.active fwhmS = defFwhm if options.fwhmS: if scienceExposure.hasPsf(): fwhm = scienceExposure.getPsf().computeShape( ).getDeterminantRadius() * sigma2fwhm print('NOTE: Embedded Psf has FwhmS =', fwhm) print('USING: FwhmS =', options.fwhmS) fwhmS = options.fwhmS fwhmT = defFwhm if options.fwhmT: if templateExposure.hasPsf(): fwhm = templateExposure.getPsf().computeShape( ).getDeterminantRadius() * sigma2fwhm print('NOTE: Embedded Psf has FwhmT =', fwhm) print('USING: FwhmT =', options.fwhmT) fwhmT = options.fwhmT bgSub = False if options.bg: print('Background subtract =', options.bg) bgSub = True if options.verbosity > 0: print('Verbosity =', options.verbosity) logUtils.traceSetAt("ip.diffim", options.verbosity) #### if bgSub: diffimTools.backgroundSubtract(subconfig.afwBackgroundConfig, [ templateExposure.getMaskedImage(), scienceExposure.getMaskedImage() ]) else: if not subconfig.fitForBackground: print('NOTE: no background subtraction at all is requested') # ImagePsfMatchTask requires a candidateList or that the exposoure have a PSF for detection if not scienceExposure.hasPsf(): sigmaS = fwhmS / sigma2fwhm kSize = int(6 * sigmaS) # minimum kernel size for FWHM oddKSize = kSize + 1 if kSize % 2 == 0 else kSize scienceExposure.setPsf(SingleGaussianPsf(oddKSize, oddKSize, sigmaS)) psfmatch = ipDiffim.ImagePsfMatchTask(config) results = psfmatch.subtractExposures(templateExposure, scienceExposure, templateFwhmPix=fwhmT, scienceFwhmPix=fwhmS) differenceExposure = results.subtractedExposure differenceExposure.writeFits(outputPath) if False: psfMatchingKernel = results.psfMatchingKernel backgroundModel = results.backgroundModel kernelCellSet = results.kernelCellSet diffimTools.writeKernelCellSet(kernelCellSet, psfMatchingKernel, backgroundModel, re.sub('.fits', '', outputPath))
def main(): defSciencePath = None defTemplatePath = None defOutputPath = 'matchedImage.fits' defVerbosity = 5 defFwhm = 3.5 usage = """usage: %%prog [options] [scienceImage [templateImage [outputImage]]]] Notes: - image arguments are paths to MaskedImage fits files - image arguments must NOT include the final _img.fits - the result is science image matched template image - the template image is convolved, the science image is not - default scienceMaskedImage=%s - default templateMaskedImage=%s - default outputImage=%s """ % (defSciencePath, defTemplatePath, defOutputPath) parser = optparse.OptionParser(usage) parser.add_option('-v', '--verbosity', type=int, default=defVerbosity, help='verbosity of Trace messages') parser.add_option('-d', '--display', action='store_true', default=False, help='display the images') parser.add_option('-b', '--bg', action='store_true', default=False, help='subtract backgrounds') parser.add_option('--fwhmS', type=float, help='Science Image Psf Fwhm (pixel)') parser.add_option('--fwhmT', type=float, help='Template Image Psf Fwhm (pixel)') (options, args) = parser.parse_args() def getArg(ind, defValue): if ind < len(args): return args[ind] return defValue sciencePath = getArg(0, defSciencePath) templatePath = getArg(1, defTemplatePath) outputPath = getArg(2, defOutputPath) if sciencePath is None or templatePath is None: parser.print_help() sys.exit(1) print('Science image: ', sciencePath) print('Template image:', templatePath) print('Output image: ', outputPath) fwhmS = defFwhm if options.fwhmS: print('FwhmS =', options.fwhmS) fwhmS = options.fwhmS fwhmT = defFwhm if options.fwhmT: print('Fwhmt =', options.fwhmT) fwhmT = options.fwhmT display = False if options.display: print('Display =', options.display) display = True bgSub = False if options.bg: print('Background subtract =', options.bg) bgSub = True if options.verbosity > 0: print('Verbosity =', options.verbosity) logUtils.traceSetAt("ip.diffim", options.verbosity) #### templateMaskedImage = afwImage.MaskedImageF(templatePath) scienceMaskedImage = afwImage.MaskedImageF(sciencePath) config = ipDiffim.ImagePsfMatch.ConfigClass() config.kernel.name = "AL" subconfig = config.kernel.active if bgSub: diffimTools.backgroundSubtract(subconfig.afwBackgroundConfig, [templateMaskedImage, scienceMaskedImage]) else: if not subconfig.fitForBackground: print('NOTE: no background subtraction at all is requested') psfmatch = ipDiffim.ImagePsfMatch(subconfig) results = psfmatch.matchMaskedImages(templateMaskedImage, scienceMaskedImage, templateFwhmPix=fwhmT, scienceFwhmPix=fwhmS) matchMaskedImage = results[0] matchMaskedImage.writeFits(outputPath) if False: spatialKernel = results[1] print(spatialKernel.getSpatialParameters()) if display: afwDisplay.Display().mtv(matchMaskedImage, title="Match Masked Image")
import lsst.afw.detection as afwDetection import lsst.meas.base as measBase import lsst.daf.base as dafBase import lsst.afw.table.catalogMatches as catMatch import lsst.log lsst.log.Log.getLogger('afw').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger('afw.math').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger('afw.image').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger('afw.math.convolve').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger('TRACE5.afw.math.convolve.convolveWithInterpolation').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger('TRACE2.afw.math.convolve.basicConvolve').setLevel(lsst.log.ERROR) lsst.log.Log.getLogger('TRACE4.afw.math.convolve.convolveWithBruteForce').setLevel(lsst.log.ERROR) log_level = lsst.log.ERROR # INFO import lsst.log.utils as logUtils logUtils.traceSetAt('afw', 0) except Exception as e: if not silent: print e print "LSSTSW has not been set up." # print 'HERE' from .utils import * from .exposure import * from .diffimTests import * from .catalog import * from .plot import * from . import multi #from . import afw
import os import sys import unittest import lsst.geom import lsst.afw.image as afwImage import lsst.afw.math as afwMath import lsst.log.utils as logUtils import lsst.meas.algorithms as algorithms import lsst.meas.algorithms.defects as defects import lsst.pex.config as pexConfig import lsst.utils import lsst.utils.tests # Increase the number for more verbose messages logUtils.traceSetAt("algorithms.CR", 3) try: display except NameError: display = False else: import lsst.afw.display as afwDisplay afwDisplay.setDefaultMaskTransparency(75) try: afwdataDir = lsst.utils.getPackageDir('afwdata') imageFile0 = os.path.join(afwdataDir, "CFHT", "D4", "cal-53535-i-797722_1.fits") except Exception: imageFile0 = None