Esempio n. 1
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)