LSST Applications 29.1.0,g0fba68d861+6b120c4394,g123d84c11c+8c5ae1fdc5,g1ec0fe41b4+191117f6ec,g1fd858c14a+c8450ae71a,g3533f9d6cb+a04f9ee0ab,g35bb328faa+8c5ae1fdc5,g3f0dcc2b1b+7df08700bd,g4178042926+b4254969db,g44ba364a48+04455b336b,g53246c7159+8c5ae1fdc5,g60b5630c4e+a04f9ee0ab,g663da51e9b+b05e6e1875,g67b6fd64d1+250bf6acd3,g78460c75b0+7e33a9eb6d,g786e29fd12+668abc6043,g8352419a5c+8c5ae1fdc5,g87e3079a85+d3fa38de54,g8852436030+cd899e2626,g89139ef638+250bf6acd3,g93a033419f+31ead11197,g989de1cb63+250bf6acd3,g9f33ca652e+f6053ecf14,ga1e959baac+5fbc491aed,ga2f891cd6c+a04f9ee0ab,gabe3b4be73+8856018cbb,gabf8522325+1f7e6d67b9,gac2eed3f23+250bf6acd3,gb1101e3267+0c331e9486,gb89ab40317+250bf6acd3,gcf25f946ba+cd899e2626,gd107969129+8964d67276,gd6cbbdb0b4+6bbecc8878,gde0f65d7ad+d65f9e019a,ge278dab8ac+eb3bbeb12f,ge410e46f29+250bf6acd3,gf5e32f922b+8c5ae1fdc5,gff02db199a+747430a128,gffe7e49bb4+a04f9ee0ab
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.meas.algorithms.sourceSelector.CullFromMaskedRegion Class Reference
Inheritance diagram for lsst.meas.algorithms.sourceSelector.CullFromMaskedRegion:

Public Member Functions

 apply (self, catalog, exposure)
 

Static Public Attributes

 badMaskNames
 
 xColName
 
 yColName
 

Detailed Description

Deselect sources that lie in a "bad" mask plane.

This will select against objects whose image coordinates lie in a region
with any of the mask bits in the `badMaskNames` list set. Namely used for
a reference catalog for which the flag columns we would get from the
measurement plugins do not exist.

NOTE: In the context of reference objects, it is recommended NOT to include
EDGE in the `badMaskNames` list as that will remove all the reference objects
outside the detector but within the pixelMargin (thus nulling the pixelMargin
padding all together!)

Definition at line 565 of file sourceSelector.py.

Member Function Documentation

◆ apply()

lsst.meas.algorithms.sourceSelector.CullFromMaskedRegion.apply ( self,
catalog,
exposure )
Apply the mask plane requirements to a catalog.

Returns whether the sources were selected.

Parameters
----------
catalog : `lsst.afw.table.SourceCatalog` or `pandas.DataFrame`
          or `astropy.table.Table`
    Catalog of sources to which the requirements will be applied.
exposure : `lsst.afw.image.Exposure` or None
    The exposure whose mask plane is to be respected.


Returns
-------
selected : `numpy.ndarray`
    Boolean array indicating for each source whether it is selected
    (True means selected).

Raises
------
RuntimeError
    Raised if exposure passed is `None`.

Definition at line 594 of file sourceSelector.py.

594 def apply(self, catalog, exposure):
595 """Apply the mask plane requirements to a catalog.
596
597 Returns whether the sources were selected.
598
599 Parameters
600 ----------
601 catalog : `lsst.afw.table.SourceCatalog` or `pandas.DataFrame`
602 or `astropy.table.Table`
603 Catalog of sources to which the requirements will be applied.
604 exposure : `lsst.afw.image.Exposure` or None
605 The exposure whose mask plane is to be respected.
606
607
608 Returns
609 -------
610 selected : `numpy.ndarray`
611 Boolean array indicating for each source whether it is selected
612 (True means selected).
613
614 Raises
615 ------
616 RuntimeError
617 Raised if exposure passed is `None`.
618 """
619 if exposure is None:
620 raise RuntimeError("Must provide an exposure to CullFromMaskedRegion selection.")
621 xRefList = catalog[self.xColName]
622 yRefList = catalog[self.yColName]
623 # Convert x, y coords to integers to map to indices in mask plane.
624 # If reference object nominally lies outside the exposure, consider
625 # it to be at the edge (and thus obeys those mask planes).
626 x0, y0 = exposure.getXY0()
627 xMax, yMax = exposure.getDimensions()
628 xRefList = [int(min(max(0, xRef - x0), xMax - 1)) for xRef in xRefList]
629 yRefList = [int(min(max(0, yRef - y0), yMax - 1)) for yRef in yRefList]
630 badMaskNames = []
631 maskPlaneDict = exposure.getMask().getMaskPlaneDict()
632 for badName in self.badMaskNames:
633 if badName in maskPlaneDict:
634 badMaskNames.append(badName)
635 bitmask = exposure.mask.getPlaneBitMask(badMaskNames)
636 toKeep = ((exposure.mask.array & bitmask) == 0)
637 selected = toKeep[yRefList, xRefList] # x & y flipped for numpy arrays
638
639 return selected
640
641

Member Data Documentation

◆ badMaskNames

lsst.meas.algorithms.sourceSelector.CullFromMaskedRegion.badMaskNames
static
Initial value:
= pexConfig.ListField(
dtype=str,
default=["NO_DATA", "NOT_DEBLENDED"],
doc="List of mask planes for which sources should be removed if a bit is set.",
)

Definition at line 578 of file sourceSelector.py.

◆ xColName

lsst.meas.algorithms.sourceSelector.CullFromMaskedRegion.xColName
static
Initial value:
= pexConfig.Field(
dtype=str,
default="centroid_x",
doc="Name of column for image x coordinate."
)

Definition at line 583 of file sourceSelector.py.

◆ yColName

lsst.meas.algorithms.sourceSelector.CullFromMaskedRegion.yColName
static
Initial value:
= pexConfig.Field(
dtype=str,
default="centroid_y",
doc="Name of column for image y coordinate."
)

Definition at line 588 of file sourceSelector.py.


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