LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.meas.base.diaCalculationPlugins.WeightedMeanDiaPsFlux Class Reference
Inheritance diagram for lsst.meas.base.diaCalculationPlugins.WeightedMeanDiaPsFlux:
lsst.meas.base.diaCalculation.DiaObjectCalculationPlugin lsst.meas.base.catalogCalculation.CatalogCalculationPlugin lsst.meas.base.pluginsBase.BasePlugin

Public Member Functions

def getExecutionOrder (cls)
 
def calculate (self, diaObjects, diaSources, filterDiaSources, filterName, **kwargs)
 
def calculate (self, cat, **kwargs)
 
def fail (self, diaObject, columns, error=None)
 
def fail (self, measRecord, error=None)
 
def getLogName (self)
 

Static Public Member Functions

def getTransformClass ()
 

Public Attributes

 config
 
 name
 
 logName
 

Static Public Attributes

 ConfigClass = WeightedMeanDiaPsFluxConfig
 
list outputCols = ["PSFluxMean", "PSFluxMeanErr", "PSFluxNdata"]
 
string plugType = "multi"
 
bool needsFilter = True
 
 registry = PluginRegistry(DiaObjectCalculationPluginConfig)
 
float FLUX_MOMENTS_CALCULATED = 5.0
 
list inputCols = []
 
float CENTROID_ORDER = 0.0
 
float SHAPE_ORDER = 1.0
 
float FLUX_ORDER = 2.0
 
float APCORR_ORDER = 3.0
 
float DEFAULT_CATALOGCALCULATION = 4.0
 

Detailed Description

Compute the weighted mean and mean error on the point source fluxes
of the DiaSource measured on the difference image.

Additionally store number of usable data points.

Definition at line 257 of file diaCalculationPlugins.py.

Member Function Documentation

◆ calculate() [1/2]

def lsst.meas.base.catalogCalculation.CatalogCalculationPlugin.calculate (   self,
  cat,
**  kwargs 
)
inherited
Perform the calculation specified by this plugin.

This method can either be used to operate on a single catalog record
or a whole catalog, populating it with the output defined by this
plugin.

Note that results may be added to catalog records as new columns, or
may result in changes to existing values.

Parameters
----------
cat : `lsst.afw.table.SourceCatalog` or `lsst.afw.table.SourceRecord`
    May either be a `~lsst.afw.table.SourceCatalog` or a single
    `~lsst.afw.table.SourceRecord`, depending on the plugin type. Will
    be updated in place to contain the results of plugin execution.
**kwargs
    Any additional keyword arguments that may be passed to the plugin.

Definition at line 97 of file catalogCalculation.py.

97  def calculate(self, cat, **kwargs):
98  """Perform the calculation specified by this plugin.
99 
100  This method can either be used to operate on a single catalog record
101  or a whole catalog, populating it with the output defined by this
102  plugin.
103 
104  Note that results may be added to catalog records as new columns, or
105  may result in changes to existing values.
106 
107  Parameters
108  ----------
109  cat : `lsst.afw.table.SourceCatalog` or `lsst.afw.table.SourceRecord`
110  May either be a `~lsst.afw.table.SourceCatalog` or a single
111  `~lsst.afw.table.SourceRecord`, depending on the plugin type. Will
112  be updated in place to contain the results of plugin execution.
113  **kwargs
114  Any additional keyword arguments that may be passed to the plugin.
115  """
116  raise NotImplementedError()
117 
118 

◆ calculate() [2/2]

def lsst.meas.base.diaCalculationPlugins.WeightedMeanDiaPsFlux.calculate (   self,
  diaObjects,
  diaSources,
  filterDiaSources,
  filterName,
**  kwargs 
)
Compute the weighted mean and mean error of the point source flux.

Parameters
----------
diaObject : `dict`
    Summary object to store values in.
diaSources : `pandas.DataFrame`
    DataFrame representing all diaSources associated with this
    diaObject.
filterDiaSources : `pandas.DataFrame`
    DataFrame representing diaSources associated with this
    diaObject that are observed in the band pass ``filterName``.
filterName : `str`
    Simple, string name of the filter for the flux being calculated.
**kwargs
    Any additional keyword arguments that may be passed to the plugin.

Reimplemented from lsst.meas.base.diaCalculation.DiaObjectCalculationPlugin.

Definition at line 274 of file diaCalculationPlugins.py.

279  filterName,
280  **kwargs):
281  """Compute the weighted mean and mean error of the point source flux.
282 
283  Parameters
284  ----------
285  diaObject : `dict`
286  Summary object to store values in.
287  diaSources : `pandas.DataFrame`
288  DataFrame representing all diaSources associated with this
289  diaObject.
290  filterDiaSources : `pandas.DataFrame`
291  DataFrame representing diaSources associated with this
292  diaObject that are observed in the band pass ``filterName``.
293  filterName : `str`
294  Simple, string name of the filter for the flux being calculated.
295  **kwargs
296  Any additional keyword arguments that may be passed to the plugin.
297  """
298  meanName = "{}PSFluxMean".format(filterName)
299  errName = "{}PSFluxMeanErr".format(filterName)
300  nDataName = "{}PSFluxNdata".format(filterName)
301  if meanName not in diaObjects.columns:
302  diaObjects[meanName] = np.nan
303  if errName not in diaObjects.columns:
304  diaObjects[errName] = np.nan
305  if nDataName not in diaObjects.columns:
306  diaObjects[nDataName] = 0
307 
308  def _weightedMean(df):
309  tmpDf = df[~np.logical_or(np.isnan(df["psFlux"]),
310  np.isnan(df["psFluxErr"]))]
311  tot_weight = np.nansum(1 / tmpDf["psFluxErr"] ** 2)
312  fluxMean = np.nansum(tmpDf["psFlux"]
313  / tmpDf["psFluxErr"] ** 2)
314  fluxMean /= tot_weight
315  if tot_weight > 0:
316  fluxMeanErr = np.sqrt(1 / tot_weight)
317  else:
318  fluxMeanErr = np.nan
319  nFluxData = len(tmpDf)
320 
321  return pd.Series({meanName: fluxMean,
322  errName: fluxMeanErr,
323  nDataName: nFluxData},
324  dtype="object")
325 
326  diaObjects.loc[:, [meanName, errName, nDataName]] = \
327  filterDiaSources.apply(_weightedMean)
328 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ fail() [1/2]

def lsst.meas.base.diaCalculation.DiaObjectCalculationPlugin.fail (   self,
  diaObject,
  columns,
  error = None 
)
inherited
Set diaObject position values to nan.

Parameters
----------
diaObject : `dict`
    Summary object to store values in.
columns : `list` of `str`
    List of string names of columns to write a the failed value.
error : `BaseException` or `None`
    Error to pass. Kept for consistency with CatologCalculationPlugin.
    Unused.

Definition at line 140 of file diaCalculation.py.

140  def fail(self, diaObject, columns, error=None):
141  """Set diaObject position values to nan.
142 
143  Parameters
144  ----------
145  diaObject : `dict`
146  Summary object to store values in.
147  columns : `list` of `str`
148  List of string names of columns to write a the failed value.
149  error : `BaseException` or `None`
150  Error to pass. Kept for consistency with CatologCalculationPlugin.
151  Unused.
152  """
153  for colName in columns:
154  diaObject[colName] = np.nan
155 
156 

◆ fail() [2/2]

def lsst.meas.base.pluginsBase.BasePlugin.fail (   self,
  measRecord,
  error = None 
)
inherited
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 in lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxForcedPlugin, lsst.meas.modelfit.psf.psfContinued.GeneralShapeletPsfApproxSingleFramePlugin, lsst.meas.modelfit.cmodel.cmodelContinued.CModelForcedPlugin, lsst.meas.modelfit.cmodel.cmodelContinued.CModelSingleFramePlugin, lsst.meas.extensions.trailedSources.VeresPlugin.SingleFrameVeresTrailPlugin, lsst.meas.extensions.trailedSources.NaivePlugin.SingleFrameNaiveTrailPlugin, lsst.meas.base.wrappers.GenericPlugin, lsst.meas.base.wrappers.WrappedForcedPlugin, lsst.meas.base.wrappers.WrappedSingleFramePlugin, lsst.meas.base.plugins.SingleFrameSkyCoordPlugin, lsst.meas.base.plugins.SingleFramePeakCentroidPlugin, lsst.meas.base.plugins.InputCountPlugin, lsst.meas.base.plugins.VariancePlugin, lsst.meas.base.plugins.SingleFrameJacobianPlugin, lsst.meas.base.plugins.SingleFrameFPPositionPlugin, lsst.meas.base.footprintArea.CatalogCalculationFootprintAreaPlugin, lsst.meas.base.classification.CatalogCalculationClassificationPlugin, and lsst.ip.diffim.dipoleMeasurement.ClassificationDipolePlugin.

Definition at line 137 of file pluginsBase.py.

137  def fail(self, measRecord, error=None):
138  """Record a failure of the `measure` or `measureN` method.
139 
140  Parameters
141  ----------
142  measRecord : `lsst.afw.table.SourceRecord`
143  Table record describing the source being measured.
144  error : `MeasurementError`, optional
145  Only provided if the measurement failed due to a
146  `MeasurementError` being raised; otherwise, will be `None`.
147 
148  Notes
149  -----
150  When the plugin raises an exception, framework will call
151  `BasePlugin.fail` to allow the plugin to set its failure flag
152  field(s). When `BasePlugin.measureN` raises an exception,
153  `BasePlugin.fail` will be called repeatedly with all the records that
154  were being measured.
155 
156  If the exception is an `MeasurementError`, it will be passed as the
157  error argument; in all other cases the error argument will be `None`,
158  and the failure will be logged by the measurement framework as a
159  warning.
160 
161  """
162  traceback.print_exc()
163  message = ("The algorithm '%s' thinks it cannot fail, but it did; "
164  "please report this as a bug (the full traceback is above)."
165  % (self.__class__.__name__,))
166  raise NotImplementedError(message)
167 

◆ getExecutionOrder()

def lsst.meas.base.diaCalculationPlugins.WeightedMeanDiaPsFlux.getExecutionOrder (   cls)
Used to set the relative order of plugin execution.

The values returned by `getExecutionOrder` are compared across all
plugins, and smaller numbers run first.

Notes
-----
`CatalogCalculationPlugin`\s must run with
`BasePlugin.DEFAULT_CATALOGCALCULATION` or higher.

All plugins must implement this method with an appropriate run level

Reimplemented from lsst.meas.base.catalogCalculation.CatalogCalculationPlugin.

Definition at line 270 of file diaCalculationPlugins.py.

270  def getExecutionOrder(cls):
271  return cls.DEFAULT_CATALOGCALCULATION
272 

◆ getLogName()

def lsst.meas.base.pluginsBase.BasePlugin.getLogName (   self)
inherited

Definition at line 134 of file pluginsBase.py.

134  def getLogName(self):
135  return self.logName
136 

◆ getTransformClass()

def lsst.meas.base.pluginsBase.BasePlugin.getTransformClass ( )
staticinherited
Get the measurement transformation appropriate to this plugin.

This returns a subclass of `transforms.MeasurementTransform`, which
may be instantiated with details of the algorithm configuration and
then called with information about calibration and WCS to convert from
raw measurement quantities to calibrated units. Calibrated data is
then provided in a separate output table.

Notes
-----
By default, we copy everything from the input to the output without
transformation.

Reimplemented in lsst.meas.base.plugins.ForcedPeakCentroidPlugin, and lsst.meas.base.plugins.SingleFramePeakCentroidPlugin.

Definition at line 169 of file pluginsBase.py.

169  def getTransformClass():
170  """Get the measurement transformation appropriate to this plugin.
171 
172  This returns a subclass of `transforms.MeasurementTransform`, which
173  may be instantiated with details of the algorithm configuration and
174  then called with information about calibration and WCS to convert from
175  raw measurement quantities to calibrated units. Calibrated data is
176  then provided in a separate output table.
177 
178  Notes
179  -----
180  By default, we copy everything from the input to the output without
181  transformation.
182  """
183  return PassThroughTransform

Member Data Documentation

◆ APCORR_ORDER

float lsst.meas.base.pluginsBase.BasePlugin.APCORR_ORDER = 3.0
staticinherited

Definition at line 98 of file pluginsBase.py.

◆ CENTROID_ORDER

float lsst.meas.base.pluginsBase.BasePlugin.CENTROID_ORDER = 0.0
staticinherited

Definition at line 72 of file pluginsBase.py.

◆ config

lsst.meas.base.pluginsBase.BasePlugin.config
inherited

Definition at line 130 of file pluginsBase.py.

◆ ConfigClass

lsst.meas.base.diaCalculationPlugins.WeightedMeanDiaPsFlux.ConfigClass = WeightedMeanDiaPsFluxConfig
static

Definition at line 264 of file diaCalculationPlugins.py.

◆ DEFAULT_CATALOGCALCULATION

float lsst.meas.base.pluginsBase.BasePlugin.DEFAULT_CATALOGCALCULATION = 4.0
staticinherited

Definition at line 108 of file pluginsBase.py.

◆ FLUX_MOMENTS_CALCULATED

float lsst.meas.base.diaCalculation.DiaObjectCalculationPlugin.FLUX_MOMENTS_CALCULATED = 5.0
staticinherited

Definition at line 69 of file diaCalculation.py.

◆ FLUX_ORDER

float lsst.meas.base.pluginsBase.BasePlugin.FLUX_ORDER = 2.0
staticinherited

Definition at line 89 of file pluginsBase.py.

◆ inputCols

list lsst.meas.base.diaCalculation.DiaObjectCalculationPlugin.inputCols = []
staticinherited

Definition at line 82 of file diaCalculation.py.

◆ logName

lsst.meas.base.pluginsBase.BasePlugin.logName
inherited

Definition at line 132 of file pluginsBase.py.

◆ name

lsst.meas.base.pluginsBase.BasePlugin.name
inherited

Definition at line 131 of file pluginsBase.py.

◆ needsFilter

bool lsst.meas.base.diaCalculationPlugins.WeightedMeanDiaPsFlux.needsFilter = True
static

Definition at line 267 of file diaCalculationPlugins.py.

◆ outputCols

list lsst.meas.base.diaCalculationPlugins.WeightedMeanDiaPsFlux.outputCols = ["PSFluxMean", "PSFluxMeanErr", "PSFluxNdata"]
static

Definition at line 265 of file diaCalculationPlugins.py.

◆ plugType

string lsst.meas.base.diaCalculationPlugins.WeightedMeanDiaPsFlux.plugType = "multi"
static

Definition at line 266 of file diaCalculationPlugins.py.

◆ registry

lsst.meas.base.diaCalculation.DiaObjectCalculationPlugin.registry = PluginRegistry(DiaObjectCalculationPluginConfig)
staticinherited

Definition at line 65 of file diaCalculation.py.

◆ SHAPE_ORDER

float lsst.meas.base.pluginsBase.BasePlugin.SHAPE_ORDER = 1.0
staticinherited

Definition at line 80 of file pluginsBase.py.


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