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.scarlet.lite.models.parametric.ParametricComponent Class Reference
Inheritance diagram for lsst.scarlet.lite.models.parametric.ParametricComponent:
lsst.scarlet.lite.component.Component lsst.scarlet.lite.models.parametric.EllipticalParametricComponent

Public Member Functions

 __init__ (self, tuple bands, Box bbox, Parameter|np.ndarray spectrum, Parameter|np.ndarray morph_params, Callable morph_func, Callable morph_grad, Callable morph_prox, Callable|np.ndarray morph_step, Callable|None prox_spectrum=None, float floor=1e-20)
 
tuple[float, float] peak (self)
 
float y0 (self)
 
float x0 (self)
 
np.ndarray spectrum (self)
 
CartesianFrame frame (self)
 
np.ndarray radial_params (self)
 
np.ndarray morph (self, CartesianFrame|None frame=None)
 
Callable prox_morph (self)
 
Callable grad_morph (self)
 
Callable morph_step (self)
 
Image get_model (self, CartesianFrame|None frame=None)
 
np.ndarray prox_spectrum (self, np.ndarray spectrum)
 
np.ndarray grad_spectrum (self, np.ndarray input_grad, np.ndarray spectrum, np.ndarray morph)
 
 update (self, int it, np.ndarray input_grad)
 
bool resize (self, Box model_box)
 
None parameterize (self, Callable parameterization)
 
ScarletComponentBaseData to_data (self)
 
Box bbox (self)
 
tuple bands (self)
 

Public Attributes

 floor = floor
 
 y0
 
 radial_params
 
 frame
 

Protected Member Functions

np.ndarray _get_morph (self, CartesianFrame|None frame=None)
 

Protected Attributes

 _spectrum = parameter(spectrum)
 
 _params = parameter(morph_params)
 
 _func = morph_func
 
 _morph_grad = morph_grad
 
 _morph_prox = morph_prox
 
Callable _morph_step = morph_step
 
Callable _prox_spectrum = self.prox_spectrum
 
tuple _bands = bands
 
Box _bbox = bbox
 

Detailed Description

A parametric model of an astrophysical source

Parameters
----------
bands:
    The bands used in the model.
bbox:
    The bounding box that holds the model.
spectrum:
    The spectrum of the component.
morph_params:
    The parameters of the morphology.
morph_func:
    The function to generate the 2D morphology image
    based on `morphParams`.
morph_grad:
    The function to calculate the gradient of the
    likelihood wrt the morphological parameters.
morph_prox:
    The proximal operator for the morphology parameters.
morph_step:
    The function that calculates the gradient of the
    morphological model.
prox_spectrum:
    Proximal operator for the spectrum.
    If `prox_spectrum` is `None` then the default proximal
    operator `self.prox_spectrum` is used.
floor:
    The minimum value of the spectrum, used to prevent
    divergences in the gradients.

Definition at line 636 of file parametric.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.scarlet.lite.models.parametric.ParametricComponent.__init__ ( self,
tuple bands,
Box bbox,
Parameter | np.ndarray spectrum,
Parameter | np.ndarray morph_params,
Callable morph_func,
Callable morph_grad,
Callable morph_prox,
Callable | np.ndarray morph_step,
Callable | None prox_spectrum = None,
float floor = 1e-20 )

Definition at line 669 of file parametric.py.

681 ):
682 super().__init__(bands=bands, bbox=bbox)
683
684 self._spectrum = parameter(spectrum)
685 self._params = parameter(morph_params)
686 self._func = morph_func
687 self._morph_grad = morph_grad
688 self._morph_prox = morph_prox
689 self._morph_step = morph_step
690 self._bbox = bbox
691 if prox_spectrum is None:
692 self._prox_spectrum: Callable = self.prox_spectrum
693 else:
694 self._prox_spectrum = prox_spectrum
695 self.floor = floor
696

Member Function Documentation

◆ _get_morph()

np.ndarray lsst.scarlet.lite.models.parametric.ParametricComponent._get_morph ( self,
CartesianFrame | None frame = None )
protected
The 2D image of the morphology

This callable generates an image of the morphology
in the given frame.

Parameters
----------
frame:
    The frame (bounding box, pixel grid) that the image is
    placed in.

Returns
-------
result:
    The image of the morphology in the `frame`.

Definition at line 727 of file parametric.py.

727 def _get_morph(self, frame: CartesianFrame | None = None) -> np.ndarray:
728 """The 2D image of the morphology
729
730 This callable generates an image of the morphology
731 in the given frame.
732
733 Parameters
734 ----------
735 frame:
736 The frame (bounding box, pixel grid) that the image is
737 placed in.
738
739 Returns
740 -------
741 result:
742 The image of the morphology in the `frame`.
743 """
744 if frame is None:
745 frame = self.frame
746 return self._func(self.radial_params, frame)
747

◆ bands()

tuple lsst.scarlet.lite.component.Component.bands ( self)
inherited
The bands in the component model

Definition at line 71 of file component.py.

71 def bands(self) -> tuple:
72 """The bands in the component model"""
73 return self._bands
74

◆ bbox()

Box lsst.scarlet.lite.component.Component.bbox ( self)
inherited
The bounding box that contains the component in the full image

Definition at line 66 of file component.py.

66 def bbox(self) -> Box:
67 """The bounding box that contains the component in the full image"""
68 return self._bbox
69

◆ frame()

CartesianFrame lsst.scarlet.lite.models.parametric.ParametricComponent.frame ( self)
The coordinate system that contains the model

Reimplemented in lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.

Definition at line 718 of file parametric.py.

718 def frame(self) -> CartesianFrame:
719 """The coordinate system that contains the model"""
720 return CartesianFrame(self._bbox)
721

◆ get_model()

Image lsst.scarlet.lite.models.parametric.ParametricComponent.get_model ( self,
CartesianFrame | None frame = None )
Generate the full model for this component

Reimplemented from lsst.scarlet.lite.component.Component.

Definition at line 772 of file parametric.py.

772 def get_model(self, frame: CartesianFrame | None = None) -> Image:
773 """Generate the full model for this component"""
774 model = self.spectrum[:, None, None] * self._get_morph(frame)[None, :, :]
775 return Image(model, bands=self.bands, yx0=cast(tuple[int, int], self.bbox.origin[-2:]))
776

◆ grad_morph()

Callable lsst.scarlet.lite.models.parametric.ParametricComponent.grad_morph ( self)
The function that calculates the gradient of the
morphological model

Definition at line 759 of file parametric.py.

759 def grad_morph(self) -> Callable:
760 """The function that calculates the gradient of the
761 morphological model
762 """
763 return self._morph_grad
764

◆ grad_spectrum()

np.ndarray lsst.scarlet.lite.models.parametric.ParametricComponent.grad_spectrum ( self,
np.ndarray input_grad,
np.ndarray spectrum,
np.ndarray morph )
Gradient of the spectrum wrt. the component model

Parameters
----------
input_grad:
    Gradient of the likelihood wrt the component model
spectrum:
    The model of the spectrum.
morph:
    The model of the morphology.

Returns
-------
result:
    The gradient of the likelihood wrt. the spectrum.

Definition at line 789 of file parametric.py.

789 def grad_spectrum(self, input_grad: np.ndarray, spectrum: np.ndarray, morph: np.ndarray) -> np.ndarray:
790 """Gradient of the spectrum wrt. the component model
791
792 Parameters
793 ----------
794 input_grad:
795 Gradient of the likelihood wrt the component model
796 spectrum:
797 The model of the spectrum.
798 morph:
799 The model of the morphology.
800
801 Returns
802 -------
803 result:
804 The gradient of the likelihood wrt. the spectrum.
805 """
806 return np.einsum("...jk,jk", input_grad, morph)
807

◆ morph()

np.ndarray lsst.scarlet.lite.models.parametric.ParametricComponent.morph ( self,
CartesianFrame | None frame = None )
The morphological model

Definition at line 749 of file parametric.py.

749 def morph(self, frame: CartesianFrame | None = None) -> np.ndarray:
750 """The morphological model"""
751 return self._get_morph(frame)
752

◆ morph_step()

Callable lsst.scarlet.lite.models.parametric.ParametricComponent.morph_step ( self)
The function that calculates the gradient of the
morphological model

Definition at line 766 of file parametric.py.

766 def morph_step(self) -> Callable:
767 """The function that calculates the gradient of the
768 morphological model
769 """
770 return cast(Callable, self._morph_step)
771

◆ parameterize()

None lsst.scarlet.lite.models.parametric.ParametricComponent.parameterize ( self,
Callable parameterization )
Convert the component parameter arrays into Parameter instances

Reimplemented from lsst.scarlet.lite.component.Component.

Definition at line 832 of file parametric.py.

832 def parameterize(self, parameterization: Callable) -> None:
833 """Convert the component parameter arrays into Parameter instances"""
834 # Update the spectrum and morph in place
835 parameterization(self)
836 # update the parameters
837 self._spectrum.grad = self.grad_spectrum
838 self._spectrum.prox = self.prox_spectrum
839 self._params.grad = self.grad_morph
840 self._params.prox = self.prox_morph
841

◆ peak()

tuple[float, float] lsst.scarlet.lite.models.parametric.ParametricComponent.peak ( self)
The center of the component

Definition at line 698 of file parametric.py.

698 def peak(self) -> tuple[float, float]:
699 """The center of the component"""
700 return self.y0, self.x0
701

◆ prox_morph()

Callable lsst.scarlet.lite.models.parametric.ParametricComponent.prox_morph ( self)
The function used to constrain the morphological model

Definition at line 754 of file parametric.py.

754 def prox_morph(self) -> Callable:
755 """The function used to constrain the morphological model"""
756 return self._morph_prox
757

◆ prox_spectrum()

np.ndarray lsst.scarlet.lite.models.parametric.ParametricComponent.prox_spectrum ( self,
np.ndarray spectrum )
Apply a prox-like update to the spectrum

Parameters
----------
spectrum:
    The spectrum of the model.

Definition at line 777 of file parametric.py.

777 def prox_spectrum(self, spectrum: np.ndarray) -> np.ndarray:
778 """Apply a prox-like update to the spectrum
779
780 Parameters
781 ----------
782 spectrum:
783 The spectrum of the model.
784 """
785 # prevent divergent spectrum
786 spectrum[spectrum < self.floor] = self.floor
787 return spectrum
788

◆ radial_params()

np.ndarray lsst.scarlet.lite.models.parametric.ParametricComponent.radial_params ( self)
The parameters used to model the radial function

Reimplemented in lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.

Definition at line 723 of file parametric.py.

723 def radial_params(self) -> np.ndarray:
724 """The parameters used to model the radial function"""
725 return self._params.x
726

◆ resize()

bool lsst.scarlet.lite.models.parametric.ParametricComponent.resize ( self,
Box model_box )
Resize the box that contains the model

Not yet implemented, so for now the model box
does not grow. If this is ever implemented in production,
in the long run this will be based on a cutoff value for the model.

Reimplemented from lsst.scarlet.lite.component.Component.

Definition at line 823 of file parametric.py.

823 def resize(self, model_box: Box) -> bool:
824 """Resize the box that contains the model
825
826 Not yet implemented, so for now the model box
827 does not grow. If this is ever implemented in production,
828 in the long run this will be based on a cutoff value for the model.
829 """
830 return False
831

◆ spectrum()

np.ndarray lsst.scarlet.lite.models.parametric.ParametricComponent.spectrum ( self)
The array of spectrum values

Definition at line 713 of file parametric.py.

713 def spectrum(self) -> np.ndarray:
714 """The array of spectrum values"""
715 return self._spectrum.x
716

◆ to_data()

ScarletComponentBaseData lsst.scarlet.lite.models.parametric.ParametricComponent.to_data ( self)
Convert the component to persistable ScarletComponentBaseData

Returns
-------
component_data: ScarletComponentBaseData
    The data object containing the component information

Reimplemented from lsst.scarlet.lite.component.Component.

Definition at line 842 of file parametric.py.

842 def to_data(self) -> ScarletComponentBaseData:
843 raise NotImplementedError("Saving elliptical parametric components is not yet implemented")
844
845

◆ update()

lsst.scarlet.lite.models.parametric.ParametricComponent.update ( self,
int it,
np.ndarray input_grad )
Update the component parameters from an input gradient

Parameters
----------
it:
    The current iteration of the optimizer.
input_grad:
    Gradient of the likelihood wrt the component model

Reimplemented from lsst.scarlet.lite.component.Component.

Reimplemented in lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.

Definition at line 808 of file parametric.py.

808 def update(self, it: int, input_grad: np.ndarray):
809 """Update the component parameters from an input gradient
810
811 Parameters
812 ----------
813 it:
814 The current iteration of the optimizer.
815 input_grad:
816 Gradient of the likelihood wrt the component model
817 """
818 spectrum = self.spectrum.copy()
819 morph = self.morph
820 self._spectrum.update(it, input_grad, morph)
821 self._params.update(it, input_grad, morph, spectrum, self.frame)
822

◆ x0()

float lsst.scarlet.lite.models.parametric.ParametricComponent.x0 ( self)
The x-center of the component

Definition at line 708 of file parametric.py.

708 def x0(self) -> float:
709 """The x-center of the component"""
710 return self._params.x[1]
711

◆ y0()

float lsst.scarlet.lite.models.parametric.ParametricComponent.y0 ( self)
The y-center of the component

Definition at line 703 of file parametric.py.

703 def y0(self) -> float:
704 """The y-center of the component"""
705 return self._params.x[0]
706

Member Data Documentation

◆ _bands

tuple lsst.scarlet.lite.component.Component._bands = bands
protectedinherited

Definition at line 62 of file component.py.

◆ _bbox

Box lsst.scarlet.lite.component.Component._bbox = bbox
protectedinherited

Definition at line 63 of file component.py.

◆ _func

lsst.scarlet.lite.models.parametric.ParametricComponent._func = morph_func
protected

Definition at line 686 of file parametric.py.

◆ _morph_grad

lsst.scarlet.lite.models.parametric.ParametricComponent._morph_grad = morph_grad
protected

Definition at line 687 of file parametric.py.

◆ _morph_prox

lsst.scarlet.lite.models.parametric.ParametricComponent._morph_prox = morph_prox
protected

Definition at line 688 of file parametric.py.

◆ _morph_step

lsst.scarlet.lite.models.parametric.ParametricComponent._morph_step = morph_step
protected

Definition at line 689 of file parametric.py.

◆ _params

lsst.scarlet.lite.models.parametric.ParametricComponent._params = parameter(morph_params)
protected

Definition at line 685 of file parametric.py.

◆ _prox_spectrum

Callable lsst.scarlet.lite.models.parametric.ParametricComponent._prox_spectrum = self.prox_spectrum
protected

Definition at line 692 of file parametric.py.

◆ _spectrum

lsst.scarlet.lite.models.parametric.ParametricComponent._spectrum = parameter(spectrum)
protected

Definition at line 684 of file parametric.py.

◆ floor

lsst.scarlet.lite.models.parametric.ParametricComponent.floor = floor

Definition at line 695 of file parametric.py.

◆ frame

lsst.scarlet.lite.models.parametric.ParametricComponent.frame

◆ radial_params

lsst.scarlet.lite.models.parametric.ParametricComponent.radial_params

◆ y0

lsst.scarlet.lite.models.parametric.ParametricComponent.y0

Definition at line 700 of file parametric.py.


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