25 from builtins
import object
27 import lsst.pex.config
28 from .transforms
import PassThroughTransform
30 __all__ = (
"BasePluginConfig",
"BasePlugin")
35 Base class measurement Plugin config classes. 37 Most derived classes will want to set defaults that make sense for the plugin type 44 Base class for measurement plugins. 46 This is the base class for SingleFramePlugin and ForcedPlugin; derived classes should inherit 54 DEFAULT_CATALOGCALCULATION = 4.0
58 """Sets the relative order of plugins (smaller numbers run first). 60 In general, the following class constants should be used (other values 61 are also allowed, but should be avoided unless they are needed): 62 CENTROID_ORDER centroids and other algorithms that require only a Footprint 63 and its Peaks as input 64 SHAPE_ORDER shape measurements and other algorithms that require getCentroid() to return 65 a good centroid (in addition to a Footprint and its Peaks). 66 FLUX_ORDER flux algorithms that require both getShape() and getCentroid(), 67 in addition to a Footprint and its Peaks 68 DEFAULT_CATALOGCALCULATION plugins that only operate on the catalog 70 Must be reimplemented as a class method by concrete derived classes. 72 This approach was chosen instead of a full graph-based analysis of dependencies 73 because algorithm dependencies are usually both quite simple and entirely substitutable: 74 an algorithm that requires a centroid can typically make use of any centroid algorithms 75 outputs. That makes it relatively easy to figure out the correct value to use for any 78 raise NotImplementedError(
"All plugins must implement getExecutionOrder()")
80 def __init__(self, config, name, logName=None):
82 Initialize the plugin object. 84 @param[in] config An instance of this class's ConfigClass. 85 @param[in] name The string the plugin was registered with. 95 def fail(self, measRecord, error=None):
97 Record a failure of the measure or measureN() method. 99 When the plugin raises an exception, framework will call 100 fail() to allow the plugin to set its failure flag 101 field(s). When measureN() raises an exception, fail() will be 102 called repeatedly with all the records that were being 105 If the exception is a MeasurementError, it will be passed as 106 the error argument; in all other cases the error argument will 107 be None, and the failure will be logged by the measurement 108 framework as a warning. 110 traceback.print_exc()
111 message = (
"The algorithm '%s' thinks it cannot fail, but it did; " 112 "please report this as a bug (the full traceback is above)." 113 % (self.__class__.__name__,))
114 raise NotImplementedError(message)
119 Get the measurement transformation appropriate to this plugin. 121 This returns a subclass of MeasurementTransform, which may be 122 instantiated with details of the algorithm configuration and then 123 called with information about calibration and WCS to convert from raw 124 measurement quantities to calibrated units. Calibrated data is then 125 provided in a separate output table. 127 By default, we copy everything from the input to the output without 130 return PassThroughTransform
def __init__(self, config, name, logName=None)
Initialize the plugin object.
def getExecutionOrder(cls)
Base class for measurement plugins.
Base class measurement Plugin config classes.
def getTransformClass()
Get the measurement transformation appropriate to this plugin.
def fail(self, measRecord, error=None)
Record a failure of the measure or measureN() method.