LSST Applications g0265f82a02+c6dfa2ddaf,g1162b98a3f+b2075782a9,g2079a07aa2+1b2e822518,g2bbee38e9b+c6dfa2ddaf,g337abbeb29+c6dfa2ddaf,g3ddfee87b4+a60788ef87,g50ff169b8f+2eb0e556e8,g52b1c1532d+90ebb246c7,g555ede804d+a60788ef87,g591dd9f2cf+ba8caea58f,g5ec818987f+864ee9cddb,g858d7b2824+9ee1ab4172,g876c692160+a40945ebb7,g8a8a8dda67+90ebb246c7,g8cdfe0ae6a+4fd9e222a8,g99cad8db69+5e309b7bc6,g9ddcbc5298+a1346535a5,ga1e77700b3+df8f93165b,ga8c6da7877+aa12a14d27,gae46bcf261+c6dfa2ddaf,gb0e22166c9+8634eb87fb,gb3f2274832+d0da15e3be,gba4ed39666+1ac82b564f,gbb8dafda3b+5dfd9c994b,gbeb006f7da+97157f9740,gc28159a63d+c6dfa2ddaf,gc86a011abf+9ee1ab4172,gcf0d15dbbd+a60788ef87,gdaeeff99f8+1cafcb7cd4,gdc0c513512+9ee1ab4172,ge79ae78c31+c6dfa2ddaf,geb67518f79+ba1859f325,geb961e4c1e+f9439d1e6f,gee10cc3b42+90ebb246c7,gf1cff7945b+9ee1ab4172,w.2024.12
LSST Data Management Base Package
Loading...
Searching...
No Matches
Classes | Functions
lsst.meas.algorithms.skyObjects Namespace Reference

Classes

class  SkyObjectsConfig
 
class  SkyObjectsTask
 

Functions

 generateSkyObjects (mask, seed, config)
 

Function Documentation

◆ generateSkyObjects()

lsst.meas.algorithms.skyObjects.generateSkyObjects ( mask,
seed,
config )
Generate a list of Footprints of sky objects

Sky objects don't overlap with other objects. This is determined
through the provided `mask` (in which objects are typically flagged
as `DETECTED`).

Sky objects are positioned using a quasi-random Halton sequence number
generator. This is a deterministic sequence that mimics a random trial and
error approach whilst acting to minimize clustering of points for a given
field of view. Up to `nTrialSources` points are generated, returning the
first `nSources` that do not overlap with the mask.

Parameters
----------
mask : `lsst.afw.image.Mask`
    Input mask plane, which identifies pixels to avoid for the sky
    objects.
seed : `int`
    Random number generator seed.
config : `SkyObjectsConfig`
    Configuration for finding sky objects.

Returns
-------
skyFootprints : `list` of `lsst.afw.detection.Footprint`
    Footprints of sky objects. Each will have a peak at the center
    of the sky object.

Definition at line 71 of file skyObjects.py.

71def generateSkyObjects(mask, seed, config):
72 """Generate a list of Footprints of sky objects
73
74 Sky objects don't overlap with other objects. This is determined
75 through the provided `mask` (in which objects are typically flagged
76 as `DETECTED`).
77
78 Sky objects are positioned using a quasi-random Halton sequence number
79 generator. This is a deterministic sequence that mimics a random trial and
80 error approach whilst acting to minimize clustering of points for a given
81 field of view. Up to `nTrialSources` points are generated, returning the
82 first `nSources` that do not overlap with the mask.
83
84 Parameters
85 ----------
86 mask : `lsst.afw.image.Mask`
87 Input mask plane, which identifies pixels to avoid for the sky
88 objects.
89 seed : `int`
90 Random number generator seed.
91 config : `SkyObjectsConfig`
92 Configuration for finding sky objects.
93
94 Returns
95 -------
96 skyFootprints : `list` of `lsst.afw.detection.Footprint`
97 Footprints of sky objects. Each will have a peak at the center
98 of the sky object.
99 """
100 if config.nSources <= 0:
101 return []
102
103 skySourceRadius = config.sourceRadius
104 nSkySources = config.nSources
105 nTrialSkySources = config.nTrialSources
106 if nTrialSkySources is None:
107 nTrialSkySources = config.nTrialSourcesMultiplier*nSkySources
108
109 box = mask.getBBox()
110 box.grow(-(int(skySourceRadius) + 1)) # Avoid objects partially off the image
111 xMin, yMin = box.getMin()
112 xMax, yMax = box.getMax()
113
114 avoid = lsst.afw.geom.SpanSet.fromMask(mask, mask.getPlaneBitMask(config.avoidMask))
115 if config.growMask > 0:
116 avoid = avoid.dilated(config.growMask)
117
118 sampler = qmc.Halton(d=2, seed=seed).random(nTrialSkySources)
119 sample = qmc.scale(sampler, [xMin, yMin], [xMax, yMax])
120
121 skyFootprints = []
122 for x, y in zip(sample[:, 0].astype(int), sample[:, 1].astype(int)):
123 if len(skyFootprints) == nSkySources:
124 break
125
126 spans = lsst.afw.geom.SpanSet.fromShape(int(skySourceRadius), offset=(x, y))
127 if spans.overlaps(avoid):
128 continue
129
130 fp = lsst.afw.detection.Footprint(spans, mask.getBBox())
131 fp.addPeak(x, y, 0)
132 skyFootprints.append(fp)
133
134 # Add doubled-in-size sky object spanSet to the avoid mask.
135 avoid = avoid.union(spans.dilated(int(skySourceRadius)))
136
137 return skyFootprints
138
139
Class to describe the properties of a detected object from an image.
Definition Footprint.h:63
static std::shared_ptr< geom::SpanSet > fromMask(image::Mask< T > const &mask, UnaryPredicate comparator=details::AnyBitSetFunctor< T >())
Create a SpanSet from a mask.
Definition SpanSet.h:644
static std::shared_ptr< geom::SpanSet > fromShape(int r, Stencil s=Stencil::CIRCLE, lsst::geom::Point2I offset=lsst::geom::Point2I())
Factory function for creating SpanSets from a Stencil.
Definition SpanSet.cc:688