LSST Applications 29.1.0,g0fba68d861+6b120c4394,g123d84c11c+8c5ae1fdc5,g1ec0fe41b4+191117f6ec,g1fd858c14a+c8450ae71a,g3533f9d6cb+a04f9ee0ab,g35bb328faa+8c5ae1fdc5,g3f0dcc2b1b+7df08700bd,g4178042926+b4254969db,g44ba364a48+04455b336b,g53246c7159+8c5ae1fdc5,g60b5630c4e+a04f9ee0ab,g663da51e9b+b05e6e1875,g67b6fd64d1+250bf6acd3,g78460c75b0+7e33a9eb6d,g786e29fd12+668abc6043,g8352419a5c+8c5ae1fdc5,g87e3079a85+d3fa38de54,g8852436030+cd899e2626,g89139ef638+250bf6acd3,g93a033419f+31ead11197,g989de1cb63+250bf6acd3,g9f33ca652e+f6053ecf14,ga1e959baac+5fbc491aed,ga2f891cd6c+a04f9ee0ab,gabe3b4be73+8856018cbb,gabf8522325+1f7e6d67b9,gac2eed3f23+250bf6acd3,gb1101e3267+0c331e9486,gb89ab40317+250bf6acd3,gcf25f946ba+cd899e2626,gd107969129+8964d67276,gd6cbbdb0b4+6bbecc8878,gde0f65d7ad+d65f9e019a,ge278dab8ac+eb3bbeb12f,ge410e46f29+250bf6acd3,gf5e32f922b+8c5ae1fdc5,gff02db199a+747430a128,gffe7e49bb4+a04f9ee0ab
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)
 
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 838 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 869 of file parametric.py.

881 ):
882 super().__init__(
883 bands=bands,
884 bbox=bbox,
885 spectrum=spectrum,
886 morph_params=morph_params,
887 morph_func=morph_func,
888 morph_grad=morph_grad,
889 morph_prox=morph_prox,
890 morph_step=morph_step,
891 prox_spectrum=prox_spectrum,
892 floor=floor,
893 )
894

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 722 of file parametric.py.

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

◆ bands()

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

Definition at line 66 of file component.py.

66 def bands(self) -> tuple:
67 """The bands in the component model"""
68 return self._bands
69

◆ bbox()

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

Definition at line 61 of file component.py.

61 def bbox(self) -> Box:
62 """The bounding box that contains the component in the full image"""
63 return self._bbox
64

◆ ellipse_params()

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

Definition at line 913 of file parametric.py.

913 def ellipse_params(self) -> np.ndarray:
914 """The parameters used to generate the scaled radius"""
915 return self._params.x[:5]
916

◆ 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 923 of file parametric.py.

923 def frame(self) -> EllipseFrame:
924 """The `EllipseFrame` that parameterizes the model"""
925 return EllipseFrame(*self.ellipse_params, self._bbox) # type: ignore
926

◆ 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 767 of file parametric.py.

767 def get_model(self, frame: CartesianFrame | None = None) -> Image:
768 """Generate the full model for this component"""
769 model = self.spectrum[:, None, None] * self._get_morph(frame)[None, :, :]
770 return Image(model, bands=self.bands, yx0=cast(tuple[int, int], self.bbox.origin[-2:]))
771

◆ 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 754 of file parametric.py.

754 def grad_morph(self) -> Callable:
755 """The function that calculates the gradient of the
756 morphological model
757 """
758 return self._morph_grad
759

◆ 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 784 of file parametric.py.

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

◆ morph()

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

Definition at line 744 of file parametric.py.

744 def morph(self, frame: CartesianFrame | None = None) -> np.ndarray:
745 """The morphological model"""
746 return self._get_morph(frame)
747

◆ 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 933 of file parametric.py.

933 def morph_grad(self) -> Callable:
934 """The function that calculates the gradient of the
935 morphological model
936 """
937 return self._morph_grad
938

◆ morph_prox()

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

Definition at line 928 of file parametric.py.

928 def morph_prox(self) -> Callable:
929 """The function used to constrain the morphological model"""
930 return self._morph_prox
931

◆ 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 761 of file parametric.py.

761 def morph_step(self) -> Callable:
762 """The function that calculates the gradient of the
763 morphological model
764 """
765 return cast(Callable, self._morph_step)
766

◆ 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 827 of file parametric.py.

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

◆ peak()

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

Definition at line 693 of file parametric.py.

693 def peak(self) -> tuple[float, float]:
694 """The center of the component"""
695 return self.y0, self.x0
696

◆ prox_morph()

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

Definition at line 749 of file parametric.py.

749 def prox_morph(self) -> Callable:
750 """The function used to constrain the morphological model"""
751 return self._morph_prox
752

◆ 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 772 of file parametric.py.

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

◆ 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 918 of file parametric.py.

918 def radial_params(self) -> np.ndarray:
919 """The parameters used to model the radial function"""
920 return self._params.x[5:]
921

◆ 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 818 of file parametric.py.

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

◆ 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 896 of file parametric.py.

896 def semi_major(self) -> float:
897 """The length of the semi-major axis of the model"""
898 return self._params.x[2]
899

◆ 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 901 of file parametric.py.

901 def semi_minor(self) -> float:
902 """The length of the semi-minor axis of the model"""
903 return self._params.x[3]
904

◆ spectrum()

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

Definition at line 708 of file parametric.py.

708 def spectrum(self) -> np.ndarray:
709 """The array of spectrum values"""
710 return self._spectrum.x
711

◆ 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 906 of file parametric.py.

906 def theta(self) -> float:
907 """The counter-clockwise rotation angle of the model from the
908 x-axis.
909 """
910 return self._params.x[4]
911

◆ 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 939 of file parametric.py.

939 def update(self, it: int, input_grad: np.ndarray):
940 """Update the component
941
942 Parameters
943 ----------
944 it:
945 The current iteration of the optimizer.
946 input_grad:
947 Gradient of the likelihood wrt the component model
948 """
949 ellipse = self.frame
950 spectrum = self.spectrum.copy()
951 morph = self._func(self.radial_params, ellipse)
952 self._spectrum.update(it, input_grad, morph)
953 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 703 of file parametric.py.

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

◆ y0()

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

Definition at line 698 of file parametric.py.

698 def y0(self) -> float:
699 """The y-center of the component"""
700 return self._params.x[0]
701

Member Data Documentation

◆ _bands

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

Definition at line 57 of file component.py.

◆ _bbox

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

Definition at line 58 of file component.py.

◆ _func

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

Definition at line 681 of file parametric.py.

◆ _morph_grad

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

Definition at line 682 of file parametric.py.

◆ _morph_prox

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

Definition at line 683 of file parametric.py.

◆ _morph_step

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

Definition at line 684 of file parametric.py.

◆ _params

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

Definition at line 680 of file parametric.py.

◆ _prox_spectrum

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

Definition at line 687 of file parametric.py.

◆ _spectrum

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

Definition at line 679 of file parametric.py.

◆ ellipse_params

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

Definition at line 925 of file parametric.py.

◆ floor

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

Definition at line 690 of file parametric.py.

◆ y0

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

Definition at line 695 of file parametric.py.


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