def run(display=False):
    """Subtract background, mask cosmic rays, then detect and measure
    """
    # Create the tasks; if you use the default config then you don't have to construct the config,
    # as shown in constructing backgroundTask, but constructing the config makes it easier to modify
    repairConfig = RepairTask.ConfigClass()
    repairTask = RepairTask(config=repairConfig)

    backgroundTask = SubtractBackgroundTask()

    damConfig = DetectAndMeasureTask.ConfigClass()
    damConfig.detection.thresholdValue = 5.0
    damConfig.detection.includeThresholdMultiplier = 1.0
    damConfig.measurement.doApplyApCorr = "yes"
    detectAndMeasureTask = DetectAndMeasureTask(config=damConfig)

    # load the data
    # Exposure ID and the number of bits required for exposure IDs are usually obtained from a data repo,
    # but here we pick reasonable values (there are 64 bits to share between exposure IDs and source IDs).
    exposure = loadData()
    exposureIdInfo = ExposureIdInfo(expId=1, expBits=5)

    # repair cosmic rays
    repairTask.run(exposure=exposure)

    # subtract an initial estimate of background level
    backgroundTask.run(exposure=exposure)

    # detect and measure
    damRes = detectAndMeasureTask.run(exposure=exposure, exposureIdInfo=exposureIdInfo)
    if display:
        displayAstrometry(frame=2, exposure=damRes.exposure, sourceCat=damRes.sourceCat, pause=False)
Beispiel #2
0
    def test_amplifierSigma(self):
        """Clipped sigma against CR-rejected sigma

        Notes
        -----
        DMTN-101 4.4

        Run a CR rejection on the result and confirm that the
        unclipped standard deviation is consistent with the 5-sigma
        clipped value.

        """
        crTask = RepairTask()
        crRejected = self.exposure.clone()
        psf = measAlg.SingleGaussianPsf(21, 21, 3.0)
        crRejected.setPsf(psf)
        crTask.run(crRejected, keepCRs=False)

        ccd = self.exposure.getDetector()
        for amp in ccd:
            ampExposure = self.exposure.Factory(self.exposure, amp.getBBox())
            clipControl = afwMath.StatisticsControl(5.0, 5)
            clipControl.setAndMask(
                self.exposure.mask.getPlaneBitMask(["SAT", "BAD", "NO_DATA"]))
            sigmaClip = afwMath.makeStatistics(ampExposure.getImage(),
                                               afwMath.STDEVCLIP,
                                               clipControl).getValue()

            crAmp = crRejected.Factory(crRejected, amp.getBBox())
            statControl = afwMath.StatisticsControl()
            statControl.setAndMask(
                self.exposure.mask.getPlaneBitMask(
                    ["SAT", "BAD", "NO_DATA", "CR"]))
            sigma = afwMath.makeStatistics(crAmp.getImage(), afwMath.STDEV,
                                           statControl).getValue()

            # needs to be < 0.05
            fractionalError = np.abs(sigma - sigmaClip) / sigmaClip
            self.assertLess(fractionalError,
                            3.0,
                            msg="Test 4.4: {amp.getName()} {fractionalError}")
Beispiel #3
0
def run(display=False):
    """Subtract background, mask cosmic rays, then detect and measure
    """
    # Create the tasks; note that background estimation is performed by a function,
    # not a task, though it has a config
    repairConfig = RepairTask.ConfigClass()
    repairTask = RepairTask(config=repairConfig)

    backgroundConfig = estimateBackground.ConfigClass()

    damConfig = DetectAndMeasureTask.ConfigClass()
    damConfig.detection.thresholdValue = 5.0
    damConfig.detection.includeThresholdMultiplier = 1.0
    damConfig.measurement.doApplyApCorr = "yes"
    detectAndMeasureTask = DetectAndMeasureTask(config=damConfig)

    # load the data
    # Exposure ID and the number of bits required for exposure IDs are usually obtained from a data repo,
    # but here we pick reasonable values (there are 64 bits to share between exposure IDs and source IDs).
    exposure = loadData()
    exposureIdInfo = ExposureIdInfo(expId=1, expBits=5)

    # repair cosmic rays
    repairTask.run(exposure=exposure)

    # subtract an initial estimate of background level
    estBg, exposure = estimateBackground(
        exposure=exposure,
        backgroundConfig=backgroundConfig,
        subtract=True,
    )

    # detect and measure
    damRes = detectAndMeasureTask.run(exposure=exposure,
                                      exposureIdInfo=exposureIdInfo)
    if display:
        displayAstrometry(frame=2,
                          exposure=damRes.exposure,
                          sourceCat=damRes.sourceCat,
                          pause=False)
def run(display=False):
    """Subtract background, mask cosmic rays, then detect and measure
    """
    # Create the tasks; note that background estimation is performed by a function,
    # not a task, though it has a config
    repairConfig = RepairTask.ConfigClass()
    repairTask = RepairTask(config=repairConfig)

    backgroundConfig = estimateBackground.ConfigClass()

    damConfig = DetectAndMeasureTask.ConfigClass()
    damConfig.detection.thresholdValue = 5.0
    damConfig.detection.includeThresholdMultiplier = 1.0
    damConfig.measurement.doApplyApCorr = "yes"
    detectAndMeasureTask = DetectAndMeasureTask(config=damConfig)

    # load the data
    # Exposure ID and the number of bits required for exposure IDs are usually obtained from a data repo,
    # but here we pick reasonable values (there are 64 bits to share between exposure IDs and source IDs).
    exposure = loadData()
    exposureIdInfo = ExposureIdInfo(expId=1, expBits=5)

    # repair cosmic rays
    repairTask.run(exposure=exposure)

    # subtract an initial estimate of background level
    estBg, exposure = estimateBackground(
        exposure = exposure,
        backgroundConfig = backgroundConfig,
        subtract = True,
    )

    # detect and measure
    damRes = detectAndMeasureTask.run(exposure=exposure, exposureIdInfo=exposureIdInfo)
    if display:
        displayAstrometry(frame=2, exposure=damRes.exposure, sourceCat=damRes.sourceCat, pause=False)
Beispiel #5
0
def runRepair(exp, defectList):
    repair = RepairTask(name="RepairTask")
    repair.run(exp, defects=defectList)
Beispiel #6
0
def runRepair(exp, defectList):
    repair = RepairTask(name="RepairTask")
    repair.run(exp, defects=defectList)