Moments#
- class scarlet2.measure.Moments(component, N=2, center=None, weight=None)[source]#
Bases:
dictBase Moments class
Moments of the brightness distribution
The dict is accessed by keys, which denote the power of y/x of the specific Moment: m[p,q] = int dx dy f(y,x) y^p x^q.
Notes
Like all coordinates in scarlet2, moments are computed in (y,x) order.
- Parameters:
component (
Componentorarray) – Component to analyze or its hyperspectral modelN (
int >=0) – Moment ordercenter (
array) – 2D coordinate in frame of componentweight (
array) – weight function with same shape as component
- property centroid#
Determine centroid from moments
- Returns:
Coordinates of the centroid in the pixel frame of the data that defines these moments
- Return type:
array
- clear() None. Remove all items from D.#
- convolve(p)[source]#
Convolve moments with moments p
The moments are changed in place.
See Melchior et al. (2010), “Weak gravitational lensing with Deimos”, Equation 9
- Parameters:
p (
Moments) – Moments of the kernel to convolve with- Return type:
self
- copy() a shallow copy of D#
- deconvolve(p)[source]#
Deconvolve moments from moments p
The moments are changed in place.
See Melchior et al. (2010), “Weak gravitational lensing with Deimos”, Table 1
- Parameters:
p (
Moments) – Moments of the kernel to deconvolve from- Return type:
self
- property ellipticity#
Determine complex ellipticity from moments
- Returns:
Ellipticity (2D) of the data that defines these moments
- Return type:
jnp.array
- property flux#
Determine flux from 0th moment
- Return type:
float
- fromkeys(value=None, /)#
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)#
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items#
- keys() a set-like object providing a view on D's keys#
- property order#
Moment order
- Return type:
int
- pop(k[, d]) v, remove specified key and return the corresponding value.#
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()#
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- resize(c)[source]#
Change moments for a change of factor c of the size/spatial resolution of the defining frame
This operation arises when one adjust the moments for a change in the size of pixels of the defining frame, e.g. when asking “what would the moments be if the pixels were factor c smaller (or the source c times larger)”? The fluxes are unchanged, which corresponds to preservation of photons under resizing.
The moments are changed in place.
See Teague (1980), “Image analysis via the general theory of moments”, eq. 34 for details.
- Parameters:
c (
floatorlist) – Scaling factor for the size change. Can be different along x and y- Return type:
self
- rotate(phi)[source]#
Change moments for rotation of angle phi.
The moments are changed in place.
See Teague (1980), “Image analysis via the general theory of moments”, eq. 36 for details.
- Parameters:
phi (
float) – Rotation angle, in radian- Return type:
self
- setdefault(key, default=None, /)#
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- property size#
Determine size from moments
- Return type:
float
- transfer(wcs_in, wcs_out)[source]#
Compute rescaling and rotation from WCSs and apply to moments
The method adjusts moments measured with a frame defined by wcs_in to the frame wcs_out. The moments are changed in place.
- Parameters:
wcs_in (
astropy.wcs.Wcsprm) – WCS of the frame with original momentswcs_out (
astropy.wcs.Wcsprm) – WCS of the frame to which the moments should be adjusted
- Return type:
self
- translate(shift)[source]#
Change moments for translation shift
The moments are changed in place.
Note: This changes all the moments, not just the dipole, for the new reference center.
See Teague (1980), “Image analysis via the general theory of moments”, eq. 30 for details.
- Parameters:
shift (
(y,x)) – translation, in pixels- Return type:
self
- update([E, ]**F) None. Update D from dict/iterable E and F.#
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values#