Ejemplo n.º 1
0
class PositionGalSimFakesConfig(FakeSourcesConfig):
    galList = lsstConfig.Field(dtype=str,
                               doc="catalog of galaxies to add")
    maxMargin = lsstConfig.Field(dtype=int, default=600,
                                 optional=True,
                                 doc="Size of margin")
    seed = lsstConfig.Field(dtype=int, default=1,
                            doc="Seed for random number generator")
    addShear = lsstConfig.Field(dtype=bool, default=False,
                                doc='include shear in the galaxies')
    addMask = lsstConfig.Field(dtype=bool, default=False,
                               doc='add FAKE mask plane')
    sersic_prec = lsstConfig.Field(dtype=float, default=0.0,
                                   doc='The desired precision for n')
    cosStr = 'Use Galsim.COSMOSlog()'
    serStr = 'Single sersic galaxies added'
    dSerStr = 'Double sersic galaxies added'
    realStr = 'Real HST galaxy images added'
    galType = lsstConfig.ChoiceField(dtype=str, default='sersic',
                                     allowed={'dsersic': dSerStr,
                                              'sersic': serStr,
                                              'real': realStr,
                                              'cosmos': cosStr},
                                     doc='type of GalSim galaxies to add')
    exclusionLevel = lsstConfig.ChoiceField(dtype=str, default='none',
                                            allowed={'none': "None",
                                                     'marginal': "Marginal",
                                                     'bad_stamp': "Bad Stamp",
                                                     'bad_fits': "Bad Fits"},
                                            doc='Exclusion level')
Ejemplo n.º 2
0
class SafeConfig(pexConfig.Config):
    coaddName = pexConfig.ChoiceField(
        dtype   = str,
        doc     = "Type of coadd to use",
        default = "deep",
        allowed = {"deep"   : "deepCoadd"}
        )
Ejemplo n.º 3
0
class ReplaceWithNoiseConfig(pexConfig.Config):
    """
    Configuration for ReplaceWithNoiseTask.
    """
    noiseSource = pexConfig.ChoiceField(
        doc=
        'How do we choose the mean and variance of the Gaussian noise we generate?',
        dtype=str,
        allowed={
            'measure':
            'Measure clipped mean and variance from the whole image',
            'meta': 'Mean = 0, variance = the "BGMEAN" metadata entry',
            'variance': "Mean = 0, variance = the image's variance",
        },
        default='measure',
        optional=False)

    noiseOffset = pexConfig.Field(dtype=float,
                                  optional=False,
                                  default=0.,
                                  doc='Add ann offset to the generated noise.')

    noiseSeed = pexConfig.Field(
        dtype=int,
        default=0,
        doc='The seed value to use for random number generation.')
class ScaleSdssZeroPointConfig(ScaleZeroPointTask.ConfigClass):
    """Config for ScaleSdssZeroPointTask
    """
    selectFluxMag0 = pexConfig.ConfigurableField(
        doc=
        "Task to select data to compute spatially varying photometric zeropoint",
        target=SelectSdssFluxMag0Task,
    )
    interpStyle = pexConfig.ChoiceField(
        dtype=str,
        doc="Algorithm to interpolate the flux scalings;"
        "Maps to an enum; see afw.math.Interpolate",
        default="NATURAL_SPLINE",
        allowed={
            "CONSTANT":
            "Use a single constant value",
            "LINEAR":
            "Use linear interpolation",
            "CUBIC_SPLINE":
            "cubic spline",
            "NATURAL_SPLINE":
            "cubic spline with zero second derivative at endpoints",
            "AKIMA_SPLINE":
            "higher-level nonlinear spline that is more robust to outliers",
        })
    bufferWidth = pexConfig.Field(
        dtype=float,
        doc=
        "Buffer in the R.A. direction added to the region to be searched by selectFluxMag0"
        "Units are multiples of SDSS field widths (1489pix). (e.g. if the exposure is 1000x1000pixels, "
        "a bufferWidth of 2 results in a search region of 6956 x 1000, centered on the original position.",
        default=3,
    )
Ejemplo n.º 5
0
class ImageReducerSubtaskConfig(pexConfig.Config):
    """Configuration parameters for the ImageReducerSubtask
    """
    reduceOperation = pexConfig.ChoiceField(
        dtype=str,
        doc="""Operation to use for reducing subimages into new image.""",
        default="average",
        allowed={
            "none": """simply return a list of values and don't re-map results into
                       a new image (noop operation)""",
            "copy": """copy pixels directly from subimage into correct location in
                       new exposure (potentially non-deterministic for overlaps)""",
            "sum": """add pixels from overlaps (probably never wanted; used for testing)
                       into correct location in new exposure""",
            "average": """same as copy, but also average pixels from overlapped regions
                       (NaNs ignored)""",
            "coaddPsf": """Instead of constructing an Exposure, take a list of returned
                       PSFs and use CoaddPsf to construct a single PSF that covers the
                       entire input exposure""",
        }
    )
    badMaskPlanes = pexConfig.ListField(
        dtype=str,
        doc="""Mask planes to set for invalid pixels""",
        default=('INVALID_MAPREDUCE', 'BAD', 'NO_DATA')
    )
Ejemplo n.º 6
0
class MakeFakeInputsConfig(pexConfig.Config):
    """Parse input for MakeFakeInputTask."""

    coaddName = pexConfig.ChoiceField(
        dtype=str,
        doc="Type of data to use",
        default="deep",
        allowed={"deep": "deepCoadd"}
    )
    rhoFakes = pexConfig.Field(doc="number of fakes per patch", dtype=int,
                               optional=False, default=500)
    inputCat = pexConfig.Field(
        doc="input galaxy catalog, if none just return ra/dec list",
        dtype=str,
        optional=True, default=DEFAULT_CATALOG_PATH)
    outDir = pexConfig.Field(doc='output directory for catalogs',
                             dtype=str,
                             optional=True, default='.')
    rad = pexConfig.Field(doc="minimum distance between fake objects",
                          dtype=float, optional=True, default=None)
    acpMask = pexConfig.Field(doc='region to include',
                              dtype=str,
                              optional=True, default='')
    rejMask = pexConfig.Field(doc='region to mask out',
                              dtype=str,
                              optional=True, default='')
    innerTract = pexConfig.Field(doc='Only add to the inner Tract region',
                                 dtype=bool, optional=True, default=False)
    uniqueID = pexConfig.Field(doc='Use the index as unique ID',
                               dtype=bool, optional=False, default=True)
Ejemplo n.º 7
0
class PipeQaConfig(pexConfig.Config):
    
    doZptFitQa      = pexConfig.Field(dtype = bool,
                                      doc = "Photometric Zeropoint: qaAnalysis.ZeropointFitQaTask",
                                      default = True)
    doEmptySectorQa = pexConfig.Field(dtype = bool,
                                      doc = "Empty Sectors: qaAnalysis.EmptySectorQaTask", default = True)
    doAstromQa      = pexConfig.Field(dtype = bool,
                                      doc = "Astrometric Error: qaAnalysis.AstrometricErrorQaTask",
                                      default = True)
    doPerformanceQa = pexConfig.Field(dtype = bool,
                                      doc = "Performance: qaAnalysis.PerformanceQaTask", default = True)
    doPhotCompareQa = pexConfig.Field(dtype = bool,
                                      doc = "Photometric Error: qaAnalysis.PhotCompareQaTask", default = True)
    doPsfShapeQa    = pexConfig.Field(dtype = bool,
                                      doc = "Psf Shape: qaAnalysis.PsfShapeQaTask", default = True)
    doCompleteQa    = pexConfig.Field(dtype = bool,
                                      doc = "Photometric Depth: qaAnalysis.CompletenessQaTask",
                                      default = True)
    doVignettingQa  = pexConfig.Field(dtype = bool,
                                      doc = "Vignetting testing: qaAnalysis.VignettingQaTask",
                                      default = True)
    doVisitQa       = pexConfig.Field(dtype = bool,
                                      doc = "Visit to visit: qaAnalysis.VisitToVisitPhotQaTask and "+
                                      "qaAnalysis.VisitToVisitAstromQaTask", default = False)

    
    zptFitQa        = pexConfig.ConfigurableField(target = ZeropointFitQaTask,
                                                  doc = "Quality of zeropoint fit")
    emptySectorQa   = pexConfig.ConfigurableField(target = EmptySectorQaTask,
                                                  doc = "Look for missing matches")
    astromQa        = pexConfig.ConfigurableField(target = AstrometricErrorQaTask,
                                                  doc = "Quality of astrometric fit")
    performanceQa   = pexConfig.ConfigurableField(target = PerformanceQaTask,
                                                  doc = "Performance")
    photCompareQa   = pexConfig.ConfigurableField(target = PhotCompareQaTask,
                                                  doc = "Quality of photometry")
    psfShapeQa      = pexConfig.ConfigurableField(target = PsfShapeQaTask,
                                                  doc = "Shape of Psf")
    completeQa      = pexConfig.ConfigurableField(target = CompletenessQaTask,
                                                  doc = "Completeness of detection")
    vignettingQa    = pexConfig.ConfigurableField(target = VignettingQaTask,
                                                  doc = "Look for residual vignetting features")
    vvPhotQa        = pexConfig.ConfigurableField(target = VisitToVisitPhotQaTask,
                                                  doc = "Visit to visit photometry")
    vvAstromQa     = pexConfig.ConfigurableField(target = VisitToVisitAstromQaTask,
                                                 doc = "Visit to visit astrometry")

    shapeAlgorithm = pexConfig.ChoiceField(
        dtype = str,
        doc = "Shape Algorithm to load",
        default = "HSM_REGAUSS",
        allowed = {
            "HSM_REGAUSS": "Hirata-Seljac-Mandelbaum Regaussianization",
            "HSM_BJ" : "Hirata-Seljac-Mandelbaum Bernstein&Jarvis",
            "HSM_LINEAR" : "Hirata-Seljac-Mandelbaum Linear",
            "HSM_KSB" : "Hirata-Seljac-Mandelbaum KSB",
            "HSM_SHAPELET" : "Hirata-Seljac-Mandelbaum SHAPELET"
            }
        )
Ejemplo n.º 8
0
class EimageIsrConfig(pexConfig.Config):
    """Config for EimageIsrTask"""
    doAddNoise = pexConfig.Field(dtype=bool, default=False,
                                 doc="Add a flat Poisson noise background to the eimage?")
    rngSeed = pexConfig.Field(dtype=int, default=None, optional=True,
                              doc=("Random number seed used when adding noise (passed directly"
                                   " to numpy at task initialization)"))
    noiseValue = pexConfig.Field(dtype=int, default=1000, doc="Mean of the Poisson distribution in counts")
    doSetVariance = pexConfig.Field(dtype=bool, default=True, doc="Set the variance plane in the eimage?")
    varianceType = pexConfig.ChoiceField(dtype=str, default="image",
                                         allowed={"image": "set variance from image plane",
                                                  "value": "set variance to a value"},
                                         doc="Choose method for setting the variance")
    varianceValue = pexConfig.Field(dtype=float, default=0.01, doc="Value to use in the variance plane.")
    maskEdgeBorder = pexConfig.Field(dtype=int, default=0, doc="Set mask to EDGE for a border of x pixels")
    sat_val = pexConfig.Field(dtype=int, default=100000, doc="Value at which to detect saturation")
    interp_size = pexConfig.Field(dtype=float, default=1, doc="Size of interpolation kernel in arcsec")
    growSaturationFootprintSize = pexConfig.Field(dtype=int, default=1,
                                                  doc="Number of pixels by which to grow"
                                                      "the saturation footprints")
    datasetType = pexConfig.Field(
        dtype=str,
        doc="Dataset type for input data; users will typically leave this alone.",
        default="eimage",
    )
Ejemplo n.º 9
0
class Simple(pexConfig.Config):
    i = pexConfig.Field("integer test", int, optional=True)
    f = pexConfig.Field("float test", float, default=3.0)
    b = pexConfig.Field("boolean test", bool, default=False, optional=False)
    c = pexConfig.ChoiceField("choice test",
                              str,
                              default="Hello",
                              allowed={
                                  "Hello": "First choice",
                                  "World": "second choice"
                              })
    r = pexConfig.RangeField("Range test",
                             float,
                             default=3.0,
                             optional=False,
                             min=3.0,
                             inclusiveMin=True)
    ll = pexConfig.ListField("list test",
                             int,
                             default=[1, 2, 3],
                             maxLength=5,
                             itemCheck=lambda x: x is not None and x > 0)
    d = pexConfig.DictField("dict test",
                            str,
                            str,
                            default={"key": "value"},
                            itemCheck=lambda x: x.startswith('v'))
    n = pexConfig.Field("nan test", float, default=float("NAN"))
Ejemplo n.º 10
0
class MakeFakeInputsConfig(pexConfig.Config):
    coaddName = pexConfig.ChoiceField(dtype=str,
                                      doc="Type of data to use",
                                      default="deep",
                                      allowed={"deep": "deepCoadd"})

    inputCat = pexConfig.Field(
        doc="input galaxy catalog, if none just return ra/dec list",
        dtype=str,
        optional=True,
        default=DEFAULT_CATALOG_PATH)
    outDir = pexConfig.Field(doc='output directory for catalogs',
                             dtype=str,
                             optional=True,
                             default='.')
    acpMask = pexConfig.Field(doc='region to include',
                              dtype=str,
                              optional=True,
                              default='')
    rejMask = pexConfig.Field(doc='region to mask out',
                              dtype=str,
                              optional=True,
                              default='')
    innerTract = pexConfig.Field(doc='only add to the inner Tract region',
                                 dtype=bool,
                                 optional=True,
                                 default=False)
    uniqueID = pexConfig.Field(doc='Use the index as unique ID',
                               dtype=bool,
                               optional=True,
                               default=True)
    theta_grid = pexConfig.Field(doc='Grid separation in arcsec)',
                                 dtype=float,
                                 optional=False,
                                 default=25)
Ejemplo n.º 11
0
class InitialPsfConfig(pexConfig.Config):
    """!Describes the initial PSF used for detection and measurement before we do PSF determination."""

    model = pexConfig.ChoiceField(
        dtype=str,
        doc="PSF model type",
        default="SingleGaussian",
        allowed={
            "SingleGaussian": "Single Gaussian model",
            "DoubleGaussian": "Double Gaussian model",
        },
    )
    pixelScale = pexConfig.Field(
        dtype=float,
        doc="Pixel size (arcsec).  Only needed if no Wcs is provided",
        default=0.25,
    )
    fwhm = pexConfig.Field(
        dtype=float,
        doc="FWHM of PSF model (arcsec)",
        default=1.0,
    )
    size = pexConfig.Field(
        dtype=int,
        doc="Size of PSF model (pixels)",
        default=15,
    )
Ejemplo n.º 12
0
class WarperConfig(pexConfig.Config):
    warpingKernelName = pexConfig.ChoiceField(dtype=str,
                                              doc="Warping kernel",
                                              default="lanczos4",
                                              allowed={
                                                  "bilinear":
                                                  "bilinear interpolation",
                                                  "lanczos3":
                                                  "Lanczos kernel of order 3",
                                                  "lanczos4":
                                                  "Lanczos kernel of order 4",
                                                  "lanczos5":
                                                  "Lanczos kernel of order 5",
                                              })
    maskWarpingKernelName = pexConfig.ChoiceField(
        dtype=str,
        doc="Warping kernel for mask (use warpingKernelName if '')",
        default="bilinear",
        allowed={
            "":
            "use the regular warping kernel for the mask plane, as well as the image and variance planes",
            "bilinear": "bilinear interpolation",
            "lanczos3": "Lanczos kernel of order 3",
            "lanczos4": "Lanczos kernel of order 4",
            "lanczos5": "Lanczos kernel of order 5",
        })
    interpLength = pexConfig.Field(
        dtype=int,
        doc="interpLength argument to lsst.afw.math.warpExposure",
        default=_DefaultInterpLength,
    )
    cacheSize = pexConfig.Field(
        dtype=int,
        doc="cacheSize argument to lsst.afw.math.SeparableKernel.computeCache",
        default=_DefaultCacheSize,
    )
    devicePreference = pexConfig.Field(
        dtype=int,
        doc="use GPU acceleration?",
        default=afwGpu.DEFAULT_DEVICE_PREFERENCE,
    )
    growFullMask = pexConfig.Field(
        dtype=int,
        doc="mask bits to grow to full width of image/variance kernel,",
        default=afwImage.MaskU.getPlaneBitMask("EDGE"),
    )
Ejemplo n.º 13
0
class MergeDefectsTaskConfig(pipeBase.PipelineTaskConfig,
                             pipelineConnections=MergeDefectsConnections):
    """Configuration for merging single exposure defects.
    """
    assertSameRun = pexConfig.Field(
        dtype=bool,
        doc=
        ("Ensure that all visits are from the same run? Raises if this is not the case, or"
         "if the run key isn't found."),
        default=
        False,  # false because most obs_packages don't have runs. obs_lsst/ts8 overrides this.
    )
    ignoreFilters = pexConfig.Field(
        dtype=bool,
        doc=
        ("Set the filters used in the CALIB_ID to NONE regardless of the filters on the input"
         " images. Allows mixing of filters in the input flats. Set to False if you think"
         " your defects might be chromatic and want to have registry support for varying"
         " defects with respect to filter."),
        default=True,
    )
    nullFilterName = pexConfig.Field(
        dtype=str,
        doc=
        ("The name of the null filter if ignoreFilters is True. Usually something like NONE or EMPTY"
         ),
        default="NONE",
    )
    combinationMode = pexConfig.ChoiceField(
        doc="Which types of defects to identify",
        dtype=str,
        default="FRACTION",
        allowed={
            "AND":
            "Logical AND the pixels found in each visit to form set ",
            "OR":
            "Logical OR the pixels found in each visit to form set ",
            "FRACTION":
            "Use pixels found in more than config.combinationFraction of visits ",
        })
    combinationFraction = pexConfig.RangeField(
        dtype=float,
        doc=
        ("The fraction (0..1) of visits in which a pixel was found to be defective across"
         " the visit list in order to be marked as a defect. Note, upper bound is exclusive, so use"
         " mode AND to require pixel to appear in all images."),
        default=0.7,
        min=0,
        max=1,
    )
    edgesAsDefects = pexConfig.Field(
        dtype=bool,
        doc=
        ("Mark all edge pixels, as defined by nPixBorder[UpDown, LeftRight], as defects."
         " Normal treatment is to simply exclude this region from the defect finding, such that no"
         " defect will be located there."),
        default=False,
    )
Ejemplo n.º 14
0
class WarperConfig(pexConfig.Config):
    warpingKernelName = pexConfig.ChoiceField(dtype=str,
                                              doc="Warping kernel",
                                              default="lanczos3",
                                              allowed={
                                                  "bilinear":
                                                  "bilinear interpolation",
                                                  "lanczos3":
                                                  "Lanczos kernel of order 3",
                                                  "lanczos4":
                                                  "Lanczos kernel of order 4",
                                                  "lanczos5":
                                                  "Lanczos kernel of order 5",
                                              })
    maskWarpingKernelName = pexConfig.ChoiceField(
        dtype=str,
        doc="Warping kernel for mask (use ``warpingKernelName`` if '')",
        default="bilinear",
        allowed={
            "":
            "use the regular warping kernel for the mask plane, as well as the image and variance planes",
            "bilinear": "bilinear interpolation",
            "lanczos3": "Lanczos kernel of order 3",
            "lanczos4": "Lanczos kernel of order 4",
            "lanczos5": "Lanczos kernel of order 5",
        })
    interpLength = pexConfig.Field(
        dtype=int,
        doc="``interpLength`` argument to `lsst.afw.math.warpExposure`",
        default=_DefaultInterpLength,
    )
    cacheSize = pexConfig.Field(
        dtype=int,
        doc=
        "``cacheSize`` argument to `lsst.afw.math.SeparableKernel.computeCache`",
        default=_DefaultCacheSize,
    )
    growFullMask = pexConfig.Field(
        dtype=int,
        doc="mask bits to grow to full width of image/variance kernel,",
        default=afwImage.Mask.getPlaneBitMask("EDGE"),
    )
Ejemplo n.º 15
0
class DebugFakesConfig(pexConfig.Config):
    coaddName = pexConfig.ChoiceField(dtype=str,
                                      doc="Type of data to use",
                                      default="deep",
                                      allowed={"deep": "deepCoadd"})
    fakes = pexConfig.ConfigurableField(
        target=DummyFakeSourcesTask,
        doc="Injection of fake sources for test purposes (retarget to enable)")
    display = pexConfig.Field(dtype=bool,
                              doc='display exposure',
                              default=False)
Ejemplo n.º 16
0
class OverscanCorrectionTaskConfig(pexConfig.Config):
    """Overscan correction options.
    """
    fitType = pexConfig.ChoiceField(
        dtype=str,
        doc="The method for fitting the overscan bias level.",
        default='MEDIAN',
        allowed={
            "POLY":
            "Fit ordinary polynomial to the longest axis of the overscan region",
            "CHEB":
            "Fit Chebyshev polynomial to the longest axis of the overscan region",
            "LEG":
            "Fit Legendre polynomial to the longest axis of the overscan region",
            "NATURAL_SPLINE":
            "Fit natural spline to the longest axis of the overscan region",
            "CUBIC_SPLINE":
            "Fit cubic spline to the longest axis of the overscan region",
            "AKIMA_SPLINE":
            "Fit Akima spline to the longest axis of the overscan region",
            "MEAN":
            "Correct using the mean of the overscan region",
            "MEANCLIP":
            "Correct using a clipped mean of the overscan region",
            "MEDIAN":
            "Correct using the median of the overscan region",
            "MEDIAN_PER_ROW":
            "Correct using the median per row of the overscan region",
        },
    )
    order = pexConfig.Field(
        dtype=int,
        doc=(
            "Order of polynomial to fit if overscan fit type is a polynomial, "
            "or number of spline knots if overscan fit type is a spline."),
        default=1,
    )
    numSigmaClip = pexConfig.Field(
        dtype=float,
        doc="Rejection threshold (sigma) for collapsing overscan before fit",
        default=3.0,
    )
    maskPlanes = pexConfig.ListField(
        dtype=str,
        doc="Mask planes to reject when measuring overscan",
        default=['BAD', 'SAT'],
    )
    overscanIsInt = pexConfig.Field(
        dtype=bool,
        doc="Treat overscan as an integer image for purposes of fitType=MEDIAN"
        " and fitType=MEDIAN_PER_ROW.",
        default=True,
    )
class ProcessCalibLsstSimConfig(IsrTask.ConfigClass):

    """Config for ProcessCcdLsstSim"""
    sigmaClip = pexConfig.Field(dtype=float, default=3., doc="Sigma level for sigma clipping")
    clipIter = pexConfig.Field(dtype=int, default=5, doc="Number of iterations for sigma clipping")
    type = pexConfig.ChoiceField(dtype=str, default='bias', doc="Type of master calibration to produce",
                                 allowed={'bias': "make master bias(zero)",
                                          'dark': "make master dark",
                                          'flat': "make master flat"})

    def __init__(self, *args, **kwargs):
        pexConfig.Config.__init__(self, *args, **kwargs)
Ejemplo n.º 18
0
class ConfigTest(pexConfig.Config):
    fStr = pexConfig.Field(dtype=str, default="default", doc="")
    fBool = pexConfig.Field(dtype=bool, default=False, doc="")
    fInt = pexConfig.Field(dtype=int, default=-1, doc="")
    fFloat = pexConfig.Field(dtype=float, default=-1., doc="")

    fListStr = pexConfig.ListField(dtype=str, default=[], doc="")
    fListBool = pexConfig.ListField(dtype=bool, default=[], doc="")
    fListInt = pexConfig.ListField(dtype=int, default=[], doc="")

    fChoiceStr = pexConfig.ChoiceField(dtype=str,
                                       allowed=dict(A="a", B="b", C="c"),
                                       doc="")
    fChoiceInt = pexConfig.ChoiceField(dtype=int,
                                       allowed={
                                           1: "a",
                                           2: "b",
                                           3: "c"
                                       },
                                       doc="")

    fDictStrInt = pexConfig.DictField(keytype=str, itemtype=int, doc="")
Ejemplo n.º 19
0
class InterpImageConfig(pexConfig.Config):
    """Config for InterpImageTask
    """
    modelPsf = measAlg.GaussianPsfFactory.makeField(doc="Model Psf factory")

    useFallbackValueAtEdge = pexConfig.Field(
        dtype=bool,
        doc="Smoothly taper to the fallback value at the edge of the image?",
        default=True,
    )
    fallbackValueType = pexConfig.ChoiceField(
        dtype=str,
        doc=
        "Type of statistic to calculate edge fallbackValue for interpolation",
        allowed={
            "MEAN": "mean",
            "MEDIAN": "median",
            "MEANCLIP": "clipped mean",
            "USER": "******",
        },
        default="MEDIAN",
    )
    fallbackUserValue = pexConfig.Field(
        dtype=float,
        doc=
        "If fallbackValueType is 'USER' then use this as the fallbackValue; ignored otherwise",
        default=0.0,
    )
    negativeFallbackAllowed = pexConfig.Field(
        dtype=bool,
        doc=
        ("Allow negative values for egde interpolation fallbackValue?  If False, set "
         "fallbackValue to max(fallbackValue, 0.0)"),
        default=False,
    )
    transpose = pexConfig.Field(
        dtype=int,
        default=False,
        doc="Transpose image before interpolating? "
        "This allows the interpolation to act over columns instead of rows.")

    def validate(self):
        pexConfig.Config.validate(self)
        if self.useFallbackValueAtEdge:
            if (not self.negativeFallbackAllowed
                    and self.fallbackValueType == "USER"
                    and self.fallbackUserValue < 0.0):
                raise ValueError(
                    "User supplied fallbackValue is negative (%.2f) but "
                    "negativeFallbackAllowed is False" %
                    self.fallbackUserValue)
Ejemplo n.º 20
0
class SpatialScaleZeroPointConfig(ScaleZeroPointConfig):
    selectFluxMag0 = pexConfig.ConfigurableField(
        doc=
        "Task to select data to compute spatially varying photometric zeropoint",
        target=BaseSelectImagesTask,
    )

    interpStyle = pexConfig.ChoiceField(
        dtype=str,
        doc="Algorithm to interpolate the flux scalings;"
        "Currently only one choice implemented",
        default="CONSTANT",
        allowed={
            "CONSTANT": "Use a single constant value",
        })
Ejemplo n.º 21
0
class CpFlatNormalizationTaskConfig(
        pipeBase.PipelineTaskConfig,
        pipelineConnections=CpFlatNormalizationConnections):
    level = pexConfig.ChoiceField(
        dtype=str,
        doc="Which level to apply normalizations.",
        default='DETECTOR',
        allowed={
            'DETECTOR': "Correct using full detector statistics.",
            'AMP': "Correct using individual amplifiers.",
        },
    )
    scaleMaxIter = pexConfig.Field(
        dtype=int,
        doc="Max number of iterations to use in scale solver.",
        default=10,
    )
Ejemplo n.º 22
0
class LinearitySolveConfig(pipeBase.PipelineTaskConfig,
                           pipelineConnections=LinearitySolveConnections):
    """Configuration for solving the linearity from PTC dataset.
    """
    linearityType = pexConfig.ChoiceField(
        dtype=str,
        doc="Type of linearizer to construct.",
        default="Squared",
        allowed={
            "LookupTable": "Create a lookup table solution.",
            "Polynomial": "Create an arbitrary polynomial solution.",
            "Squared": "Create a single order squared solution.",
            "Spline": "Create a spline based solution.",
            "None": "Create a dummy solution.",
        })
    polynomialOrder = pexConfig.Field(
        dtype=int,
        doc="Degree of polynomial to fit.",
        default=3,
    )
    splineKnots = pexConfig.Field(
        dtype=int,
        doc="Number of spline knots to use in fit.",
        default=10,
    )
    maxLookupTableAdu = pexConfig.Field(
        dtype=int,
        doc="Maximum DN value for a LookupTable linearizer.",
        default=2**18,
    )
    maxLinearAdu = pexConfig.Field(
        dtype=float,
        doc="Maximum DN value to use to estimate linear term.",
        default=20000.0,
    )
    minLinearAdu = pexConfig.Field(
        dtype=float,
        doc="Minimum DN value to use to estimate linear term.",
        default=2000.0,
    )
    nSigmaClipLinear = pexConfig.Field(
        dtype=float,
        doc="Maximum deviation from linear solution for Poissonian noise.",
        default=5.0,
    )
Ejemplo n.º 23
0
class StackBrightStarsConfig(pexConfig.Config):
    """Configuration parameters for StackBrightStarsTask.
    """
    subregion_size = pexConfig.ListField(
        dtype=int,
        doc="Size, in pixels, of the subregions over which the stacking will be "
        "iteratively performed.",
        default=(100, 100))
    stacking_statistic = pexConfig.ChoiceField(
        dtype=str,
        doc="Type of statistic to use for stacking.",
        default="MEANCLIP",
        allowed={
            "MEAN": "mean",
            "MEDIAN": "median",
            "MEANCLIP": "clipped mean",
        })
    num_sigma_clip = pexConfig.Field(
        dtype=float,
        doc=
        "Sigma for outlier rejection; ignored if stacking_statistic != 'MEANCLIP'.",
        default=4)
    num_iter = pexConfig.Field(
        dtype=int,
        doc=
        "Number of iterations of outlier rejection; ignored if stackingStatistic != 'MEANCLIP'.",
        default=3)
    bad_mask_planes = pexConfig.ListField(
        dtype=str,
        doc=
        "Mask planes that, if set, lead to associated pixels not being included in the stacking of the "
        "bright star stamps.",
        default=('BAD', 'CR', 'CROSSTALK', 'EDGE', 'NO_DATA', 'SAT', 'SUSPECT',
                 'UNMASKEDNAN'))
    do_mag_cut = pexConfig.Field(dtype=bool,
                                 doc="Apply magnitude cut before stacking?",
                                 default=False)
    mag_limit = pexConfig.Field(
        dtype=float,
        doc=
        "Magnitude limit, in Gaia G; all stars brighter than this value will be stacked",
        default=18)
Ejemplo n.º 24
0
class SpatialDecorrelateALKernelMapReduceConfig(ImageMapReduceConfig):
    """Configuration parameters for the ImageMapReduceTask to direct it to use
       SpatialDecorrelateALKernelMapperSubtask as its mapperSubtask for A&L decorrelation.
    """
    mapperSubtask = pexConfig.ConfigurableField(
        doc='A&L decorrelation subtask to run on each sub-image',
        target=SpatialDecorrelateALKernelMapperSubtask)

    reduceOperation = pexConfig.ChoiceField(
        dtype=str,
        doc="""Operation to use for reducing subimages into new image.""",
        default="coaddPsf",
        allowed={
            "none":
            """simply return a list of values and don't re-map results into
                       a new image (noop operation)""",
            "coaddPsf":
            """Instead of constructing an Exposure, take a list of returned
                       PSFs and use CoaddPsf to construct a single PSF that covers the
                       entire input exposure""",
        })
Ejemplo n.º 25
0
class SourceDetectionConfig(pexConfig.Config):
    """!Configuration parameters for the SourceDetectionTask
    """
    minPixels = pexConfig.RangeField(
        doc=
        "detected sources with fewer than the specified number of pixels will be ignored",
        dtype=int,
        optional=False,
        default=1,
        min=0,
    )
    isotropicGrow = pexConfig.Field(
        doc="Pixels should be grown as isotropically as possible (slower)",
        dtype=bool,
        optional=False,
        default=False,
    )
    nSigmaToGrow = pexConfig.Field(
        doc="Grow detections by nSigmaToGrow * sigma; if 0 then do not grow",
        dtype=float,
        default=2.4,  # 2.4 pixels/sigma is roughly one pixel/FWHM
    )
    returnOriginalFootprints = pexConfig.Field(
        doc=
        "Grow detections to set the image mask bits, but return the original (not-grown) footprints",
        dtype=bool,
        optional=False,
        default=False,
    )
    thresholdValue = pexConfig.RangeField(
        doc="Threshold for footprints",
        dtype=float,
        optional=False,
        default=5.0,
        min=0.0,
    )
    includeThresholdMultiplier = pexConfig.RangeField(
        doc="Include threshold relative to thresholdValue",
        dtype=float,
        default=1.0,
        min=0.0,
    )
    thresholdType = pexConfig.ChoiceField(
        doc="specifies the desired flavor of Threshold",
        dtype=str,
        optional=False,
        default="stdev",
        allowed={
            "variance": "threshold applied to image variance",
            "stdev": "threshold applied to image std deviation",
            "value": "threshold applied to image value",
            "pixel_stdev": "threshold applied to per-pixel std deviation",
        },
    )
    thresholdPolarity = pexConfig.ChoiceField(
        doc=
        "specifies whether to detect positive, or negative sources, or both",
        dtype=str,
        optional=False,
        default="positive",
        allowed={
            "positive": "detect only positive sources",
            "negative": "detect only negative sources",
            "both": "detect both positive and negative sources",
        },
    )
    adjustBackground = pexConfig.Field(
        dtype=float,
        doc="Fiddle factor to add to the background; debugging only",
        default=0.0,
    )
    reEstimateBackground = pexConfig.Field(
        dtype=bool,
        doc="Estimate the background again after final source detection?",
        default=True,
        optional=False,
    )
    background = pexConfig.ConfigurableField(
        doc="Background re-estimation; ignored if reEstimateBackground false",
        target=SubtractBackgroundTask,
    )
    tempLocalBackground = pexConfig.ConfigurableField(
        doc=
        ("A seperate background estimation and removal before footprint and peak detection. "
         "It is added back into the image after detection."),
        target=SubtractBackgroundTask,
    )
    doTempLocalBackground = pexConfig.Field(
        dtype=bool,
        doc=
        "Do temporary interpolated background subtraction before footprint detection?",
        default=False,
    )

    def setDefaults(self):
        self.tempLocalBackground.binSize = 64
        self.tempLocalBackground.algorithm = "AKIMA_SPLINE"
        self.tempLocalBackground.useApprox = False
Ejemplo n.º 26
0
class SubtractBackgroundConfig(pexConfig.Config):
    """!Config for SubtractBackgroundTask

    @note Many of these fields match fields in lsst.afw.math.BackgroundControl,
    the control class for lsst.afw.math.makeBackground
    """
    statisticsProperty = pexConfig.ChoiceField(
        doc="type of statistic to use for grid points",
        dtype=str,
        default="MEANCLIP",
        allowed={
            "MEANCLIP": "clipped mean",
            "MEAN": "unclipped mean",
            "MEDIAN": "median",
        })
    undersampleStyle = pexConfig.ChoiceField(
        doc=
        "behaviour if there are too few points in grid for requested interpolation style",
        dtype=str,
        default="REDUCE_INTERP_ORDER",
        allowed={
            "THROW_EXCEPTION":
            "throw an exception if there are too few points",
            "REDUCE_INTERP_ORDER":
            "use an interpolation style with a lower order.",
            "INCREASE_NXNYSAMPLE":
            "Increase the number of samples used to make the interpolation grid.",
        },
    )
    binSize = pexConfig.RangeField(
        doc=
        "how large a region of the sky should be used for each background point",
        dtype=int,
        default=128,
        min=1,
    )
    binSizeX = pexConfig.RangeField(
        doc=
        ("Sky region size to be used for each background point in X direction. "
         "If 0, the binSize config is used."),
        dtype=int,
        default=0,
        min=0,
    )
    binSizeY = pexConfig.RangeField(
        doc=
        ("Sky region size to be used for each background point in Y direction. "
         "If 0, the binSize config is used."),
        dtype=int,
        default=0,
        min=0,
    )
    algorithm = pexConfig.ChoiceField(
        doc=
        "how to interpolate the background values. This maps to an enum; see afw::math::Background",
        dtype=str,
        default="AKIMA_SPLINE",
        optional=True,
        allowed={
            "CONSTANT": "Use a single constant value",
            "LINEAR": "Use linear interpolation",
            "NATURAL_SPLINE":
            "cubic spline with zero second derivative at endpoints",
            "AKIMA_SPLINE":
            "higher-level nonlinear spline that is more robust to outliers",
            "NONE": "No background estimation is to be attempted",
        },
    )
    ignoredPixelMask = pexConfig.ListField(
        doc="Names of mask planes to ignore while estimating the background",
        dtype=str,
        default=[
            "BAD",
            "EDGE",
            "DETECTED",
            "DETECTED_NEGATIVE",
            "NO_DATA",
        ],
        itemCheck=lambda x: x in afwImage.Mask().getMaskPlaneDict().keys(),
    )
    isNanSafe = pexConfig.Field(
        doc="Ignore NaNs when estimating the background",
        dtype=bool,
        default=False,
    )

    useApprox = pexConfig.Field(
        doc="Use Approximate (Chebyshev) to model background.",
        dtype=bool,
        default=True,
    )
    approxOrderX = pexConfig.Field(
        doc=
        "Approximation order in X for background Chebyshev (valid only with useApprox=True)",
        dtype=int,
        default=6,
    )
    # Note: Currently X- and Y-orders must be equal due to a limitation in math::Chebyshev1Function2
    # The following is being added so that the weighting attribute can also be configurable for the
    # call to afwMath.ApproximateControl
    approxOrderY = pexConfig.Field(
        doc=
        "Approximation order in Y for background Chebyshev (valid only with useApprox=True)",
        dtype=int,
        default=-1,
    )
    weighting = pexConfig.Field(
        doc=
        "Use inverse variance weighting in calculation (valid only with useApprox=True)",
        dtype=bool,
        default=True,
    )
Ejemplo n.º 27
0
class SourceDeblendConfig(pexConfig.Config):

    edgeHandling = pexConfig.ChoiceField(
        doc=
        'What to do when a peak to be deblended is close to the edge of the image',
        dtype=str,
        default='ramp',
        allowed={
            'clip':
            'Clip the template at the edge AND the mirror of the edge.',
            'ramp': 'Ramp down flux at the image edge by the PSF',
            'noclip': 'Ignore the edge when building the symmetric template.',
        })

    strayFluxToPointSources = pexConfig.ChoiceField(
        doc='When the deblender should attribute stray flux to point sources',
        dtype=str,
        default='necessary',
        allowed={
            'necessary':
            'When there is not an extended object in the footprint',
            'always':
            'Always',
            'never':
            ('Never; stray flux will not be attributed to any deblended child '
             'if the deblender thinks all peaks look like point sources'),
        })

    assignStrayFlux = pexConfig.Field(
        dtype=bool,
        default=True,
        doc='Assign stray flux (not claimed by any child in the deblender) '
        'to deblend children.')

    strayFluxRule = pexConfig.ChoiceField(
        doc='How to split flux among peaks',
        dtype=str,
        default='trim',
        allowed={
            'r-to-peak':
            '~ 1/(1+R^2) to the peak',
            'r-to-footprint':
            ('~ 1/(1+R^2) to the closest pixel in the footprint.  '
             'CAUTION: this can be computationally expensive on large footprints!'
             ),
            'nearest-footprint':
            ('Assign 100% to the nearest footprint (using L-1 norm aka '
             'Manhattan distance)'),
            'trim':
            ('Shrink the parent footprint to pixels that are not assigned to children'
             )
        })

    clipStrayFluxFraction = pexConfig.Field(
        dtype=float,
        default=0.001,
        doc=('When splitting stray flux, clip fractions below '
             'this value to zero.'))
    psfChisq1 = pexConfig.Field(
        dtype=float,
        default=1.5,
        optional=False,
        doc=('Chi-squared per DOF cut for deciding a source is '
             'a PSF during deblending (un-shifted PSF model)'))
    psfChisq2 = pexConfig.Field(
        dtype=float,
        default=1.5,
        optional=False,
        doc=('Chi-squared per DOF cut for deciding a source is '
             'PSF during deblending (shifted PSF model)'))
    psfChisq2b = pexConfig.Field(
        dtype=float,
        default=1.5,
        optional=False,
        doc=('Chi-squared per DOF cut for deciding a source is '
             'a PSF during deblending (shifted PSF model #2)'))
    maxNumberOfPeaks = pexConfig.Field(
        dtype=int,
        default=0,
        doc=("Only deblend the brightest maxNumberOfPeaks peaks in the parent"
             " (<= 0: unlimited)"))
    maxFootprintArea = pexConfig.Field(
        dtype=int,
        default=1000000,
        doc=("Maximum area for footprints before they are ignored as large; "
             "non-positive means no threshold applied"))
    maxFootprintSize = pexConfig.Field(
        dtype=int,
        default=0,
        doc=("Maximum linear dimension for footprints before they are ignored "
             "as large; non-positive means no threshold applied"))
    minFootprintAxisRatio = pexConfig.Field(
        dtype=float,
        default=0.0,
        doc=("Minimum axis ratio for footprints before they are ignored "
             "as large; non-positive means no threshold applied"))
    notDeblendedMask = pexConfig.Field(
        dtype=str,
        default="NOT_DEBLENDED",
        optional=True,
        doc="Mask name for footprints not deblended, or None")

    tinyFootprintSize = pexConfig.RangeField(
        dtype=int,
        default=2,
        min=2,
        inclusiveMin=True,
        doc=('Footprints smaller in width or height than this value '
             'will be ignored; minimum of 2 due to PSF gradient '
             'calculation.'))

    propagateAllPeaks = pexConfig.Field(
        dtype=bool,
        default=False,
        doc=('Guarantee that all peaks produce a child source.'))
    catchFailures = pexConfig.Field(
        dtype=bool,
        default=False,
        doc=(
            "If True, catch exceptions thrown by the deblender, log them, "
            "and set a flag on the parent, instead of letting them propagate up"
        ))
    maskPlanes = pexConfig.ListField(
        dtype=str,
        default=["SAT", "INTRP", "NO_DATA"],
        doc="Mask planes to ignore when performing statistics")
    maskLimits = pexConfig.DictField(
        keytype=str,
        itemtype=float,
        default={},
        doc=
        ("Mask planes with the corresponding limit on the fraction of masked pixels. "
         "Sources violating this limit will not be deblended."),
    )
    weightTemplates = pexConfig.Field(
        dtype=bool,
        default=False,
        doc=(
            "If true, a least-squares fit of the templates will be done to the "
            "full image. The templates will be re-weighted based on this fit."
        ))
    removeDegenerateTemplates = pexConfig.Field(
        dtype=bool, default=False, doc=("Try to remove similar templates?"))
    maxTempDotProd = pexConfig.Field(
        dtype=float,
        default=0.5,
        doc=
        ("If the dot product between two templates is larger than this value, we consider them to be "
         "describing the same object (i.e. they are degenerate).  If one of the objects has been "
         "labeled as a PSF it will be removed, otherwise the template with the lowest value will "
         "be removed."))
    medianSmoothTemplate = pexConfig.Field(
        dtype=bool,
        default=True,
        doc="Apply a smoothing filter to all of the template images")
Ejemplo n.º 28
0
class MatchBackgroundsConfig(pexConfig.Config):

    usePolynomial = pexConfig.Field(
        dtype=bool,
        doc="Fit background difference with Chebychev polynomial interpolation "
        "(using afw.math.Approximate)? If False, fit with spline interpolation using afw.math.Background",
        default=False)
    order = pexConfig.Field(
        dtype=int,
        doc=
        "Order of Chebyshev polynomial background model. Ignored if usePolynomial False",
        default=8)
    badMaskPlanes = pexConfig.ListField(
        doc="Names of mask planes to ignore while estimating the background",
        dtype=str,
        default=[
            "NO_DATA", "DETECTED", "DETECTED_NEGATIVE", "SAT", "BAD", "INTRP",
            "CR"
        ],
        itemCheck=lambda x: x in afwImage.Mask().getMaskPlaneDict(),
    )
    gridStatistic = pexConfig.ChoiceField(
        dtype=str,
        doc="Type of statistic to estimate pixel value for the grid points",
        default="MEAN",
        allowed={
            "MEAN": "mean",
            "MEDIAN": "median",
            "MEANCLIP": "clipped mean"
        })
    undersampleStyle = pexConfig.ChoiceField(
        doc=
        "Behaviour if there are too few points in grid for requested interpolation style. "
        "Note: INCREASE_NXNYSAMPLE only allowed for usePolynomial=True.",
        dtype=str,
        default="REDUCE_INTERP_ORDER",
        allowed={
            "THROW_EXCEPTION":
            "throw an exception if there are too few points",
            "REDUCE_INTERP_ORDER":
            "use an interpolation style with a lower order.",
            "INCREASE_NXNYSAMPLE":
            "Increase the number of samples used to make the interpolation grid.",
        })
    binSize = pexConfig.Field(
        doc=
        "Bin size for gridding the difference image and fitting a spatial model",
        dtype=int,
        default=256)
    interpStyle = pexConfig.ChoiceField(
        dtype=str,
        doc=
        "Algorithm to interpolate the background values; ignored if usePolynomial is True"
        "Maps to an enum; see afw.math.Background",
        default="AKIMA_SPLINE",
        allowed={
            "CONSTANT": "Use a single constant value",
            "LINEAR": "Use linear interpolation",
            "NATURAL_SPLINE":
            "cubic spline with zero second derivative at endpoints",
            "AKIMA_SPLINE":
            "higher-level nonlinear spline that is more robust to outliers",
            "NONE": "No background estimation is to be attempted",
        })
    numSigmaClip = pexConfig.Field(
        dtype=int,
        doc=
        "Sigma for outlier rejection; ignored if gridStatistic != 'MEANCLIP'.",
        default=3)
    numIter = pexConfig.Field(
        dtype=int,
        doc=
        "Number of iterations of outlier rejection; ignored if gridStatistic != 'MEANCLIP'.",
        default=2)
    bestRefWeightCoverage = pexConfig.RangeField(
        dtype=float,
        doc=
        "Weight given to coverage (number of pixels that overlap with patch), "
        "when calculating best reference exposure. Higher weight prefers exposures with high coverage."
        "Ignored when reference visit is supplied",
        default=0.4,
        min=0.,
        max=1.)
    bestRefWeightVariance = pexConfig.RangeField(
        dtype=float,
        doc=
        "Weight given to image variance when calculating best reference exposure. "
        "Higher weight prefers exposures with low image variance. Ignored when reference visit is supplied",
        default=0.4,
        min=0.,
        max=1.)
    bestRefWeightLevel = pexConfig.RangeField(
        dtype=float,
        doc=
        "Weight given to mean background level when calculating best reference exposure. "
        "Higher weight prefers exposures with low mean background level. "
        "Ignored when reference visit is supplied.",
        default=0.2,
        min=0.,
        max=1.)
    approxWeighting = pexConfig.Field(
        dtype=bool,
        doc=
        ("Use inverse-variance weighting when approximating background offset model? "
         + "This will fail when the background offset is constant " +
         "(this is usually only the case in testing with artificial images)." +
         "(usePolynomial=True)"),
        default=True,
    )
    gridStdevEpsilon = pexConfig.RangeField(
        dtype=float,
        doc=
        "Tolerance on almost zero standard deviation in a background-offset grid bin. "
        "If all bins have a standard deviation below this value, the background offset model "
        "is approximated without inverse-variance weighting. (usePolynomial=True)",
        default=1e-8,
        min=0.)
Ejemplo n.º 29
0
class SubaruIsrConfig(IsrTask.ConfigClass):
    qa = pexConfig.ConfigField(doc="QA-related config options", dtype=QaConfig)
    doSaturation = pexConfig.Field(doc="Mask saturated pixels?",
                                   dtype=bool,
                                   default=True)
    doSuspect = pexConfig.Field(doc="Mask suspect pixels?",
                                dtype=bool,
                                default=True)
    doWidenSaturationTrails = pexConfig.Field(
        doc="Widen bleed trails based on their width?",
        dtype=bool,
        default=True)
    doOverscan = pexConfig.Field(doc="Do overscan subtraction?",
                                 dtype=bool,
                                 default=True)
    doVariance = pexConfig.Field(doc="Calculate variance?",
                                 dtype=bool,
                                 default=True)
    doDefect = pexConfig.Field(doc="Mask defect pixels?",
                               dtype=bool,
                               default=True)
    doGuider = pexConfig.Field(
        dtype=bool,
        doc="Trim guider shadow",
        default=True,
    )
    crosstalk = pexConfig.ConfigurableField(target=NullCrosstalkTask,
                                            doc="Crosstalk correction")
    doCrosstalk = pexConfig.Field(
        dtype=bool,
        doc="Correct for crosstalk",
        default=True,
    )
    doStrayLight = pexConfig.Field(
        dtype=bool,
        doc="Subtract stray light in the y-band (due to encoder LEDs)?",
        default=True,
    )
    strayLight = pexConfig.ConfigurableField(
        target=StrayLightTask, doc="y-band stray light correction")
    doApplyGains = pexConfig.Field(
        dtype=bool,
        doc="""Correct the amplifiers for their gains

N.b. this is intended to be used *instead* of doFlat; it's useful if you're measuring system throughput
""",
        default=False,
    )
    normalizeGains = pexConfig.Field(
        dtype=bool,
        doc="""Normalize all the amplifiers in each CCD to have the same gain

This does not measure the gains, it simply forces the median of each amplifier to be equal
after applying the nominal gain
""",
        default=False,
    )
    removePcCards = Field(dtype=bool,
                          doc='Remove any PC cards in the header',
                          default=True)
    fwhmForBadColumnInterpolation = pexConfig.Field(
        dtype=float,
        doc="FWHM of PSF used when interpolating over bad columns (arcsec)",
        default=1.0,
    )
    doSetBadRegions = pexConfig.Field(
        dtype=bool,
        doc=
        "Should we set the level of all BAD patches of the chip to the chip's average value?",
        default=True,
    )
    badStatistic = pexConfig.ChoiceField(
        dtype=str,
        doc="How to estimate the average value for BAD regions.",
        default='MEANCLIP',
        allowed={
            "MEANCLIP": "Correct using the (clipped) mean of good data",
            "MEDIAN": "Correct using the median of the good data",
        },
    )
    doTweakFlat = pexConfig.Field(
        dtype=bool,
        doc="Tweak flats to match observed amplifier ratios?",
        default=False)
    overscanMaxDev = pexConfig.Field(
        dtype=float,
        doc="Maximum deviation from the median for overscan",
        default=1000.0,
        check=lambda x: x > 0)
    vignette = pexConfig.ConfigField(
        dtype=VignetteConfig,
        doc="Vignetting parameters in focal plane coordinates")
    numPolygonPoints = pexConfig.Field(
        dtype=int,
        doc="Number of points to define the Vignette polygon",
        default=100,
    )
    doWriteVignettePolygon = pexConfig.Field(
        dtype=bool,
        doc="Persist Polygon used to define vignetted region?",
        default=True,
    )
    fluxMag0T1 = pexConfig.DictField(
        keytype=str,
        itemtype=float,
        doc=
        "The approximate flux of a zero-magnitude object in a one-second exposure, per filter",
        # These are the HSC sensitivities from:
        # http://www.subarutelescope.org/Observing/Instruments/HSC/sensitivity.html
        default=dict((f, pow(10.0, 0.4 * m)) for f, m in (
            ("g", 29.0),
            ("r", 29.0),
            ("i", 28.6),
            ("z", 27.7),
            ("y", 27.4),
            ("N515", 25.8),
            ("N816", 25.5),
            ("N921", 25.7),
        )))
    defaultFluxMag0T1 = pexConfig.Field(
        dtype=float,
        default=pow(10.0, 0.4 * 28.0),
        doc="Default value for fluxMag0T1 (for an unrecognised filter)")
    thumbnailBinning = Field(dtype=int,
                             default=4,
                             doc="Binning factor for thumbnail")
    thumbnailStdev = Field(
        dtype=float,
        default=3.0,
        doc="Number of stdev below the background to set thumbnail minimum")
    thumbnailRange = Field(dtype=float,
                           default=5.0,
                           doc="Range for thumbnail mapping")
    thumbnailQ = Field(dtype=float,
                       default=20.0,
                       doc="Softening parameter for thumbnail mapping")
    thumbnailSatBorder = Field(
        dtype=int,
        default=2,
        doc="Border around saturated pixels for thumbnail")

    def validate(self):
        super(SubaruIsrConfig, self).validate()
        if self.doFlat and self.doApplyGains:
            raise ValueError(
                "You may not specify both self.doFlat and self.doApplyGains")
class PsfexPsfDeterminerConfig(measAlg.BasePsfDeterminerConfig):
    __nEigenComponents = pexConfig.Field(
        doc="number of eigen components for PSF kernel creation",
        dtype=int,
        default=4,
    )
    spatialOrder = pexConfig.Field(
        doc="specify spatial order for PSF kernel creation",
        dtype=int,
        default=2,
        check=lambda x: x >= 0,
    )
    sizeCellX = pexConfig.Field(
        doc="size of cell used to determine PSF (pixels, column direction)",
        dtype=int,
        default=256,
        #        minValue = 10,
        check=lambda x: x >= 10,
    )
    sizeCellY = pexConfig.Field(
        doc="size of cell used to determine PSF (pixels, row direction)",
        dtype=int,
        default=sizeCellX.default,
        #        minValue = 10,
        check=lambda x: x >= 10,
    )
    __nStarPerCell = pexConfig.Field(
        doc="number of stars per psf cell for PSF kernel creation",
        dtype=int,
        default=3,
    )
    samplingSize = pexConfig.Field(
        doc="Resolution of the internal PSF model relative to the pixel size; "
        "e.g. 0.5 is equal to 2x oversampling",
        dtype=float,
        default=1,
    )
    badMaskBits = pexConfig.ListField(
        doc="List of mask bits which cause a source to be rejected as bad "
        "N.b. INTRP is used specially in PsfCandidateSet; it means \"Contaminated by neighbour\"",
        dtype=str,
        default=["INTRP", "SAT"],
    )
    psfexBasis = pexConfig.ChoiceField(
        doc="BASIS value given to psfex.  PIXEL_AUTO will use the requested samplingSize only if "
        "the FWHM < 3 pixels.  Otherwise, it will use samplingSize=1.  PIXEL will always use the "
        "requested samplingSize",
        dtype=str,
        allowed={
            "PIXEL": "Always use requested samplingSize",
            "PIXEL_AUTO": "Only use requested samplingSize when FWHM < 3",
        },
        default='PIXEL',
        optional=False,
    )
    __borderWidth = pexConfig.Field(
        doc="Number of pixels to ignore around the edge of PSF candidate postage stamps",
        dtype=int,
        default=0,
    )
    __nStarPerCellSpatialFit = pexConfig.Field(
        doc="number of stars per psf Cell for spatial fitting",
        dtype=int,
        default=5,
    )
    __constantWeight = pexConfig.Field(
        doc="Should each PSF candidate be given the same weight, independent of magnitude?",
        dtype=bool,
        default=True,
    )
    __nIterForPsf = pexConfig.Field(
        doc="number of iterations of PSF candidate star list",
        dtype=int,
        default=3,
    )
    tolerance = pexConfig.Field(
        doc="tolerance of spatial fitting",
        dtype=float,
        default=1e-2,
    )
    lam = pexConfig.Field(
        doc="floor for variance is lam*data",
        dtype=float,
        default=0.05,
    )
    reducedChi2ForPsfCandidates = pexConfig.Field(
        doc="for psf candidate evaluation",
        dtype=float,
        default=2.0,
    )
    spatialReject = pexConfig.Field(
        doc="Rejection threshold (stdev) for candidates based on spatial fit",
        dtype=float,
        default=3.0,
    )
    recentroid = pexConfig.Field(
        doc="Should PSFEX be permitted to recentroid PSF candidates?",
        dtype=bool,
        default=False,
    )

    def setDefaults(self):
        self.kernelSize = 41