Example #1
0
    def __init__(self, config, name, schema, metadata):
        super().__init__(config, name, schema, metadata)

        # Measurement Keys
        self.keyX0 = schema.addField(name + "_x0",
                                     type="D",
                                     doc="Trail head X coordinate.",
                                     units="pixel")
        self.keyY0 = schema.addField(name + "_y0",
                                     type="D",
                                     doc="Trail head Y coordinate.",
                                     units="pixel")
        self.keyX1 = schema.addField(name + "_x1",
                                     type="D",
                                     doc="Trail tail X coordinate.",
                                     units="pixel")
        self.keyY1 = schema.addField(name + "_y1",
                                     type="D",
                                     doc="Trail tail Y coordinate.",
                                     units="pixel")
        self.keyFlux = schema.addField(name + "_flux",
                                       type="D",
                                       doc="Trailed source flux.",
                                       units="count")
        self.keyL = schema.addField(name + "_length",
                                    type="D",
                                    doc="Trail length.",
                                    units="pixel")
        self.keyAngle = schema.addField(name + "_angle",
                                        type="D",
                                        doc="Angle measured from +x-axis.")

        # Measurement Error Keys
        self.keyX0Err = schema.addField(name + "_x0Err",
                                        type="D",
                                        doc="Trail head X coordinate error.",
                                        units="pixel")
        self.keyY0Err = schema.addField(name + "_y0Err",
                                        type="D",
                                        doc="Trail head Y coordinate error.",
                                        units="pixel")
        self.keyX1Err = schema.addField(name + "_x1Err",
                                        type="D",
                                        doc="Trail tail X coordinate error.",
                                        units="pixel")
        self.keyY1Err = schema.addField(name + "_y1Err",
                                        type="D",
                                        doc="Trail tail Y coordinate error.",
                                        units="pixel")

        flagDefs = FlagDefinitionList()
        flagDefs.addFailureFlag("No trailed-source measured")
        self.NO_FLUX = flagDefs.add("flag_noFlux",
                                    "No suitable prior flux measurement")
        self.flagHandler = FlagHandler.addFields(schema, name, flagDefs)

        self.centriodExtractor = SafeCentroidExtractor(schema, name)
Example #2
0
    def __init__(self, config, name, schema, metadata):
        super().__init__(config, name, schema, metadata)

        self.keyXC = schema.addField(name + "_centroid_x",
                                     type="D",
                                     doc="Trail centroid X coordinate.",
                                     units="pixel")
        self.keyYC = schema.addField(name + "_centroid_y",
                                     type="D",
                                     doc="Trail centroid Y coordinate.",
                                     units="pixel")
        self.keyX0 = schema.addField(name + "_x0",
                                     type="D",
                                     doc="Trail head X coordinate.",
                                     units="pixel")
        self.keyY0 = schema.addField(name + "_y0",
                                     type="D",
                                     doc="Trail head Y coordinate.",
                                     units="pixel")
        self.keyX1 = schema.addField(name + "_x1",
                                     type="D",
                                     doc="Trail tail X coordinate.",
                                     units="pixel")
        self.keyY1 = schema.addField(name + "_y1",
                                     type="D",
                                     doc="Trail tail Y coordinate.",
                                     units="pixel")
        self.keyL = schema.addField(name + "_length",
                                    type="D",
                                    doc="Length of trail.",
                                    units="pixel")
        self.keyTheta = schema.addField(name + "_angle",
                                        type="D",
                                        doc="Angle of trail from +x-axis.")
        self.keyFlux = schema.addField(name + "_flux",
                                       type="D",
                                       doc="Trailed source flux.",
                                       units="count")
        self.keyRChiSq = schema.addField(name + "_rChiSq",
                                         type="D",
                                         doc="Reduced chi-squared of fit")

        flagDefs = FlagDefinitionList()
        flagDefs.addFailureFlag("No trailed-sources measured")
        self.NON_CONVERGE = flagDefs.add("flag_nonConvergence",
                                         "Optimizer did not converge")
        self.NO_NAIVE = flagDefs.add("flag_noNaive",
                                     "Naive measurement contains NaNs")
        self.flagHandler = FlagHandler.addFields(schema, name, flagDefs)

        self.centroidExtractor = SafeCentroidExtractor(schema, name)
Example #3
0
 def __init__(self, config, name, schema, metadata, logName=None):
     SingleFramePlugin.__init__(self, config, name, schema, metadata, logName=logName)
     flagDefs = FlagDefinitionList()
     self.FAILURE = flagDefs.addFailureFlag()
     self.CONTAINS_NAN = flagDefs.add("flag_containsNan", "Measurement area contains a nan")
     self.flagHandler = FlagHandler.addFields(schema, name, flagDefs)
     self.instFluxKey = schema.addField(name + "_instFlux", "F", doc="flux")
Example #4
0
 def __init__(self, config, name, schema, metadata):
     SingleFramePlugin.__init__(self, config, name, schema, metadata)
     flagDefs = FlagDefinitionList()
     self.FAILURE = flagDefs.addFailureFlag()
     self.CONTAINS_NAN = flagDefs.add("flag_containsNan", "Measurement area contains a nan")
     self.EDGE = flagDefs.add("flag_edge", "Measurement area over edge")
     self.flagHandler = FlagHandler.addFields(schema, name, flagDefs)
     self.centroidExtractor = lsst.meas.base.SafeCentroidExtractor(schema, name)
     self.instFluxKey = schema.addField(name + "_instFlux", "F", doc="flux")
     self.magKey = schema.addField(name + "_mag", "F", doc="mag")
Example #5
0
 def __init__(self, config, name, schema, metadata):
     SingleFramePlugin.__init__(self, config, name, schema, metadata)
     flagDefs = FlagDefinitionList()
     self.FAILURE = flagDefs.addFailureFlag()
     self.CONTAINS_NAN = flagDefs.add("flag_containsNan",
                                      "Measurement area contains a nan")
     self.EDGE = flagDefs.add("flag_edge", "Measurement area over edge")
     self.flagHandler = FlagHandler.addFields(schema, name, flagDefs)
     self.centroidExtractor = lsst.meas.base.SafeCentroidExtractor(
         schema, name)
     self.fluxKey = schema.addField(name + "_flux", "F", doc="flux")
     self.magKey = schema.addField(name + "_mag", "F", doc="mag")
Example #6
0
 def __init__(self, config, name, schema, metadata, logName=None):
     SingleFramePlugin.__init__(self,
                                config,
                                name,
                                schema,
                                metadata,
                                logName=logName)
     flagDefs = FlagDefinitionList()
     self.FAILURE = flagDefs.addFailureFlag()
     self.CONTAINS_NAN = flagDefs.add("flag_containsNan",
                                      "Measurement area contains a nan")
     self.flagHandler = FlagHandler.addFields(schema, name, flagDefs)
     self.fluxKey = schema.addField(name + "_flux", "F", doc="flux")
Example #7
0
    def testFlagHandler(self):
        """
        Standalone test to create a flaghandler and call it
        This is not a real world example, just a simple unit test
        """
        schema = lsst.afw.table.SourceTable.makeMinimalSchema()

        # This is a FlagDefinition structure like a plugin might have
        flagDefs = FlagDefinitionList()
        FAILURE = flagDefs.addFailureFlag()
        FIRST = flagDefs.add("1st error", "this is the first failure type")
        SECOND = flagDefs.add("2nd error", "this is the second failure type")
        fh = FlagHandler.addFields(schema, "test", flagDefs)
        # Check to be sure that the FlagHandler was correctly initialized
        for index in range(len(flagDefs)):
            self.assertEqual(
                flagDefs.getDefinition(index).name, fh.getFlagName(index))

        catalog = lsst.afw.table.SourceCatalog(schema)

        # Now check to be sure that all of the known failures set the bits correctly
        record = catalog.addNew()
        fh.handleFailure(record)
        self.assertTrue(fh.getValue(record, FAILURE.number))
        self.assertFalse(fh.getValue(record, FIRST.number))
        self.assertFalse(fh.getValue(record, SECOND.number))
        record = catalog.addNew()

        error = MeasurementError(FAILURE.doc, FAILURE.number)
        fh.handleFailure(record, error.cpp)
        self.assertTrue(fh.getValue(record, FAILURE.number))
        self.assertFalse(fh.getValue(record, FIRST.number))
        self.assertFalse(fh.getValue(record, SECOND.number))

        record = catalog.addNew()
        error = MeasurementError(FIRST.doc, FIRST.number)
        fh.handleFailure(record, error.cpp)
        self.assertTrue(fh.getValue(record, FAILURE.number))
        self.assertTrue(fh.getValue(record, FIRST.number))
        self.assertFalse(fh.getValue(record, SECOND.number))

        record = catalog.addNew()
        error = MeasurementError(SECOND.doc, SECOND.number)
        fh.handleFailure(record, error.cpp)
        self.assertTrue(fh.getValue(record, FAILURE.number))
        self.assertFalse(fh.getValue(record, FIRST.number))
        self.assertTrue(fh.getValue(record, SECOND.number))
Example #8
0
    def testFlagHandler(self):
        """Test creation and invocation of `FlagHander`.
        """
        schema = lsst.afw.table.SourceTable.makeMinimalSchema()

        # This is a FlagDefinition structure like a plugin might have
        flagDefs = FlagDefinitionList()
        FAILURE = flagDefs.addFailureFlag()
        FIRST = flagDefs.add("1st error", "this is the first failure type")
        SECOND = flagDefs.add("2nd error", "this is the second failure type")
        fh = FlagHandler.addFields(schema, "test", flagDefs)
        # Check to be sure that the FlagHandler was correctly initialized
        for index in range(len(flagDefs)):
            self.assertEqual(flagDefs.getDefinition(index).name, fh.getFlagName(index))

        catalog = lsst.afw.table.SourceCatalog(schema)

        # Now check to be sure that all of the known failures set the bits
        # correctly
        record = catalog.addNew()
        fh.handleFailure(record)
        self.assertTrue(fh.getValue(record, FAILURE.number))
        self.assertFalse(fh.getValue(record, FIRST.number))
        self.assertFalse(fh.getValue(record, SECOND.number))
        record = catalog.addNew()

        error = MeasurementError(FAILURE.doc, FAILURE.number)
        fh.handleFailure(record, error.cpp)
        self.assertTrue(fh.getValue(record, FAILURE.number))
        self.assertFalse(fh.getValue(record, FIRST.number))
        self.assertFalse(fh.getValue(record, SECOND.number))

        record = catalog.addNew()
        error = MeasurementError(FIRST.doc, FIRST.number)
        fh.handleFailure(record, error.cpp)
        self.assertTrue(fh.getValue(record, FAILURE.number))
        self.assertTrue(fh.getValue(record, FIRST.number))
        self.assertFalse(fh.getValue(record, SECOND.number))

        record = catalog.addNew()
        error = MeasurementError(SECOND.doc, SECOND.number)
        fh.handleFailure(record, error.cpp)
        self.assertTrue(fh.getValue(record, FAILURE.number))
        self.assertFalse(fh.getValue(record, FIRST.number))
        self.assertTrue(fh.getValue(record, SECOND.number))