LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin Class Reference
Inheritance diagram for lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin:
lsst.meas.base.sfm.SingleFramePlugin lsst.meas.base.baseMeasurement.BaseMeasurementPlugin lsst.meas.base.pluginsBase.BasePlugin

Public Member Functions

 getExecutionOrder (cls)
 
 __init__ (self, SingleFrameCompensatedTophatFluxConfig config, str name, schema, metadata, logName=None, **kwds)
 
 fail (self, measRecord, error=None)
 
 measure (self, measRecord, exposure)
 

Public Attributes

 aperture_keys
 
 flagHandler
 

Static Public Attributes

 ConfigClass = SingleFrameCompensatedTophatFluxConfig
 

Protected Attributes

 _rads
 
 _inner_scale
 
 _outer_scale
 
 _max_rad
 

Detailed Description

Definition at line 70 of file _compensatedTophat.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin.__init__ ( self,
SingleFrameCompensatedTophatFluxConfig config,
str name,
schema,
metadata,
logName = None,
** kwds )

Reimplemented from lsst.meas.base.sfm.SingleFramePlugin.

Definition at line 77 of file _compensatedTophat.py.

85 ):
86 super().__init__(config, name, schema, metadata, logName, **kwds)
87
88 flagDefs = FlagDefinitionList()
89
90 self.aperture_keys = {}
91 self._rads = {}
92 self._inner_scale = config.inner_scale
93 self._outer_scale = config.outer_scale
94 for aperture in config.apertures:
95 base_key = f"{name}_{aperture}"
96
97 # flux
98 flux_str = f"{base_key}_instFlux"
99 flux_key = schema.addField(
100 flux_str,
101 type="D",
102 doc="Compensated Tophat flux measurement.",
103 units="count",
104 )
105
106 # flux error
107 err_str = f"{base_key}_instFluxErr"
108 err_key = schema.addField(
109 err_str,
110 type="D",
111 doc="Compensated Tophat flux error.",
112 units="count",
113 )
114
115 # mask bits
116 mask_str = f"{base_key}_mask_bits"
117 mask_key = schema.addField(mask_str, type=np.int32, doc="Mask bits set within aperture.")
118
119 # failure flags
120 failure_flag = flagDefs.add(f"{aperture}_flag", "Compensated Tophat measurement failed")
121 oob_flag = flagDefs.add(f"{aperture}_flag_bounds", "Compensated Tophat out-of-bounds")
122
123 self.aperture_keys[aperture] = (flux_key, err_key, mask_key, failure_flag, oob_flag)
124 self._rads[aperture] = int(math.ceil(self._outer_scale*aperture))
125
126 self.flagHandler = FlagHandler.addFields(schema, name, flagDefs)
127 self._max_rad = max(self._rads)
128
int max

Member Function Documentation

◆ fail()

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin.fail ( self,
measRecord,
error = None )
Record a failure of the `measure` or `measureN` method.

Parameters
----------
measRecord : `lsst.afw.table.SourceRecord`
    Table record describing the source being measured.
error : `MeasurementError`, optional
    Only provided if the measurement failed due to a
    `MeasurementError` being raised; otherwise, will be `None`.

Notes
-----
When the plugin raises an exception, framework will call
`BasePlugin.fail` to allow the plugin to set its failure flag
field(s).  When `BasePlugin.measureN` raises an exception,
`BasePlugin.fail` will be called repeatedly with all the records that
were being measured.

If the exception is an `MeasurementError`, it will be passed as the
error argument; in all other cases the error argument will be `None`,
and the failure will be logged by the measurement framework as a
warning.

Reimplemented from lsst.meas.base.pluginsBase.BasePlugin.

Definition at line 129 of file _compensatedTophat.py.

129 def fail(self, measRecord, error=None):
130 if error is None:
131 self.flagHandler.handleFailure(measRecord)
132 else:
133 self.flagHandler.handleFailure(measRecord, error.cpp)
134

◆ getExecutionOrder()

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin.getExecutionOrder ( cls)
Get the relative execution order of this plugin.

Must be reimplemented as a class method by concrete derived classes.

Reimplemented from lsst.meas.base.pluginsBase.BasePlugin.

Definition at line 74 of file _compensatedTophat.py.

74 def getExecutionOrder(cls):
75 return cls.FLUX_ORDER
76

◆ measure()

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin.measure ( self,
measRecord,
exposure )
Measure the properties of a source on a single image.

The image may be from a single epoch, or it may be a coadd.

Parameters
----------
measRecord : `lsst.afw.table.SourceRecord`
    Record describing the object being measured. Previously-measured
    quantities may be retrieved from here, and it will be updated
    in-place tih the outputs of this plugin.
exposure : `lsst.afw.image.ExposureF`
    The pixel data to be measured, together with the associated PSF,
    WCS, etc. All other sources in the image should have been replaced
    by noise according to deblender outputs.

Reimplemented from lsst.meas.base.sfm.SingleFramePlugin.

Definition at line 135 of file _compensatedTophat.py.

135 def measure(self, measRecord, exposure):
136 center = measRecord.getCentroid()
137 bbox = exposure.getBBox()
138
139 y = center.getY() - bbox.beginY
140 x = center.getX() - bbox.beginX
141
142 y_floor = math.floor(y)
143 x_floor = math.floor(x)
144
145 ctrl = ApertureFluxAlgorithm.Control()
146
147 for aperture, (flux_key, err_key, mask_key, failure_flag, oob_flag) in self.aperture_keys.items():
148 rad = self._rads[aperture]
149
150 # This will fail if even a single pixel is outside the bounding
151 # box.
152 if Point2I(center) not in exposure.getBBox().erodedBy(rad):
153 self.flagHandler.setValue(measRecord, failure_flag.number, True)
154 self.flagHandler.setValue(measRecord, oob_flag.number, True)
155 continue
156
157 # We confirmed that the bounding box is sufficient to hold these
158 # slices, so no additional range checking is needed.
159 y_slice = slice(y_floor - rad, y_floor + rad + 1, 1)
160 x_slice = slice(x_floor - rad, x_floor + rad + 1, 1)
161
162 # We will need the mask below, we can use this to test bounds as
163 # well.
164 sub_mask = exposure.mask.array[y_slice, x_slice]
165
166 if sub_mask.size == 0 or sub_mask.shape[0] != sub_mask.shape[1] or (sub_mask.shape[0] % 2) == 0:
167 self.flagHandler.setValue(measRecord, failure_flag.number, True)
168 self.flagHandler.setValue(measRecord, oob_flag.number, True)
169 continue
170
171 # Compute three aperture fluxes.
172 ellipse = lsst.afw.geom.Ellipse(lsst.afw.geom.ellipses.Axes(float(aperture),
173 float(aperture), 0.0),
174 center)
175 tophat = ApertureFluxAlgorithm.computeFlux(exposure.maskedImage, ellipse, ctrl)
176 ellipse.grow((self._inner_scale - 1.0)*aperture)
177 inner = ApertureFluxAlgorithm.computeFlux(exposure.maskedImage, ellipse, ctrl)
178 ellipse.grow((self._outer_scale - self._inner_scale)*aperture)
179 outer = ApertureFluxAlgorithm.computeFlux(exposure.maskedImage, ellipse, ctrl)
180
181 # We have flux in 3 circular apertures, a_0, a_1, a_2 with
182 # associated variances \sigma_{a_0}^2, \sigma_{a_1}^2,
183 # \sigma_{a_2)^2.
std::vector< SchemaItem< Flag > > * items
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a,...
Definition Axes.h:47
An ellipse defined by an arbitrary BaseCore and a center point.
Definition Ellipse.h:51

Member Data Documentation

◆ _inner_scale

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin._inner_scale
protected

Definition at line 92 of file _compensatedTophat.py.

◆ _max_rad

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin._max_rad
protected

Definition at line 127 of file _compensatedTophat.py.

◆ _outer_scale

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin._outer_scale
protected

Definition at line 93 of file _compensatedTophat.py.

◆ _rads

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin._rads
protected

Definition at line 91 of file _compensatedTophat.py.

◆ aperture_keys

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin.aperture_keys

Definition at line 90 of file _compensatedTophat.py.

◆ ConfigClass

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin.ConfigClass = SingleFrameCompensatedTophatFluxConfig
static

Definition at line 71 of file _compensatedTophat.py.

◆ flagHandler

lsst.meas.base.compensatedGaussian._compensatedTophat.SingleFrameCompensatedTophatFluxPlugin.flagHandler

Definition at line 126 of file _compensatedTophat.py.


The documentation for this class was generated from the following file: