LSST Applications g00274db5b6+edbf708997,g00d0e8bbd7+edbf708997,g199a45376c+5137f08352,g1fd858c14a+1d4b6db739,g262e1987ae+f4d9505c4f,g29ae962dfc+7156fb1a53,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3e17d7035e+5b3adc59f5,g3fd5ace14f+852fa6fbcb,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+9f17e571f4,g67b6fd64d1+6dc8069a4c,g74acd417e5+ae494d68d9,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+536efcc10a,g7cc15d900a+d121454f8d,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d7436a09f+28c28d8d6d,g8ea07a8fe4+db21c37724,g92c671f44c+9f17e571f4,g98df359435+b2e6376b13,g99af87f6a8+b0f4ad7b8d,gac66b60396+966efe6077,gb88ae4c679+7dec8f19df,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gc24b5d6ed1+9f17e571f4,gca7fc764a6+6dc8069a4c,gcc769fe2a4+97d0256649,gd7ef33dd92+6dc8069a4c,gdab6d2f7ff+ae494d68d9,gdbb4c4dda9+9f17e571f4,ge410e46f29+6dc8069a4c,geaed405ab2+e194be0d2b,w.2025.47
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 566 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 595 of file sourceSelector.py.

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

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 579 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 584 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 589 of file sourceSelector.py.


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