LSST Applications g0603fd7c41+501e3db9f9,g0aad566f14+23d8574c86,g0dd44d6229+a1a4c8b791,g2079a07aa2+86d27d4dc4,g2305ad1205+a62672bbc1,g2bbee38e9b+047b288a59,g337abbeb29+047b288a59,g33d1c0ed96+047b288a59,g3a166c0a6a+047b288a59,g3d1719c13e+23d8574c86,g487adcacf7+cb7fd919b2,g4be5004598+23d8574c86,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+4a9e435310,g63cd9335cc+585e252eca,g858d7b2824+23d8574c86,g88963caddf+0cb8e002cc,g99cad8db69+43388bcaec,g9ddcbc5298+9a081db1e4,ga1e77700b3+a912195c07,gae0086650b+585e252eca,gb0e22166c9+60f28cb32d,gb2522980b2+793639e996,gb3a676b8dc+b4feba26a1,gb4b16eec92+63f8520565,gba4ed39666+c2a2e4ac27,gbb8dafda3b+a5d255a82e,gc120e1dc64+d820f8acdb,gc28159a63d+047b288a59,gc3e9b769f7+f4f1cc6b50,gcf0d15dbbd+a1a4c8b791,gdaeeff99f8+f9a426f77a,gdb0af172c8+b6d5496702,ge79ae78c31+047b288a59,w.2024.19
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
lsst.scarlet.lite.initialization.FactorizedChi2Initialization Class Reference
Inheritance diagram for lsst.scarlet.lite.initialization.FactorizedChi2Initialization:
lsst.scarlet.lite.initialization.FactorizedInitialization

Public Member Functions

 __init__ (self, Observation observation, Sequence[tuple[int, int]] centers, np.ndarray|None detect=None, float min_snr=50, Monotonicity|None monotonicity=None, float disk_percentile=25, float thresh=0.5, int padding=2)
 
Source|None init_source (self, tuple[int, int] center)
 

Public Attributes

 detect
 
 disk_percentile
 
 thresh
 
 padding
 
 observation
 

Detailed Description

Initialize all sources with chi^2 detections

There are a large number of parameters that are universal for all of the
sources being initialized from the same set of observed images.
To simplify the API those parameters are all initialized by this class
and passed to `init_main_source` for each source.
It also creates temporary objects that only need to be created once for
all of the sources in a blend.

Parameters
----------
observation:
    The observation containing the blend
centers:
    The center of each source to initialize.
detect:
    The array that contains a 2D image used for detection.
min_snr:
    The minimum SNR required per component.
    So a 2-component source requires at least `2*min_snr` while sources
    with SNR < `min_snr` will be initialized with the PSF.
monotonicity:
    When `monotonicity` is `None`,
    the component is initialized with only the
    monotonic pixels, otherwise the monotonicity operator is used to
    project the morphology to a monotonic solution.
disk_percentile:
    The percentage of the overall flux to attribute to the disk.
thresh:
    The threshold used to trim the morphology,
    so all pixels below `thresh * bg_rms` are set to zero.
padding:
    The amount to pad the morphology to allow for extra flux
    in the first few iterations before resizing.

Definition at line 399 of file initialization.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.scarlet.lite.initialization.FactorizedChi2Initialization.__init__ ( self,
Observation observation,
Sequence[tuple[int, int]] centers,
np.ndarray | None detect = None,
float min_snr = 50,
Monotonicity | None monotonicity = None,
float disk_percentile = 25,
float thresh = 0.5,
int padding = 2 )

Reimplemented from lsst.scarlet.lite.initialization.FactorizedInitialization.

Definition at line 436 of file initialization.py.

446 ):
447 if detect is None:
448 # Build the morphology detection image
449 detect = np.sum(
450 observation.images.data / (observation.noise_rms**2)[:, None, None],
451 axis=0,
452 )
453 self.detect = detect
454 _detect = Image(detect)
455 # Convolve the detection image.
456 # This may seem counter-intuitive,
457 # since this is effectively growing the model,
458 # but this is exactly what convolution will do to the model
459 # in each iteration.
460 # So we create the convolved model in order
461 # to correctly set the spectrum.
462 convolved = observation.convolve(_detect.repeat(observation.bands), mode="real")
463
464 # Set the input parameters
465 self.disk_percentile = disk_percentile
466 self.thresh = thresh
467 self.padding = padding
468
469 # Initialize the sources
470 super().__init__(observation, convolved, centers, min_snr, monotonicity)
471

Member Function Documentation

◆ init_source()

Source | None lsst.scarlet.lite.initialization.FactorizedChi2Initialization.init_source ( self,
tuple[int, int] center )
Initialize a source from a chi^2 detection.

Parameter
---------
center:
    The center of the source.
init:
    The initialization parameters common to all of the sources.
max_components:
    The maximum number of components in the source.

Reimplemented from lsst.scarlet.lite.initialization.FactorizedInitialization.

Definition at line 472 of file initialization.py.

472 def init_source(self, center: tuple[int, int]) -> Source | None:
473 """Initialize a source from a chi^2 detection.
474
475 Parameter
476 ---------
477 center:
478 The center of the source.
479 init:
480 The initialization parameters common to all of the sources.
481 max_components:
482 The maximum number of components in the source.
483 """
484 # Some operators need the local center, not center in the full image
485 local_center = (
486 center[0] - self.observation.bbox.origin[0],
487 center[1] - self.observation.bbox.origin[1],
488 )
489
490 # Calculate the signal to noise at the center of this source
491 component_snr = self.get_snr(center)
492
493 # Initialize the bbox, morph, and spectrum
494 # for a single component source
495 detect = prox_uncentered_symmetry(self.detect.copy(), local_center, fill=0)
496 thresh = np.mean(self.observation.noise_rms) * self.thresh
497 component = self.get_single_component(center, detect, thresh, self.padding)
498
499 if component is None:
500 components = [self.get_psf_component(center)]
501 elif component_snr < 2:
502 components = [component]
503 else:
504 # There was enough flux for a 2-component source,
505 # so split the single component model into two components,
506 # using the same algorithm as scarlet main.
507 bulge_morph = component.morph.copy()
508 disk_morph = component.morph
509 # Set the threshold for the bulge.
510 # Since the morphology is monotonic, this selects the inner
511 # of the single component morphology and assigns it to the bulge.
512 flux_thresh = self.disk_percentile / 100
513 mask = disk_morph > flux_thresh
514 # Remove the flux above the threshold so that the disk will have
515 # a flat center.
516 disk_morph[mask] = flux_thresh
517 # Subtract off the thresholded flux (since we're normalizing the
518 # morphology anyway) so that it does not have a sharp
519 # discontinuity at the edge.
520 bulge_morph -= flux_thresh
521 bulge_morph[bulge_morph < 0] = 0
522
523 bulge_morph /= np.max(bulge_morph)
524 disk_morph /= np.max(disk_morph)
525
526 # Fit the spectra assuming that all of the flux in the image
527 # is due to both components. This is not true, but for the
528 # vast majority of sources this is a good approximation.
529 bulge_spectrum, disk_spectrum = multifit_spectra(
530 self.observation,
531 [
532 Image(bulge_morph, yx0=cast(tuple[int, int], component.bbox.origin)),
533 Image(disk_morph, yx0=cast(tuple[int, int], component.bbox.origin)),
534 ],
535 )
536
537 components = [
538 FactorizedComponent(
539 self.observation.bands,
540 bulge_spectrum,
541 bulge_morph,
542 component.bbox.copy(),
543 center,
544 self.observation.noise_rms,
545 monotonicity=self.monotonicity,
546 ),
547 FactorizedComponent(
548 self.observation.bands,
549 disk_spectrum,
550 disk_morph,
551 component.bbox.copy(),
552 center,
553 self.observation.noise_rms,
554 monotonicity=self.monotonicity,
555 ),
556 ]
557
558 return Source(components) # type: ignore
559
560

Member Data Documentation

◆ detect

lsst.scarlet.lite.initialization.FactorizedChi2Initialization.detect

Definition at line 453 of file initialization.py.

◆ disk_percentile

lsst.scarlet.lite.initialization.FactorizedChi2Initialization.disk_percentile

Definition at line 465 of file initialization.py.

◆ observation

lsst.scarlet.lite.initialization.FactorizedChi2Initialization.observation

Definition at line 530 of file initialization.py.

◆ padding

lsst.scarlet.lite.initialization.FactorizedChi2Initialization.padding

Definition at line 467 of file initialization.py.

◆ thresh

lsst.scarlet.lite.initialization.FactorizedChi2Initialization.thresh

Definition at line 466 of file initialization.py.


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