Ejemplo n.º 1
0
class Config1(pexConfig.Config):
    d1 = pexConfig.DictField("d1",
                             keytype=str,
                             itemtype=int,
                             default={"hi": 4},
                             itemCheck=lambda x: x > 0)
    d2 = pexConfig.DictField("d2", keytype=str, itemtype=str, default=None)
    d3 = pexConfig.DictField("d3",
                             keytype=float,
                             itemtype=float,
                             optional=True,
                             itemCheck=lambda x: x > 0)
    d4 = pexConfig.DictField("d4", keytype=str, itemtype=None, default={})
Ejemplo n.º 2
0
class SitesConfig(pexConfig.Config):
    inputFile = pexConfig.Field("input", str)
    outputFile = pexConfig.Field("output", str)
    keywords = pexConfig.DictField("key value pairs",
                                   keytype=str,
                                   itemtype=str,
                                   default=dict())
Ejemplo n.º 3
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.º 4
0
class BaseMakeQaTractTablesTaskConfig(pipeBase.PipelineTaskConfig,
                                      pipelineConnections=BaseMakeQaTractTablesTaskConnections):
    # TODO: remove the filterMap config song and dance once DM-28475 lands
    filterMap = pexConfig.DictField(
        keytype=str, itemtype=str,
        default={},
        doc=("Dictionary mapping canonical band to the camera's physical filter.  This is currently "
             "required for {coaddName}Coadd_obj that are indexed on the latter as the dataId supplied "
             "will only contain the former (this will likely become unnecessary once the postprocess "
             "scripts are updated to index on band).")
    )
    baseColStrList = pexConfig.ListField(
        dtype=str,
        default=["coord", "tract", "patch", "visit", "ccd", "base_PixelFlags", "base_GaussianFlux",
                 "base_PsfFlux", "base_CircularApertureFlux_9_0_instFlux", "base_CircularApertureFlux_12_0",
                 "base_CircularApertureFlux_25_0", "ext_photometryKron_KronFlux", "modelfit_CModel",
                 "base_Sdss", "slot_Centroid", "slot_Shape", "ext_shapeHSM_HsmSourceMoments_",
                 "ext_shapeHSM_HsmPsfMoments_", "ext_shapeHSM_HsmShapeRegauss_", "base_Footprint",
                 "base_FPPosition", "base_ClassificationExtendedness", "parent", "detect", "deblend_nChild",
                 "base_Blendedness_abs", "base_Blendedness_flag", "base_InputCount",
                 "merge_peak_sky", "merge_measurement", "calib", "sky_source"],
        doc=("List of \"prefix\" strings of column names to load from deepCoadd_obj parquet table. "
             "All columns that start with one of these strings will be loaded UNLESS the full column "
             "name contains one of the strings listed in the notInColumnStrList config.")
    )
    notInColStrList = pexConfig.ListField(
        dtype=str,
        default=["flag_bad", "flag_no", "missingDetector_flag", "_region_", "Truncated", "_radius",
                 "_bad_", "initial", "_exp_", "_dev_", "fracDev", "objective", "SdssCentroid_flag_",
                 "SdssShape_flag_u", "SdssShape_flag_m", "_Cov", "_child_", "_parent_"],
        doc=("List of substrings to select against when creating list of columns to load from the "
             "deepCoadd_obj parquet table.")
    )
Ejemplo n.º 5
0
class TransformObjectCatalogConfig(TransformCatalogBaseConfig):
    coaddName = pexConfig.Field(
        dtype=str,
        default="deep",
        doc="Name of coadd"
    )
    filterMap = pexConfig.DictField(
        keytype=str,
        itemtype=str,
        default={},
        doc=("Dictionary mapping full filter name to short one for column name munging."
             "These filters determine the output columns no matter what filters the "
             "input data actually contain.")
    )
    camelCase = pexConfig.Field(
        dtype=bool,
        default=True,
        doc=("Write per-filter columns names with camelCase, else underscore "
             "For example: gPsfFlux instead of g_PsfFlux.")
    )
    multilevelOutput = pexConfig.Field(
        dtype=bool,
        default=False,
        doc=("Whether results dataframe should have a multilevel column index (True) or be flat "
             "and name-munged (False).")
    )
Ejemplo n.º 6
0
class ScriptTemplateConfig(pexConfig.Config):
    # input file
    inputFile = pexConfig.Field("input file", str)
    # key value pars to substitute for the template
    keywords = pexConfig.DictField("key value pairs", keytype=str, itemtype=str, default=dict())
    # output file for results of template substitution
    outputFile = pexConfig.Field("output file", str)
Ejemplo n.º 7
0
class MapDiaSourceConfig(pexConfig.Config):
    """Config for the DiaSourceMapperTask
    """
    copyColumns = pexConfig.DictField(
        keytype=str,
        itemtype=str,
        doc="Mapping of input SciencePipelines columns to output DPDD "
        "columns.",
        default={
            "id": "id",
            "parent": "parent",
            "coord_ra": "coord_ra",
            "coord_dec": "coord_dec",
            "slot_Centroid_x": "x",
            "slot_Centroid_xErr": "xErr",
            "slot_Centroid_y": "y",
            "slot_Centroid_yErr": "yErr",
            "slot_ApFlux_instFlux": "apFlux",
            "slot_ApFlux_instFluxErr": "apFluxErr",
            "slot_PsfFlux_instFlux": "psFlux",
            "slot_PsfFlux_instFluxErr": "psFluxErr",
            "ip_diffim_DipoleFit_orientation": "dipAngle",
            "ip_diffim_DipoleFit_chi2dof": "dipChi2",
            "ip_diffim_forced_PsfFlux_instFlux": "totFlux",
            "ip_diffim_forced_PsfFlux_instFluxErr": "totFluxErr",
            "ip_diffim_DipoleFit_flag_classification": "isDipole",
            "slot_Shape_xx": "ixx",
            "slot_Shape_xxErr": "ixxErr",
            "slot_Shape_yy": "iyy",
            "slot_Shape_yyErr": "iyyErr",
            "slot_Shape_xy": "ixy",
            "slot_Shape_xyErr": "ixyErr",
            "slot_PsfShape_xx": "ixxPSF",
            "slot_PsfShape_yy": "iyyPSF",
            "slot_PsfShape_xy": "ixyPSF"
        })
    calibrateColumns = pexConfig.ListField(
        dtype=str,
        doc="Flux columns in the input catalog to calibrate.",
        default=["slot_ApFlux", "slot_PsfFlux", "ip_diffim_forced_PsfFlux"])
    flagMap = pexConfig.Field(
        dtype=str,
        doc="Yaml file specifying SciencePipelines flag fields to bit packs.",
        default=os.path.join(getPackageDir("ap_association"), "data",
                             "association-flag-map.yaml"),
    )
    dipFluxPrefix = pexConfig.Field(
        dtype=str,
        doc="Prefix of the Dipole measurement column containing negative and "
        "positive flux lobes.",
        default="ip_diffim_DipoleFit",
    )
    dipSepColumn = pexConfig.Field(
        dtype=str,
        doc="Column of the separation of the negative and positive poles of "
        "the dipole.",
        default="ip_diffim_DipoleFit_separation")
class TemplateConfig(pexConfig.Config):
    # key/value pairs
    keywords = pexConfig.DictField("key value pairs",
                                   keytype=str,
                                   itemtype=str,
                                   default=dict())
    # input file
    inputFile = pexConfig.Field("name of template to fill in",
                                str,
                                default=None)
    # output file
    outputFile = pexConfig.Field("name of file to write", str, default=None)
Ejemplo n.º 9
0
class CpVerifyExpMergeConfig(pipeBase.PipelineTaskConfig,
                             pipelineConnections=CpVerifyExpMergeConnections):
    """Configuration parameters for exposure stats merging.
    """
    exposureStatKeywords = pexConfig.DictField(
        keytype=str,
        itemtype=str,
        doc=
        "Dictionary of statistics to run on the set of detector values. The key should be the test "
        "name to record in the output, and the value should be the `lsst.afw.math` statistic name string.",
        default={},
    )
Ejemplo n.º 10
0
class MapApDataConfig(pexConfig.Config):
    """Configuration for the generic MapApDataTask class.
    """
    copyColumns = pexConfig.DictField(
        keytype=str,
        itemtype=str,
        doc="Mapping of input SciencePipelines columns to output DPDD "
        "columns.",
        default={
            "id": "id",
            "parent": "parent",
            "coord_ra": "coord_ra",
            "coord_dec": "coord_dec"
        })
Ejemplo n.º 11
0
class ReadFitsCatalogConfig(pexConfig.Config):
    hdu = pexConfig.Field(
        dtype=int,
        default=1,
        doc=
        "HDU containing the desired binary table, 0-based but a binary table never occurs in HDU 0",
    )
    column_map = pexConfig.DictField(
        doc=
        "Mapping of input column name: output column name; each specified column must exist, "
        "but additional columns in the input data are written using their original name. ",
        keytype=str,
        itemtype=str,
        default={},
    )
Ejemplo n.º 12
0
class FgcmMakeLutConfig(pipeBase.PipelineTaskConfig,
                        pipelineConnections=FgcmMakeLutConnections):
    """Config for FgcmMakeLutTask"""
    physicalFilters = pexConfig.ListField(
        doc="List of physicalFilter labels to generate look-up table.",
        dtype=str,
        default=[],
    )
    stdPhysicalFilterOverrideMap = pexConfig.DictField(
        doc=
        ("Override mapping from physical filter labels to 'standard' physical "
         "filter labels. The 'standard' physical filter defines the transmission "
         "curve that the FGCM standard bandpass will be based on. "
         "Any filter not listed here will be mapped to "
         "itself (e.g. g->g or HSC-G->HSC-G).  Use this override for cross-"
         "filter calibration such as HSC-R->HSC-R2 and HSC-I->HSC-I2."),
        keytype=str,
        itemtype=str,
        default={},
    )
    atmosphereTableName = pexConfig.Field(
        doc="FGCM name or filename of precomputed atmospheres",
        dtype=str,
        default=None,
        optional=True,
    )
    parameters = pexConfig.ConfigField(
        doc="Atmosphere parameters (required if no atmosphereTableName)",
        dtype=FgcmMakeLutParametersConfig,
        default=None,
        check=None)

    def validate(self):
        """
        Validate the config parameters.

        This method behaves differently from the parent validate in the case
        that atmosphereTableName is set.  In this case, the config values
        for standard values, step sizes, and ranges are loaded
        directly from the specified atmosphereTableName.
        """
        # check that filterNames and stdFilterNames are okay
        self._fields['physicalFilters'].validate(self)
        self._fields['stdPhysicalFilterOverrideMap'].validate(self)

        if self.atmosphereTableName is None:
            # Validate the parameters
            self._fields['parameters'].validate(self)
Ejemplo n.º 13
0
class MeasureExtendedPsfConfig(
        pipeBase.PipelineTaskConfig,
        pipelineConnections=MeasureExtendedPsfConnections):
    """Configuration parameters for MeasureExtendedPsfTask.
    """
    stack_bright_stars = pexConfig.ConfigurableField(
        target=StackBrightStarsTask,
        doc="Stack selected bright stars",
    )
    detectors_focal_plane_regions = pexConfig.DictField(
        keytype=int,
        itemtype=str,
        doc=
        "Mapping from detector IDs to focal plane region names. If empty, a constant "
        "extended PSF model is built from all selected bright stars.",
        default={})
Ejemplo n.º 14
0
class IngestCatalogConfig(pex_config.Config):
    """Configuration for :class:`~IngestCatalogTask`."""

    allow_replace = pex_config.Field(
        "Allow replacement of existing rows with the same unique IDs",
        bool,
        default=False)

    max_query_len = pex_config.Field(
        "Maximum length of a query string. None means use a non-standard, "
        "database-specific way to get the maximum.",
        int,
        optional=True,
        default=None)

    max_column_len = pex_config.RangeField(
        "Maximum length of a database column name or alias. Fields "
        "that map to longer column names will not be ingested.",
        int,
        default=64,
        min=1,
        max=64,
        inclusiveMin=True,
        inclusiveMax=True)

    id_field_name = pex_config.Field("Name of the unique ID field",
                                     str,
                                     optional=True,
                                     default="id")

    remap = pex_config.DictField(
        "A mapping from afw table field names to desired SQL column names. "
        "Column names containing special characters must be quoted.",
        keytype=str,
        itemtype=str,
        optional=True,
        default={})

    extra_columns = pex_config.Field(
        "Extra column definitions, comma-separated, to put into the "
        "CREATE TABLE statement (if the table is being created)",
        str,
        optional=True,
        default="")
Ejemplo n.º 15
0
class TransformObjectCatalogConfig(TransformCatalogBaseConfig):
    filterMap = pexConfig.DictField(
        keytype=str,
        itemtype=str,
        default={},
        doc="Dictionary mapping full filter name to short one for column name munging."
    )
    camelCase = pexConfig.Field(
        dtype=bool,
        default=True,
        doc=("Write per-filter columns names with camelCase, else underscore "
             "For example: gPsfFlux instead of g_PsfFlux.")
    )
    multilevelOutput = pexConfig.Field(
        dtype=bool,
        default=False,
        doc=("Whether results dataframe should have a multilevel column index (True) or be flat "
             "and name-munged (False).")
    )
Ejemplo n.º 16
0
class SkyPlotTaskConfig(pipeBase.PipelineTaskConfig,
                        pipelineConnections=SkyPlotTaskConnections):

    axisActions = ConfigurableActionStructField(
        doc=
        "The actions to use to calculate the values used on each axis. Used if <axis> in axisColNames "
        "is set to 'Functor'.",
        default={
            "xAction": CoordColumn,
            "yAction": CoordColumn,
            "zAction": SingleColumnAction
        },
    )

    axisLabels = pexConfig.DictField(
        doc=
        "Name of column in dataframe to plot, will be used as axis label: {'x':, 'y':, 'z':}",
        keytype=str,
        itemtype=str,
    )

    sourceSelectorActions = ConfigurableActionStructField(
        doc="What types of sources to use.",
        default={"sourceSelector": dataSelectors.StarIdentifier},
    )

    selectorActions = ConfigurableActionStructField(
        doc="Which selectors to use to narrow down the data for QA plotting.",
        default={"mainFlagSelector": dataSelectors.MainFlagSelector},
    )

    statisticSelectorActions = ConfigurableActionStructField(
        doc=
        "Selectors to use to decide which points to use for calculating statistics.",
        default={"statSelector": dataSelectors.LowSnSelector},
    )

    def setDefaults(self):
        super().setDefaults()
        self.axisActions.xAction.column = "coord_ra"
        self.axisActions.xAction.inRadians = False
        self.axisActions.yAction.column = "coord_dec"
        self.axisActions.yAction.inRadians = False
Ejemplo n.º 17
0
class LoadReferenceObjectsConfig(pexConfig.Config):
    pixelMargin = pexConfig.RangeField(
        doc="Padding to add to 4 all edges of the bounding box (pixels)",
        dtype=int,
        default=50,
        min=0,
    )
    defaultFilter = pexConfig.Field(
        doc = "Default reference catalog filter to use if filter not specified in exposure; " + \
            "if blank then filter must be specified in exposure",
        dtype = str,
        default = "",
    )
    filterMap = pexConfig.DictField(
        doc = "Mapping of camera filter name: reference catalog filter name; " + \
            "each reference filter must exist",
        keytype = str,
        itemtype = str,
        default = {},
    )
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 FgcmLoadReferenceCatalogConfig(pexConfig.Config):
    """Config for FgcmLoadReferenceCatalogTask"""

    refObjLoader = pexConfig.ConfigurableField(
        target=LoadIndexedReferenceObjectsTask,
        doc="Reference object loader for photometry",
        deprecated="refObjLoader is deprecated, and will be removed after v24.",
    )
    filterMap = pexConfig.DictField(
        doc="Mapping from physicalFilter label to reference filter name.",
        keytype=str,
        itemtype=str,
        default={},
    )
    applyColorTerms = pexConfig.Field(
        doc=("Apply photometric color terms to reference stars?"
             "Requires that colorterms be set to a ColorTermLibrary"),
        dtype=bool,
        default=True)
    colorterms = pexConfig.ConfigField(
        doc="Library of photometric reference catalog name to color term dict.",
        dtype=ColortermLibrary,
    )
    referenceSelector = pexConfig.ConfigurableField(
        target=ReferenceSourceSelectorTask,
        doc="Selection of reference sources",
    )

    def validate(self):
        super().validate()
        if not self.filterMap:
            msg = 'Must set filterMap'
            raise pexConfig.FieldValidationError(
                FgcmLoadReferenceCatalogConfig.filterMap, self, msg)
        if self.applyColorTerms and len(self.colorterms.data) == 0:
            msg = "applyColorTerms=True requires the `colorterms` field be set to a ColortermLibrary."
            raise pexConfig.FieldValidationError(
                FgcmLoadReferenceCatalogConfig.colorterms, self, msg)
Ejemplo n.º 20
0
class TransformObjectCatalogConfig(TransformCatalogBaseConfig):
    coaddName = pexConfig.Field(
        dtype=str,
        default="deep",
        doc="Name of coadd"
    )
    # TODO: remove in DM-27177
    filterMap = pexConfig.DictField(
        keytype=str,
        itemtype=str,
        default={},
        doc=("Dictionary mapping full filter name to short one for column name munging."
             "These filters determine the output columns no matter what filters the "
             "input data actually contain."),
        deprecated=("Coadds are now identified by the band, so this transform is unused."
                    "Will be removed after v22.")
    )
    outputBands = pexConfig.ListField(
        dtype=str,
        default=None,
        optional=True,
        doc=("These bands and only these bands will appear in the output,"
             " NaN-filled if the input does not include them."
             " If None, then use all bands found in the input.")
    )
    camelCase = pexConfig.Field(
        dtype=bool,
        default=True,
        doc=("Write per-band columns names with camelCase, else underscore "
             "For example: gPsFlux instead of g_PsFlux.")
    )
    multilevelOutput = pexConfig.Field(
        dtype=bool,
        default=False,
        doc=("Whether results dataframe should have a multilevel column index (True) or be flat "
             "and name-munged (False).")
    )
Ejemplo n.º 21
0
class FgcmOutputProductsConfig(
        pipeBase.PipelineTaskConfig,
        pipelineConnections=FgcmOutputProductsConnections):
    """Config for FgcmOutputProductsTask"""

    cycleNumber = pexConfig.Field(
        doc="Final fit cycle from FGCM fit",
        dtype=int,
        default=None,
    )
    physicalFilterMap = pexConfig.DictField(
        doc="Mapping from 'physicalFilter' to band.",
        keytype=str,
        itemtype=str,
        default={},
    )
    # The following fields refer to calibrating from a reference
    # catalog, but in the future this might need to be expanded
    doReferenceCalibration = pexConfig.Field(
        doc=("Transfer 'absolute' calibration from reference catalog? "
             "This afterburner step is unnecessary if reference stars "
             "were used in the full fit in FgcmFitCycleTask."),
        dtype=bool,
        default=False,
    )
    doRefcatOutput = pexConfig.Field(
        doc="Output standard stars in reference catalog format",
        dtype=bool,
        default=False,
        deprecated=
        "doRefcatOutput is no longer supported; this config will be removed after v24"
    )
    doAtmosphereOutput = pexConfig.Field(
        doc="Output atmospheres in transmission_atmosphere_fgcm format",
        dtype=bool,
        default=True,
    )
    doZeropointOutput = pexConfig.Field(
        doc="Output zeropoints in fgcm_photoCalib format",
        dtype=bool,
        default=True,
    )
    doComposeWcsJacobian = pexConfig.Field(
        doc=
        "Compose Jacobian of WCS with fgcm calibration for output photoCalib?",
        dtype=bool,
        default=True,
    )
    doApplyMeanChromaticCorrection = pexConfig.Field(
        doc="Apply the mean chromatic correction to the zeropoints?",
        dtype=bool,
        default=True,
    )
    refObjLoader = pexConfig.ConfigurableField(
        target=LoadIndexedReferenceObjectsTask,
        doc="reference object loader for 'absolute' photometric calibration",
        deprecated="refObjLoader is deprecated, and will be removed after v24",
    )
    photoCal = pexConfig.ConfigurableField(
        target=PhotoCalTask,
        doc="task to perform 'absolute' calibration",
    )
    referencePixelizationNside = pexConfig.Field(
        doc="Healpix nside to pixelize catalog to compare to reference catalog",
        dtype=int,
        default=64,
    )
    referencePixelizationMinStars = pexConfig.Field(
        doc=(
            "Minimum number of stars per healpix pixel to select for comparison"
            "to the specified reference catalog"),
        dtype=int,
        default=200,
    )
    referenceMinMatch = pexConfig.Field(
        doc=
        "Minimum number of stars matched to reference catalog to be used in statistics",
        dtype=int,
        default=50,
    )
    referencePixelizationNPixels = pexConfig.Field(
        doc=("Number of healpix pixels to sample to do comparison. "
             "Doing too many will take a long time and not yield any more "
             "precise results because the final number is the median offset "
             "(per band) from the set of pixels."),
        dtype=int,
        default=100,
    )
    datasetConfig = pexConfig.ConfigField(
        dtype=DatasetConfig,
        doc="Configuration for writing/reading ingested catalog",
        deprecated=
        "The datasetConfig was only used for gen2; this config will be removed after v24.",
    )

    def setDefaults(self):
        pexConfig.Config.setDefaults(self)

        # In order to transfer the "absolute" calibration from a reference
        # catalog to the relatively calibrated FGCM standard stars (one number
        # per band), we use the PhotoCalTask to match stars in a sample of healpix
        # pixels.  These basic settings ensure that only well-measured, good stars
        # from the source and reference catalogs are used for the matching.

        # applyColorTerms needs to be False if doReferenceCalibration is False,
        # as is the new default after DM-16702
        self.photoCal.applyColorTerms = False
        self.photoCal.fluxField = 'instFlux'
        self.photoCal.magErrFloor = 0.003
        self.photoCal.match.referenceSelection.doSignalToNoise = True
        self.photoCal.match.referenceSelection.signalToNoise.minimum = 10.0
        self.photoCal.match.sourceSelection.doSignalToNoise = True
        self.photoCal.match.sourceSelection.signalToNoise.minimum = 10.0
        self.photoCal.match.sourceSelection.signalToNoise.fluxField = 'instFlux'
        self.photoCal.match.sourceSelection.signalToNoise.errField = 'instFluxErr'
        self.photoCal.match.sourceSelection.doFlags = True
        self.photoCal.match.sourceSelection.flags.good = []
        self.photoCal.match.sourceSelection.flags.bad = ['flag_badStar']
        self.photoCal.match.sourceSelection.doUnresolved = False

    def validate(self):
        super().validate()

        # Force the connections to conform with cycleNumber
        self.connections.cycleNumber = str(self.cycleNumber)
Ejemplo n.º 22
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.º 23
0
 class BadDictCheck(pexConfig.Config):
     d = pexConfig.DictField("...",
                             keytype=int,
                             itemtype=int,
                             dictCheck=4)
Ejemplo n.º 24
0
 class BadItemtype(pexConfig.Config):
     d = pexConfig.DictField("...", keytype=int, itemtype=dict)
Ejemplo n.º 25
0
 class BadKeytype(pexConfig.Config):
     d = pexConfig.DictField("...", keytype=list, itemtype=int)
Ejemplo n.º 26
0
 class BadConfigClass(pexConf.Config):
     d = pexConf.DictField("...",
                           target=Target2,
                           ConfigClass=Target2)
Ejemplo n.º 27
0
class MosaicConfig(pexConfig.Config):
    nBrightest = pexConfig.Field(
        doc="number of stars used for fitting per exposure",
        dtype=int,
        default=0)
    cellSize = pexConfig.Field(
        doc="size of cell used to select stars (pixels)",
        dtype=int,
        default=512,
        check=lambda x: x >= 128)
    nStarPerCell = pexConfig.Field(doc="number of stars per cell",
                                   dtype=int,
                                   default=5)
    radXMatch = pexConfig.RangeField(
        doc="radius to cross-match objects between expsoures in arcsec",
        dtype=float,
        default=1.0,
        min=0.1)
    fittingOrder = pexConfig.RangeField(doc="fitting order",
                                        dtype=int,
                                        default=5,
                                        min=2)
    internalFitting = pexConfig.Field(
        doc="Use stars without catalog matching for fitting?",
        dtype=bool,
        default=True)
    solveCcd = pexConfig.Field(doc="Solve CCD alignment?",
                               dtype=bool,
                               default=True)
    allowRotation = pexConfig.Field(doc="Solve rotation?",
                                    dtype=bool,
                                    default=True)
    catRMS = pexConfig.Field(
        doc="Positional error in reference catalog (degree)",
        dtype=float,
        default=0.040 / 3600.)
    chebyshev = pexConfig.Field(
        doc="Use Chebyshev polynomials for flux fitting?",
        dtype=bool,
        default=True)
    fluxFitOrder = pexConfig.RangeField(doc="flux fitting order",
                                        dtype=int,
                                        default=5,
                                        min=0)
    fluxFitAbsolute = pexConfig.Field(doc="Fit to catalog flux?",
                                      dtype=bool,
                                      default=False)
    fluxFitSolveCcd = pexConfig.Field(doc="Solve for per CCD flux scale?",
                                      dtype=bool,
                                      default=False)
    minNumMatch = pexConfig.RangeField(
        doc="Minimum number of matches in CCD to be used.",
        dtype=int,
        default=0,
        min=0)
    numSourceMerge = pexConfig.RangeField(
        doc="Minimum number of sources to be merged.",
        dtype=int,
        default=2,
        min=0)
    requireTractOverlap = pexConfig.Field(
        doc="If True, ignore CCDs that don't overlap the current tract",
        dtype=bool,
        default=True)
    clipSourcesOutsideTract = pexConfig.Field(
        doc=
        "If True, unmatched sources outside of tract will not be used as constraints",
        dtype=bool,
        default=True)
    loadAstrom = pexConfig.ConfigurableField(
        doc="Configuration for astrometry reference object loading",
        target=LoadIndexedReferenceObjectsTask)
    doColorTerms = pexConfig.Field(
        doc="Apply color terms as part of solution?", dtype=bool, default=True)
    doSolveWcs = pexConfig.Field(doc="Solve distortion and wcs?",
                                 dtype=bool,
                                 default=True)
    doSolveFlux = pexConfig.Field(doc="Solve flux correction?",
                                  dtype=bool,
                                  default=True)
    commonFluxCorr = pexConfig.Field(
        doc="Is flux correction common between exposures?",
        dtype=bool,
        default=True)
    colorterms = pexConfig.ConfigField(doc="Color term library",
                                       dtype=ColortermLibrary)
    photoCatName = pexConfig.Field(
        doc=
        "Name of photometric reference catalog; used to select a color term dict in colorterm library.",
        default="ps1_pv3_3pi_20170110",
        dtype=str,
        optional=True)
    includeSaturated = pexConfig.Field(
        doc="If True, saturated objects will also be used for mosaicking.",
        dtype=bool,
        default=False)
    extendednessForStarSelection = pexConfig.Field(
        doc="Extendedness for star selection",
        dtype=str,
        default="base_ClassificationExtendedness_value")
    saturatedForStarSelection = pexConfig.Field(
        doc="Saturated flag for star selection",
        dtype=str,
        default="base_PixelFlags_flag_saturated")
    psfStarForStarSelection = pexConfig.Field(
        doc="PSF star flag for star selection",
        dtype=str,
        default="calib_psfUsed")
    calibStarForStarSelection = pexConfig.Field(
        doc="Calibration star detected as an icSrc flag for star selection",
        dtype=str,
        default="calib_detected")
    parentForStarSelection = pexConfig.Field(
        doc="Does souce have a parent? For star selection",
        dtype=str,
        default="parent")
    nChildForStarSelection = pexConfig.Field(
        doc="Does souce have any children? For star selection",
        dtype=str,
        default="deblend_nChild")
    coaddName = pexConfig.Field(
        doc="Type of coadd being produced; used to select the correct SkyMap.",
        dtype=str,
        default="deep")
    srcSchemaMap = pexConfig.DictField(
        doc="Mapping between different stack (e.g. HSC vs. LSST) schema names",
        keytype=str,
        itemtype=str,
        default=None,
        optional=True)
    allowMixedFilters = pexConfig.Field(dtype=bool,
                                        default=False,
                                        doc="Allow multiple filters in input?")

    def setDefaults(self):
        self.loadAstrom.ref_dataset_name = "ps1_pv3_3pi_20170110"
Ejemplo n.º 28
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")
Ejemplo n.º 29
0
class PhotonTransferCurveExtractConfig(pipeBase.PipelineTaskConfig,
                                       pipelineConnections=PhotonTransferCurveExtractConnections):
    """Configuration for the measurement of covariances from flats.
    """
    maximumRangeCovariancesAstier = pexConfig.Field(
        dtype=int,
        doc="Maximum range of covariances as in Astier+19",
        default=8,
    )
    covAstierRealSpace = pexConfig.Field(
        dtype=bool,
        doc="Calculate covariances in real space or via FFT? (see appendix A of Astier+19).",
        default=False,
    )
    binSize = pexConfig.Field(
        dtype=int,
        doc="Bin the image by this factor in both dimensions.",
        default=1,
    )
    minMeanSignal = pexConfig.DictField(
        keytype=str,
        itemtype=float,
        doc="Minimum values (inclusive) of mean signal (in ADU) above which to consider, per amp."
            " The same cut is applied to all amps if this dictionary is of the form"
            " {'ALL_AMPS': value}",
        default={'ALL_AMPS': 0.0},
    )
    maxMeanSignal = pexConfig.DictField(
        keytype=str,
        itemtype=float,
        doc="Maximum values (inclusive) of mean signal (in ADU) below which to consider, per amp."
            " The same cut is applied to all amps if this dictionary is of the form"
            " {'ALL_AMPS': value}",
        default={'ALL_AMPS': 1e6},
    )
    maskNameList = pexConfig.ListField(
        dtype=str,
        doc="Mask list to exclude from statistics calculations.",
        default=['SUSPECT', 'BAD', 'NO_DATA'],
    )
    nSigmaClipPtc = pexConfig.Field(
        dtype=float,
        doc="Sigma cut for afwMath.StatisticsControl()",
        default=5.5,
    )
    nIterSigmaClipPtc = pexConfig.Field(
        dtype=int,
        doc="Number of sigma-clipping iterations for afwMath.StatisticsControl()",
        default=1,
    )
    minNumberGoodPixelsForFft = pexConfig.Field(
        dtype=int,
        doc="Minimum number of acceptable good pixels per amp to calculate the covariances via FFT.",
        default=10000,
    )
    detectorMeasurementRegion = pexConfig.ChoiceField(
        dtype=str,
        doc="Region of each exposure where to perform the calculations (amplifier or full image).",
        default='AMP',
        allowed={
            "AMP": "Amplifier of the detector.",
            "FULL": "Full image."
        }
    )
class IngestIndexedReferenceConfig(pexConfig.Config):
    dataset_config = pexConfig.ConfigField(
        dtype=DatasetConfig,
        doc="Configuration for reading the ingested data",
    )
    n_processes = pexConfig.Field(
        dtype=int,
        doc=("Number of python processes to use when ingesting."),
        default=1)
    file_reader = pexConfig.ConfigurableField(
        target=ReadTextCatalogTask,
        doc='Task to use to read the files.  Default is to expect text files.')
    ra_name = pexConfig.Field(
        dtype=str,
        doc="Name of RA column",
    )
    dec_name = pexConfig.Field(
        dtype=str,
        doc="Name of Dec column",
    )
    ra_err_name = pexConfig.Field(
        dtype=str,
        doc="Name of RA error column",
        optional=True,
    )
    dec_err_name = pexConfig.Field(
        dtype=str,
        doc="Name of Dec error column",
        optional=True,
    )
    mag_column_list = pexConfig.ListField(
        dtype=str,
        doc=
        "The values in the reference catalog are assumed to be in AB magnitudes. "
        "List of column names to use for photometric information.  At least one entry is required."
    )
    mag_err_column_map = pexConfig.DictField(
        keytype=str,
        itemtype=str,
        default={},
        doc=
        "A map of magnitude column name (key) to magnitude error column (value)."
    )
    is_photometric_name = pexConfig.Field(
        dtype=str,
        optional=True,
        doc=
        'Name of column stating if satisfactory for photometric calibration (optional).'
    )
    is_resolved_name = pexConfig.Field(
        dtype=str,
        optional=True,
        doc='Name of column stating if the object is resolved (optional).')
    is_variable_name = pexConfig.Field(
        dtype=str,
        optional=True,
        doc=
        'Name of column stating if the object is measured to be variable (optional).'
    )
    id_name = pexConfig.Field(
        dtype=str,
        optional=True,
        doc='Name of column to use as an identifier (optional).')
    pm_ra_name = pexConfig.Field(
        dtype=str,
        doc="Name of proper motion RA column",
        optional=True,
    )
    pm_dec_name = pexConfig.Field(
        dtype=str,
        doc="Name of proper motion Dec column",
        optional=True,
    )
    pm_ra_err_name = pexConfig.Field(
        dtype=str,
        doc="Name of proper motion RA error column",
        optional=True,
    )
    pm_dec_err_name = pexConfig.Field(
        dtype=str,
        doc="Name of proper motion Dec error column",
        optional=True,
    )
    pm_scale = pexConfig.Field(
        dtype=float,
        doc=
        "Scale factor by which to multiply proper motion values to obtain units of milliarcsec/year",
        default=1.0,
    )
    parallax_name = pexConfig.Field(
        dtype=str,
        doc="Name of parallax column",
        optional=True,
    )
    parallax_err_name = pexConfig.Field(
        dtype=str,
        doc="Name of parallax error column",
        optional=True,
    )
    parallax_scale = pexConfig.Field(
        dtype=float,
        doc=
        "Scale factor by which to multiply parallax values to obtain units of milliarcsec",
        default=1.0,
    )
    epoch_name = pexConfig.Field(
        dtype=str,
        doc="Name of epoch column",
        optional=True,
    )
    epoch_format = pexConfig.Field(
        dtype=str,
        doc=
        "Format of epoch column: any value accepted by astropy.time.Time, e.g. 'iso' or 'unix'",
        optional=True,
    )
    epoch_scale = pexConfig.Field(
        dtype=str,
        doc=
        "Scale of epoch column: any value accepted by astropy.time.Time, e.g. 'utc'",
        optional=True,
    )
    extra_col_names = pexConfig.ListField(
        dtype=str,
        default=[],
        doc='Extra columns to add to the reference catalog.')

    def setDefaults(self):
        # Newly ingested reference catalogs always have the latest format_version.
        self.dataset_config.format_version = LATEST_FORMAT_VERSION

    def validate(self):
        pexConfig.Config.validate(self)

        def assertAllOrNone(*names):
            """Raise ValueError unless all the named fields are set or are
            all none (or blank)
            """
            setNames = [name for name in names if bool(getattr(self, name))]
            if len(setNames) in (len(names), 0):
                return
            prefix = "Both or neither" if len(names) == 2 else "All or none"
            raise ValueError(
                "{} of {} must be set, but only {} are set".format(
                    prefix, ", ".join(names), ", ".join(setNames)))

        if not (self.ra_name and self.dec_name and self.mag_column_list):
            raise ValueError(
                "ra_name and dec_name and at least one entry in mag_column_list must be supplied."
            )
        if self.mag_err_column_map and set(self.mag_column_list) != set(
                self.mag_err_column_map.keys()):
            raise ValueError(
                "mag_err_column_map specified, but keys do not match mag_column_list: {} != {}"
                .format(sorted(self.mag_err_column_map.keys()),
                        sorted(self.mag_column_list)))
        assertAllOrNone("ra_err_name", "dec_err_name")
        assertAllOrNone("epoch_name", "epoch_format", "epoch_scale")
        assertAllOrNone("pm_ra_name", "pm_dec_name")
        assertAllOrNone("pm_ra_err_name", "pm_dec_err_name")
        assertAllOrNone("parallax_name", "parallax_err_name")
        if self.pm_ra_err_name and not self.pm_ra_name:
            raise ValueError(
                '"pm_ra/dec_name" must be specified if "pm_ra/dec_err_name" are specified'
            )
        if (self.pm_ra_name or self.parallax_name) and not self.epoch_name:
            raise ValueError(
                '"epoch_name" must be specified if "pm_ra/dec_name" or "parallax_name" are specified'
            )