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

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)
 
float semi_major (self)
 
float semi_minor (self)
 
float theta (self)
 
np.ndarray ellipse_params (self)
 
np.ndarray radial_params (self)
 
EllipseFrame frame (self)
 
Callable morph_prox (self)
 
Callable morph_grad (self)
 
 update (self, int it, np.ndarray input_grad)
 
float y0 (self)
 
tuple[float, float] peak (self)
 
float x0 (self)
 
np.ndarray spectrum (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)
 
bool resize (self, Box model_box)
 
None parameterize (self, Callable parameterization)
 
ScarletComponentBaseData to_data (self)
 
Box bbox (self)
 
tuple bands (self)
 

Public Attributes

 ellipse_params
 
 floor = floor
 
 y0
 

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 radial density/surface brightness profile with elliptical symmetry

Parameters
----------
bands:
    The bands used in the model.
bbox:
    The bounding box that holds this component model.
spectrum:
    The spectrum of the component.
morph_params:
    The parameters passed to `morph_func` to
    generate the morphology in image space.
morph_func:
    The function to generate the morphology
    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.
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 846 of file parametric.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.__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 877 of file parametric.py.

889 ):
890 super().__init__(
891 bands=bands,
892 bbox=bbox,
893 spectrum=spectrum,
894 morph_params=morph_params,
895 morph_func=morph_func,
896 morph_grad=morph_grad,
897 morph_prox=morph_prox,
898 morph_step=morph_step,
899 prox_spectrum=prox_spectrum,
900 floor=floor,
901 )
902

Member Function Documentation

◆ _get_morph()

np.ndarray lsst.scarlet.lite.models.parametric.ParametricComponent._get_morph ( self,
CartesianFrame | None frame = None )
protectedinherited
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

◆ ellipse_params()

np.ndarray lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.ellipse_params ( self)
The parameters used to generate the scaled radius

Definition at line 921 of file parametric.py.

921 def ellipse_params(self) -> np.ndarray:
922 """The parameters used to generate the scaled radius"""
923 return self._params.x[:5]
924

◆ frame()

EllipseFrame lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.frame ( self)
The `EllipseFrame` that parameterizes the model

Reimplemented from lsst.scarlet.lite.models.parametric.ParametricComponent.

Definition at line 931 of file parametric.py.

931 def frame(self) -> EllipseFrame:
932 """The `EllipseFrame` that parameterizes the model"""
933 return EllipseFrame(*self.ellipse_params, self._bbox) # type: ignore
934

◆ get_model()

Image lsst.scarlet.lite.models.parametric.ParametricComponent.get_model ( self,
CartesianFrame | None frame = None )
inherited
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)
inherited
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 )
inherited
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 )
inherited
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_grad()

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

Definition at line 941 of file parametric.py.

941 def morph_grad(self) -> Callable:
942 """The function that calculates the gradient of the
943 morphological model
944 """
945 return self._morph_grad
946

◆ morph_prox()

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

Definition at line 936 of file parametric.py.

936 def morph_prox(self) -> Callable:
937 """The function used to constrain the morphological model"""
938 return self._morph_prox
939

◆ morph_step()

Callable lsst.scarlet.lite.models.parametric.ParametricComponent.morph_step ( self)
inherited
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 )
inherited
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)
inherited
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)
inherited
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 )
inherited
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.EllipticalParametricComponent.radial_params ( self)
The parameters used to model the radial function

Reimplemented from lsst.scarlet.lite.models.parametric.ParametricComponent.

Definition at line 926 of file parametric.py.

926 def radial_params(self) -> np.ndarray:
927 """The parameters used to model the radial function"""
928 return self._params.x[5:]
929

◆ resize()

bool lsst.scarlet.lite.models.parametric.ParametricComponent.resize ( self,
Box model_box )
inherited
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

◆ semi_major()

float lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.semi_major ( self)
The length of the semi-major axis of the model

Definition at line 904 of file parametric.py.

904 def semi_major(self) -> float:
905 """The length of the semi-major axis of the model"""
906 return self._params.x[2]
907

◆ semi_minor()

float lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.semi_minor ( self)
The length of the semi-minor axis of the model

Definition at line 909 of file parametric.py.

909 def semi_minor(self) -> float:
910 """The length of the semi-minor axis of the model"""
911 return self._params.x[3]
912

◆ spectrum()

np.ndarray lsst.scarlet.lite.models.parametric.ParametricComponent.spectrum ( self)
inherited
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

◆ theta()

float lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.theta ( self)
The counter-clockwise rotation angle of the model from the
x-axis.

Definition at line 914 of file parametric.py.

914 def theta(self) -> float:
915 """The counter-clockwise rotation angle of the model from the
916 x-axis.
917 """
918 return self._params.x[4]
919

◆ to_data()

ScarletComponentBaseData lsst.scarlet.lite.models.parametric.ParametricComponent.to_data ( self)
inherited
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.EllipticalParametricComponent.update ( self,
int it,
np.ndarray input_grad )
Update the component

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

Reimplemented from lsst.scarlet.lite.models.parametric.ParametricComponent.

Definition at line 947 of file parametric.py.

947 def update(self, it: int, input_grad: np.ndarray):
948 """Update the component
949
950 Parameters
951 ----------
952 it:
953 The current iteration of the optimizer.
954 input_grad:
955 Gradient of the likelihood wrt the component model
956 """
957 ellipse = self.frame
958 spectrum = self.spectrum.copy()
959 morph = self._func(self.radial_params, ellipse)
960 self._spectrum.update(it, input_grad, morph)
961 self._params.update(it, input_grad, morph, spectrum, ellipse)

◆ x0()

float lsst.scarlet.lite.models.parametric.ParametricComponent.x0 ( self)
inherited
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)
inherited
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
protectedinherited

Definition at line 686 of file parametric.py.

◆ _morph_grad

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

Definition at line 687 of file parametric.py.

◆ _morph_prox

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

Definition at line 688 of file parametric.py.

◆ _morph_step

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

Definition at line 689 of file parametric.py.

◆ _params

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

Definition at line 685 of file parametric.py.

◆ _prox_spectrum

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

Definition at line 692 of file parametric.py.

◆ _spectrum

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

Definition at line 684 of file parametric.py.

◆ ellipse_params

lsst.scarlet.lite.models.parametric.EllipticalParametricComponent.ellipse_params

Definition at line 933 of file parametric.py.

◆ floor

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

Definition at line 695 of file parametric.py.

◆ y0

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

Definition at line 700 of file parametric.py.


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