EllipseGeometry

class photutils.isophote.EllipseGeometry(x0, y0, sma, eps, pa, astep=0.1, linear_growth=False, fix_center=False, fix_pa=False, fix_eps=False)[source]

Bases: object

Container class to store parameters for the geometry of an ellipse.

Parameters that describe the relationship of a given ellipse with other associated ellipses are also encapsulated in this container. These associated ellipses may include, e.g., the two (inner and outer) bounding ellipses that are used to build sectors along the elliptical path. These sectors are used as areas for integrating pixel values, when the area integration mode (mean or median) is used.

This class also keeps track of where in the ellipse we are when performing an ‘extract’ operation. This is mostly relevant when using an area integration mode (as opposed to a pixel integration mode)

Parameters:
x0, y0float

The center pixel coordinate of the ellipse.

smafloat

The semimajor axis of the ellipse in pixels.

epsellipticity

The ellipticity of the ellipse.

pafloat

The position angle (in radians) of the semimajor axis in relation to the positive x axis of the image array (rotating towards the positive y axis). Position angles are defined in the range \(0 < PA <= \pi\). Avoid using as starting position angle of 0., since the fit algorithm may not work properly. When the ellipses are such that position angles are near either extreme of the range, noise can make the solution jump back and forth between successive isophotes, by amounts close to 180 degrees.

astepfloat, optional

The step value for growing/shrinking the semimajor axis. It can be expressed either in pixels (when linear_growth=True) or as a relative value (when linear_growth=False). The default is 0.1.

linear_growthbool, optional

The semimajor axis growing/shrinking mode. The default is False.

fix_centerbool, optional

Keep center of ellipse fixed during fit? The default is False.

fix_pabool, optional

Keep position angle of semi-major axis of ellipse fixed during fit? The default is False.

fix_epsbool, optional

Keep ellipticity of ellipse fixed during fit? The default is False.

Methods Summary

bounding_ellipses()

Compute the semimajor axis of the two ellipses that bound the annulus where integrations take place.

find_center(image[, threshold, verbose])

Find the center of a galaxy.

initialize_sector_geometry(phi)

Initialize geometry attributes associated with an elliptical sector at the given polar angle phi.

polar_angle_sector_limits()

Return the two polar angles that bound the sector.

radius(angle)

Calculate the polar radius for a given polar angle.

reset_sma(step)

Change the direction of semimajor axis growth, from outwards to inwards.

to_polar(x, y)

Return the radius and polar angle in the ellipse coordinate system given (x, y) pixel image coordinates.

update_sma(step)

Calculate an updated value for the semimajor axis, given the current value and the step value.

Methods Documentation

bounding_ellipses()[source]

Compute the semimajor axis of the two ellipses that bound the annulus where integrations take place.

Returns:
sma1, sma2float

The smaller and larger values of semimajor axis length that define the annulus bounding ellipses.

find_center(image, threshold=0.1, verbose=True)[source]

Find the center of a galaxy.

If the algorithm is successful the (x, y) coordinates in this EllipseGeometry (i.e., the x0 and y0 attributes) instance will be modified.

The isophote fit algorithm requires an initial guess for the galaxy center (x, y) coordinates and these coordinates must be close to the actual galaxy center for the isophote fit to work. This method provides can provide an initial guess for the galaxy center coordinates. See the Notes section below for more details.

Parameters:
image2D ndarray

The image array. Masked arrays are not recognized here. This assumes that centering should always be done on valid pixels.

thresholdfloat, optional

The centerer threshold. To turn off the centerer, set this to a large value (i.e., >> 1). The default is 0.1.

verbosebool, optional

Whether to print object centering information. The default is True.

Notes

The centerer function scans a 10x10 window centered on the (x, y) coordinates in the EllipseGeometry instance passed to the constructor of the Ellipse class. If any of the EllipseGeometry (x, y) coordinates are None, the center of the input image frame is used. If the center acquisition is successful, the EllipseGeometry instance is modified in place to reflect the solution of the object centerer algorithm.

In some cases the object centerer algorithm may fail even though there is enough signal-to-noise to start a fit (e.g., objects with very high ellipticity). In those cases the sensitivity of the algorithm can be decreased by decreasing the value of the object centerer threshold parameter. The centerer works by looking where a quantity akin to a signal-to-noise ratio is maximized within the 10x10 window. The centerer can thus be shut off entirely by setting the threshold to a large value (i.e., >> 1; meaning no location inside the search window will achieve that signal-to-noise ratio).

initialize_sector_geometry(phi)[source]

Initialize geometry attributes associated with an elliptical sector at the given polar angle phi.

This function computes:

  • the four vertices that define the elliptical sector on the pixel array.

  • the sector area (saved in the sector_area attribute)

  • the sector angular width (saved in sector_angular_width attribute)

Parameters:
phifloat

The polar angle (radians) where the sector is located.

Returns:
x, y1D ndarray

The x and y coordinates of each vertex as 1D arrays.

polar_angle_sector_limits()[source]

Return the two polar angles that bound the sector.

The two bounding polar angles become available only after calling the initialize_sector_geometry() method.

Returns:
phi1, phi2float

The smaller and larger values of polar angle that bound the current sector.

radius(angle)[source]

Calculate the polar radius for a given polar angle.

Parameters:
anglefloat

The polar angle (radians).

Returns:
radiusfloat

The polar radius (pixels).

reset_sma(step)[source]

Change the direction of semimajor axis growth, from outwards to inwards.

Parameters:
stepfloat

The current step value.

Returns:
sma, new_stepfloat

The new semimajor axis length and the new step value to initiate the shrinking of the semimajor axis length. This is the step value that should be used when calling the update_sma() method.

to_polar(x, y)[source]

Return the radius and polar angle in the ellipse coordinate system given (x, y) pixel image coordinates.

This function takes care of the different definitions for position angle (PA) and polar angle (phi):

\[ \begin{align}\begin{aligned}-\pi < PA < \pi\\0 < phi < 2 \pi\end{aligned}\end{align} \]

Note that radius can be anything. The solution is not tied to the semimajor axis length, but to the center position and tilt angle.

Parameters:
x, yfloat

The (x, y) image coordinates.

Returns:
radius, anglefloat

The ellipse radius and polar angle.

update_sma(step)[source]

Calculate an updated value for the semimajor axis, given the current value and the step value.

The step value must be managed by the caller to support both modes: grow outwards and shrink inwards.

Parameters:
stepfloat

The step value.

Returns:
smafloat

The new semimajor axis length.