ProfileBase#

class photutils.profiles.ProfileBase(data, xycen, radii, *, error=None, mask=None, method='exact', subpixels=5)[source]#

Bases: object

Abstract base class for profile classes.

Parameters:
data2D ndarray

The 2D data array. The data should be background-subtracted.

xycentuple of 2 floats

The (x, y) pixel coordinate of the source center.

radii1D float ndarray

An array of radii defining the profile apertures. radii must be strictly increasing with a minimum value greater than or equal to zero, and contain at least 2 values. The radial spacing does not need to be constant. See the subclass documentation for details on how radii is interpreted.

error2D ndarray, optional

The 1-sigma errors of the input data. error is assumed to include all sources of error, including the Poisson error of the sources (see calc_total_error). error must have the same shape as the input data.

mask2D bool ndarray, optional

A boolean mask with the same shape as data where a True value indicates the corresponding element of data is masked. Masked data are excluded from all calculations.

method{‘exact’, ‘center’, ‘subpixel’}, optional

The method used to determine the pixel weights (the fraction of the pixel area covered by the aperture):

  • 'exact' (default): Calculates the exact geometric overlap area. Weights are continuous in the range [0, 1].

  • 'center': Binary weighting based on the pixel center. Weights are either 0 or 1. A pixel is included only if its center lies strictly inside the aperture; pixel centers lying exactly on the aperture boundary are excluded (weight 0).

  • 'subpixel': Approximates the overlap by averaging binary samples on a subgrid. The number of samples is set by the subpixels parameter. Weights are discrete in the range [0, 1]. A subpixel is included only if its center lies strictly inside the aperture; subpixel centers lying exactly on the aperture boundary are excluded (weight 0).

subpixelsint, optional

The subsampling factor per axis used when method='subpixel'. Each pixel is divided into a grid of subpixels**2 subpixels to approximate the overlap. This parameter is ignored for other methods.

Attributes Summary

profile

The radial profile as a 1D ndarray.

profile_error

The profile errors as a 1D ndarray.

radius

The profile radius in pixels as a 1D ndarray.

Methods Summary

normalize([method])

Normalize the profile.

plot([ax])

Plot the profile.

plot_error([ax])

Plot the profile errors.

unnormalize()

Unnormalize the profile back to the original state before any calls to normalize.

Attributes Documentation

profile#

The radial profile as a 1D ndarray.

profile_error#

The profile errors as a 1D ndarray.

If no error array was provided, an empty array with shape (0,) is returned.

radius#

The profile radius in pixels as a 1D ndarray.

Methods Documentation

normalize(method='max')[source]#

Normalize the profile.

Parameters:
method{‘max’, ‘sum’}, optional

The method used to normalize the profile:

  • 'max' (default): The profile is normalized such that its maximum value is 1.

  • 'sum': The profile is normalized such that its sum (integral) is 1.

plot(ax=None, **kwargs)[source]#

Plot the profile.

Parameters:
axmatplotlib.axes.Axes or None, optional

The matplotlib axes on which to plot. If None, then the current Axes instance is used.

**kwargsdict, optional

Any keyword arguments accepted by matplotlib.pyplot.plot.

Returns:
lineslist of Line2D

A list of lines representing the plotted data.

plot_error(ax=None, **kwargs)[source]#

Plot the profile errors.

Parameters:
axmatplotlib.axes.Axes or None, optional

The matplotlib axes on which to plot. If None, then the current Axes instance is used.

**kwargsdict, optional

Any keyword arguments accepted by matplotlib.pyplot.fill_between.

Returns:
polymatplotlib.collections.PolyCollection or None

A PolyCollection containing the plotted polygons, or None if no errors were input.

unnormalize()[source]#

Unnormalize the profile back to the original state before any calls to normalize.