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 | Protected Attributes | List of all members
lsst.scarlet.lite.models.parametric.EllipseFrame Class Reference
Inheritance diagram for lsst.scarlet.lite.models.parametric.EllipseFrame:
lsst.scarlet.lite.models.parametric.CartesianFrame

Public Member Functions

 __init__ (self, float y0, float x0, float major, float minor, float theta, Box bbox, float r_min=1e-20)
 
float grad_x0 (self, np.ndarray input_grad, bool use_r2)
 
float grad_y0 (self, np.ndarray input_grad, bool use_r2)
 
float grad_major (self, np.ndarray input_grad, bool use_r2)
 
float grad_minor (self, np.ndarray input_grad, bool use_r2)
 
float grad_theta (self, np.ndarray input_grad, bool use_r2)
 
float x0 (self)
 
float y0 (self)
 
float major (self)
 
float minor (self)
 
float theta (self)
 
Box bbox (self)
 
np.ndarray r_grid (self)
 
np.ndarray r2_grid (self)
 

Protected Attributes

 _xMajor
 
 _xMinor
 
 _xa
 
 _yb
 
 _y0
 
 _x0
 
 _theta
 
 _major
 
 _minor
 
 _sin
 
 _cos
 
 _bbox
 
 _rMin
 
 _radius2
 
 _radius
 

Detailed Description

Frame to scale the radius based on the parameters of an ellipse

This frame is used to calculate the coordinates of the
radius and radius**2 from a given center location,
based on the semi-major axis, semi-minor axis, and rotation angle.
It is also used to calculate the gradient wrt either the
radius**2 or radius for all of the model parameters.

Parameters
----------
y0: float
    The y-center of the ellipse.
x0: float
    The x-center of the ellipse.
major: float
    The length of the semi-major axis.
minor: float
    The length of the semi-minor axis.
theta: float
    The counter-clockwise rotation angle
    from the semi-major axis.
bbox: Box
    The bounding box that contains the entire frame.
r_min: float
    The minimum value of the radius.
    This is used to prevent divergences that occur
    when calculating the gradient at radius == 0.

Definition at line 104 of file parametric.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.scarlet.lite.models.parametric.EllipseFrame.__init__ ( self,
float bbox,
float x0,
float major,
float minor,
float theta,
Box bbox,
float r_min = 1e-20 )
Parameters
----------
bbox: Box
    The bounding box that contains this frame.

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

Definition at line 134 of file parametric.py.

143 ):
144 super().__init__(bbox)
145 # Set some useful parameters for derivations
146 sin = np.sin(theta)
147 cos = np.cos(theta)
148
149 # Rotate into the frame with xMajor as the x-axis
150 # and xMinor as the y-axis
151 self._xMajor = (self._x - x0) * cos + (self._y - y0) * sin
152 self._xMinor = -(self._x - x0) * sin + (self._y - y0) * cos
153 # The scaled major and minor axes
154 self._xa = self._xMajor / major
155 self._yb = self._xMinor / minor
156
157 # Store parameters useful for gradient calculation
158 self._y0, self._x0 = y0, x0
159 self._theta = theta
160 self._major = major
161 self._minor = minor
162 self._sin, self._cos = sin, cos
163 self._bbox = bbox
164 self._rMin = r_min
165 # Store the scaled radius**2 and radius
166 self._radius2 = self._xa**2 + self._yb**2
167 self._radius: np.ndarray | None = None
168

Member Function Documentation

◆ bbox()

Box lsst.scarlet.lite.models.parametric.EllipseFrame.bbox ( self)
The bounding box to hold the model

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

Definition at line 318 of file parametric.py.

318 def bbox(self) -> Box:
319 """The bounding box to hold the model"""
320 return self._bbox
321
AmpInfoBoxKey bbox
Definition Amplifier.cc:117

◆ grad_major()

float lsst.scarlet.lite.models.parametric.EllipseFrame.grad_major ( self,
np.ndarray input_grad,
bool use_r2 )
The gradient of either the radius or radius**2 wrt.
the semi-major axis

Parameters
----------
input_grad:
    Gradient of the likelihood wrt the component model
use_r2:
    Whether to calculate the gradient of the radius**2
    (``use_r2==True``) or the radius (``use_r2==False``).

Returns
-------
result:
    The gradient of the likelihood wrt the semi-major axis.

Definition at line 217 of file parametric.py.

217 def grad_major(self, input_grad: np.ndarray, use_r2: bool) -> float:
218 """The gradient of either the radius or radius**2 wrt.
219 the semi-major axis
220
221 Parameters
222 ----------
223 input_grad:
224 Gradient of the likelihood wrt the component model
225 use_r2:
226 Whether to calculate the gradient of the radius**2
227 (``use_r2==True``) or the radius (``use_r2==False``).
228
229 Returns
230 -------
231 result:
232 The gradient of the likelihood wrt the semi-major axis.
233 """
234 grad = -2 / self._major * self._xa**2
235 if use_r2:
236 grad *= 2
237 else:
238 r = self.r_grid
239 grad *= 1 / r
240 return np.sum(grad * input_grad) # type: ignore
241

◆ grad_minor()

float lsst.scarlet.lite.models.parametric.EllipseFrame.grad_minor ( self,
np.ndarray input_grad,
bool use_r2 )
The gradient of either the radius or radius**2 wrt.
the semi-minor axis

Parameters
----------
input_grad:
    Gradient of the likelihood wrt the component model
use_r2:
    Whether to calculate the gradient of the radius**2
    (``useR2==True``) or the radius (``useR2==False``).

Returns
-------
result:
    The gradient of the likelihood wrt the semi-minor axis.

Definition at line 242 of file parametric.py.

242 def grad_minor(self, input_grad: np.ndarray, use_r2: bool) -> float:
243 """The gradient of either the radius or radius**2 wrt.
244 the semi-minor axis
245
246 Parameters
247 ----------
248 input_grad:
249 Gradient of the likelihood wrt the component model
250 use_r2:
251 Whether to calculate the gradient of the radius**2
252 (``useR2==True``) or the radius (``useR2==False``).
253
254 Returns
255 -------
256 result:
257 The gradient of the likelihood wrt the semi-minor axis.
258 """
259 grad = -2 / self._minor * self._yb**2
260 if use_r2:
261 grad *= 2
262 else:
263 r = self.r_grid
264 grad *= 1 / r
265 return np.sum(grad * input_grad) # type: ignore
266

◆ grad_theta()

float lsst.scarlet.lite.models.parametric.EllipseFrame.grad_theta ( self,
np.ndarray input_grad,
bool use_r2 )
The gradient of either the radius or radius**2 wrt.
the rotation angle

Parameters
----------
input_grad:
    Gradient of the likelihood wrt the component model
use_r2:
    Whether to calculate the gradient of the radius**2
    (``useR2==True``) or the radius (``useR2==False``).

Returns
-------
result:
    The gradient of the likelihood wrt the rotation angle.

Definition at line 267 of file parametric.py.

267 def grad_theta(self, input_grad: np.ndarray, use_r2: bool) -> float:
268 """The gradient of either the radius or radius**2 wrt.
269 the rotation angle
270
271 Parameters
272 ----------
273 input_grad:
274 Gradient of the likelihood wrt the component model
275 use_r2:
276 Whether to calculate the gradient of the radius**2
277 (``useR2==True``) or the radius (``useR2==False``).
278
279 Returns
280 -------
281 result:
282 The gradient of the likelihood wrt the rotation angle.
283 """
284 grad = self._xa * self._xMinor / self._major - self._yb * self._xMajor / self._minor
285 if use_r2:
286 grad *= 2
287 else:
288 r = self.r_grid
289 grad *= 1 / r
290 return np.sum(grad * input_grad) # type: ignore
291

◆ grad_x0()

float lsst.scarlet.lite.models.parametric.EllipseFrame.grad_x0 ( self,
np.ndarray input_grad,
bool use_r2 )
The gradient of either the radius or radius**2 wrt. the x-center

Parameters
----------
input_grad:
    Gradient of the likelihood wrt the component model
use_r2:
    Whether to calculate the gradient of the radius**2
    (``useR2==True``) or the radius (``useR2==False``).

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

Definition at line 169 of file parametric.py.

169 def grad_x0(self, input_grad: np.ndarray, use_r2: bool) -> float:
170 """The gradient of either the radius or radius**2 wrt. the x-center
171
172 Parameters
173 ----------
174 input_grad:
175 Gradient of the likelihood wrt the component model
176 use_r2:
177 Whether to calculate the gradient of the radius**2
178 (``useR2==True``) or the radius (``useR2==False``).
179
180 Returns
181 -------
182 result:
183 The gradient of the likelihood wrt x0.
184 """
185 grad = -self._xa * self._cos / self._major + self._yb * self._sin / self._minor
186 if use_r2:
187 grad *= 2
188 else:
189 r = self.r_grid
190 grad *= 1 / r
191 return np.sum(grad * input_grad) # type: ignore
192

◆ grad_y0()

float lsst.scarlet.lite.models.parametric.EllipseFrame.grad_y0 ( self,
np.ndarray input_grad,
bool use_r2 )
The gradient of either the radius or radius**2 wrt. the y-center

Parameters
----------
input_grad:
    Gradient of the likelihood wrt the component model
use_r2:
    Whether to calculate the gradient of the radius**2
    (``useR2==True``) or the radius (``useR2==False``).

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

Definition at line 193 of file parametric.py.

193 def grad_y0(self, input_grad: np.ndarray, use_r2: bool) -> float:
194 """The gradient of either the radius or radius**2 wrt. the y-center
195
196 Parameters
197 ----------
198 input_grad:
199 Gradient of the likelihood wrt the component model
200 use_r2:
201 Whether to calculate the gradient of the radius**2
202 (``useR2==True``) or the radius (``useR2==False``).
203
204 Returns
205 -------
206 result:
207 The gradient of the likelihood wrt y0.
208 """
209 grad = -(self._xa * self._sin / self._major + self._yb * self._cos / self._minor)
210 if use_r2:
211 grad *= 2
212 else:
213 r = self.r_grid
214 grad *= 1 / r
215 return np.sum(grad * input_grad) # type: ignore
216

◆ major()

float lsst.scarlet.lite.models.parametric.EllipseFrame.major ( self)
The semi-major axis

Definition at line 303 of file parametric.py.

303 def major(self) -> float:
304 """The semi-major axis"""
305 return self._major
306

◆ minor()

float lsst.scarlet.lite.models.parametric.EllipseFrame.minor ( self)
The semi-minor axis

Definition at line 308 of file parametric.py.

308 def minor(self) -> float:
309 """The semi-minor axis"""
310 return self._minor
311

◆ r2_grid()

np.ndarray lsst.scarlet.lite.models.parametric.EllipseFrame.r2_grid ( self)
The radius squared located at each pixel

Definition at line 330 of file parametric.py.

330 def r2_grid(self) -> np.ndarray:
331 """The radius squared located at each pixel"""
332 return self._radius2 + self._rMin**2
333
334

◆ r_grid()

np.ndarray lsst.scarlet.lite.models.parametric.EllipseFrame.r_grid ( self)
The radial coordinates of each pixel

Definition at line 323 of file parametric.py.

323 def r_grid(self) -> np.ndarray:
324 """The radial coordinates of each pixel"""
325 if self._radius is None:
326 self._radius = np.sqrt(self.r2_grid)
327 return self._radius
328

◆ theta()

float lsst.scarlet.lite.models.parametric.EllipseFrame.theta ( self)
The rotation angle

Definition at line 313 of file parametric.py.

313 def theta(self) -> float:
314 """The rotation angle"""
315 return self._theta
316

◆ x0()

float lsst.scarlet.lite.models.parametric.EllipseFrame.x0 ( self)
The x-center

Definition at line 293 of file parametric.py.

293 def x0(self) -> float:
294 """The x-center"""
295 return self._x0
296

◆ y0()

float lsst.scarlet.lite.models.parametric.EllipseFrame.y0 ( self)
The y-center

Definition at line 298 of file parametric.py.

298 def y0(self) -> float:
299 """The y-center"""
300 return self._y0
301

Member Data Documentation

◆ _bbox

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

Definition at line 163 of file parametric.py.

◆ _cos

lsst.scarlet.lite.models.parametric.EllipseFrame._cos
protected

Definition at line 162 of file parametric.py.

◆ _major

lsst.scarlet.lite.models.parametric.EllipseFrame._major
protected

Definition at line 160 of file parametric.py.

◆ _minor

lsst.scarlet.lite.models.parametric.EllipseFrame._minor
protected

Definition at line 161 of file parametric.py.

◆ _radius

lsst.scarlet.lite.models.parametric.EllipseFrame._radius
protected

Definition at line 326 of file parametric.py.

◆ _radius2

lsst.scarlet.lite.models.parametric.EllipseFrame._radius2
protected

Definition at line 166 of file parametric.py.

◆ _rMin

lsst.scarlet.lite.models.parametric.EllipseFrame._rMin
protected

Definition at line 164 of file parametric.py.

◆ _sin

lsst.scarlet.lite.models.parametric.EllipseFrame._sin
protected

Definition at line 162 of file parametric.py.

◆ _theta

lsst.scarlet.lite.models.parametric.EllipseFrame._theta
protected

Definition at line 159 of file parametric.py.

◆ _x0

lsst.scarlet.lite.models.parametric.EllipseFrame._x0
protected

Definition at line 158 of file parametric.py.

◆ _xa

lsst.scarlet.lite.models.parametric.EllipseFrame._xa
protected

Definition at line 154 of file parametric.py.

◆ _xMajor

lsst.scarlet.lite.models.parametric.EllipseFrame._xMajor
protected

Definition at line 151 of file parametric.py.

◆ _xMinor

lsst.scarlet.lite.models.parametric.EllipseFrame._xMinor
protected

Definition at line 152 of file parametric.py.

◆ _y0

lsst.scarlet.lite.models.parametric.EllipseFrame._y0
protected

Definition at line 158 of file parametric.py.

◆ _yb

lsst.scarlet.lite.models.parametric.EllipseFrame._yb
protected

Definition at line 155 of file parametric.py.


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