LSST Applications g0265f82a02+093ff98f47,g02d81e74bb+10352d6f39,g1f3e9fa97e+40b0fc677d,g2079a07aa2+14824f138e,g2bbee38e9b+093ff98f47,g337abbeb29+093ff98f47,g3ddfee87b4+064c02c7ee,g487adcacf7+7e842ebf4b,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g568d43a26c+1d7ac31cb0,g591dd9f2cf+fb1f69e2ea,g858d7b2824+10352d6f39,g8a8a8dda67+a6fc98d2e7,g8cdfe0ae6a+66d966b544,g99cad8db69+7ce8a7c20a,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga2e4dd1c03+064c02c7ee,ga8c6da7877+04f6ba86dc,gae46bcf261+093ff98f47,gb0e22166c9+3863383f4c,gba4ed39666+9664299f35,gbb8dafda3b+db40f59a7d,gbeb006f7da+e6a448e96d,gbf5cecdb8a+10352d6f39,gc0f3af6251+10a3fd39cd,gc120e1dc64+5839e50a77,gc28159a63d+093ff98f47,gcf0d15dbbd+064c02c7ee,gd2a12a3803+0c2c227a2b,gdaeeff99f8+a38ce5ea23,ge79ae78c31+093ff98f47,gee10cc3b42+a6fc98d2e7,gf1cff7945b+10352d6f39,w.2024.15
LSST Data Management Base Package
Loading...
Searching...
No Matches
Classes | Functions | Variables
lsst.scarlet.lite.detect Namespace Reference

Classes

class  Footprint
 

Functions

Box bounds_to_bbox (tuple[int, int, int, int] bounds)
 
Image footprints_to_image (Sequence[Footprint] footprints, tuple[int, int] shape)
 
np.ndarray get_wavelets (np.ndarray images, np.ndarray variance, int|None scales=None)
 
np.ndarray get_detect_wavelets (np.ndarray images, np.ndarray variance, int scales=3)
 

Variables

 logger = logging.getLogger("scarlet.detect")
 

Function Documentation

◆ bounds_to_bbox()

Box lsst.scarlet.lite.detect.bounds_to_bbox ( tuple[int, int, int, int] bounds)
Convert the bounds of a Footprint into a Box

Notes
-----
Unlike slices, the bounds are _inclusive_ of the end points.

Parameters
----------
bounds:
    The bounds of the `Footprint` as a `tuple` of
    ``(bottom, top, left, right)``.
Returns
-------
result:
    The `Box` created from the bounds

Definition at line 38 of file detect.py.

38def bounds_to_bbox(bounds: tuple[int, int, int, int]) -> Box:
39 """Convert the bounds of a Footprint into a Box
40
41 Notes
42 -----
43 Unlike slices, the bounds are _inclusive_ of the end points.
44
45 Parameters
46 ----------
47 bounds:
48 The bounds of the `Footprint` as a `tuple` of
49 ``(bottom, top, left, right)``.
50 Returns
51 -------
52 result:
53 The `Box` created from the bounds
54 """
55 return Box(
56 (bounds[1] + 1 - bounds[0], bounds[3] + 1 - bounds[2]),
57 origin=(bounds[0], bounds[2]),
58 )
59
60
61@continue_class

◆ footprints_to_image()

Image lsst.scarlet.lite.detect.footprints_to_image ( Sequence[Footprint] footprints,
tuple[int, int] shape )
Convert a set of scarlet footprints to a pixelized image.

Parameters
----------
footprints:
    The footprints to convert into an image.
shape:
    The shape of the image that is created from the footprints.

Returns
-------
result:
    The image created from the footprints.

Definition at line 114 of file detect.py.

114def footprints_to_image(footprints: Sequence[Footprint], shape: tuple[int, int]) -> Image:
115 """Convert a set of scarlet footprints to a pixelized image.
116
117 Parameters
118 ----------
119 footprints:
120 The footprints to convert into an image.
121 shape:
122 The shape of the image that is created from the footprints.
123
124 Returns
125 -------
126 result:
127 The image created from the footprints.
128 """
129 result = Image.from_box(Box(shape), dtype=int)
130 for k, footprint in enumerate(footprints):
131 bbox = bounds_to_bbox(footprint.bounds)
132 fp_image = Image(footprint.data, yx0=cast(tuple[int, int], bbox.origin))
133 result = result + fp_image * (k + 1)
134 return result
135
136

◆ get_detect_wavelets()

np.ndarray lsst.scarlet.lite.detect.get_detect_wavelets ( np.ndarray images,
np.ndarray variance,
int scales = 3 )
Get an array of wavelet coefficents to use for detection

Parameters
----------
images:
    The array of images with shape `(bands, Ny, Nx)` for which to
    calculate wavelet coefficients.
variance:
    An array of variances with the same shape as `images`.
scales:
    The maximum number of wavelet scales to use.
    Note that the result will have `scales+1` total arrays,
    where the last set of coefficients is the image of all
    flux with frequency greater than the last wavelet scale.

Returns
-------
starlets:
    The array of wavelet coefficients for pixels with siignificant
    amplitude in each scale.

Definition at line 175 of file detect.py.

175def get_detect_wavelets(images: np.ndarray, variance: np.ndarray, scales: int = 3) -> np.ndarray:
176 """Get an array of wavelet coefficents to use for detection
177
178 Parameters
179 ----------
180 images:
181 The array of images with shape `(bands, Ny, Nx)` for which to
182 calculate wavelet coefficients.
183 variance:
184 An array of variances with the same shape as `images`.
185 scales:
186 The maximum number of wavelet scales to use.
187 Note that the result will have `scales+1` total arrays,
188 where the last set of coefficients is the image of all
189 flux with frequency greater than the last wavelet scale.
190
191 Returns
192 -------
193 starlets:
194 The array of wavelet coefficients for pixels with siignificant
195 amplitude in each scale.
196 """
197 sigma = np.median(np.sqrt(variance))
198 # Create the wavelet coefficients for the significant pixels
199 detect = np.sum(images, axis=0)
200 _coeffs = starlet_transform(detect, scales=scales)
201 support = get_multiresolution_support(
202 image=detect,
203 starlets=_coeffs,
204 sigma=sigma, # type: ignore
205 sigma_scaling=3,
206 epsilon=1e-1,
207 max_iter=20,
208 )
209 return (support * _coeffs).astype(images.dtype)

◆ get_wavelets()

np.ndarray lsst.scarlet.lite.detect.get_wavelets ( np.ndarray images,
np.ndarray variance,
int | None scales = None )
Calculate wavelet coefficents given a set of images and their variances

Parameters
----------
images:
    The array of images with shape `(bands, Ny, Nx)` for which to
    calculate wavelet coefficients.
variance:
    An array of variances with the same shape as `images`.
scales:
    The maximum number of wavelet scales to use.

Returns
-------
coeffs:
    The array of coefficents with shape `(scales+1, bands, Ny, Nx)`.
    Note that the result has `scales+1` total arrays,
    since the last set of coefficients is the image of all
    flux with frequency greater than the last wavelet scale.

Definition at line 137 of file detect.py.

137def get_wavelets(images: np.ndarray, variance: np.ndarray, scales: int | None = None) -> np.ndarray:
138 """Calculate wavelet coefficents given a set of images and their variances
139
140 Parameters
141 ----------
142 images:
143 The array of images with shape `(bands, Ny, Nx)` for which to
144 calculate wavelet coefficients.
145 variance:
146 An array of variances with the same shape as `images`.
147 scales:
148 The maximum number of wavelet scales to use.
149
150 Returns
151 -------
152 coeffs:
153 The array of coefficents with shape `(scales+1, bands, Ny, Nx)`.
154 Note that the result has `scales+1` total arrays,
155 since the last set of coefficients is the image of all
156 flux with frequency greater than the last wavelet scale.
157 """
158 sigma = np.median(np.sqrt(variance), axis=(1, 2))
159 # Create the wavelet coefficients for the significant pixels
160 coeffs = []
161 for b, image in enumerate(images):
162 _coeffs = starlet_transform(image, scales=scales)
163 support = get_multiresolution_support(
164 image=image,
165 starlets=_coeffs,
166 sigma=sigma[b],
167 sigma_scaling=3,
168 epsilon=1e-1,
169 max_iter=20,
170 )
171 coeffs.append((support * _coeffs).astype(images.dtype))
172 return np.array(coeffs)
173
174

Variable Documentation

◆ logger

lsst.scarlet.lite.detect.logger = logging.getLogger("scarlet.detect")

Definition at line 35 of file detect.py.