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 | Protected Member Functions | Protected Attributes | List of all members
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)
 

Public Attributes

 floor
 
 y0
 
 radial_params
 
 frame
 

Protected Member Functions

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

Protected Attributes

 _spectrum
 
 _params
 
 _func
 
 _morph_grad
 
 _morph_prox
 
 _morph_step
 
 _bbox
 
 _prox_spectrum
 

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 631 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 )

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

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

Definition at line 664 of file parametric.py.

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

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 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

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

713 def frame(self) -> CartesianFrame:
714 """The coordinate system that contains the model"""
715 return CartesianFrame(self._bbox)
716

◆ 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 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)
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 )
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 )
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_step()

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

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

Definition at line 718 of file parametric.py.

718 def radial_params(self) -> np.ndarray:
719 """The parameters used to model the radial function"""
720 return self._params.x
721

◆ 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 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

◆ spectrum()

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

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

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

◆ x0()

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

◆ _bbox

lsst.scarlet.lite.models.parametric.ParametricComponent._bbox
protected

Definition at line 685 of file parametric.py.

◆ _func

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

Definition at line 681 of file parametric.py.

◆ _morph_grad

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

Definition at line 682 of file parametric.py.

◆ _morph_prox

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

Definition at line 683 of file parametric.py.

◆ _morph_step

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

Definition at line 684 of file parametric.py.

◆ _params

lsst.scarlet.lite.models.parametric.ParametricComponent._params
protected

Definition at line 680 of file parametric.py.

◆ _prox_spectrum

lsst.scarlet.lite.models.parametric.ParametricComponent._prox_spectrum
protected

Definition at line 689 of file parametric.py.

◆ _spectrum

lsst.scarlet.lite.models.parametric.ParametricComponent._spectrum
protected

Definition at line 679 of file parametric.py.

◆ floor

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

Definition at line 690 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 695 of file parametric.py.


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