CurveOfGrowth#
- class photutils.profiles.CurveOfGrowth(data, xycen, radii, *, error=None, mask=None, method='exact', subpixels=5)[source]#
Bases:
ProfileBaseClass to create a curve of growth using concentric circular apertures.
The curve of growth profile represents the circular aperture flux as a function of circular radius.
- Parameters:
- data2D
ndarray The 2D data array. The data should be background-subtracted. Non-finite values (e.g., NaN or inf) in the
dataorerrorarray are automatically masked.- xycentuple of 2 floats
The
(x, y)pixel coordinate of the source center.- radii1D float
ndarray An array of the circular radii.
radiimust be strictly increasing with a minimum value greater than zero, and contain at least 2 values. The radial spacing does not need to be constant.- error2D
ndarray, optional The 1-sigma errors of the input
data.erroris assumed to include all sources of error, including the Poisson error of the sources (seecalc_total_error).errormust have the same shape as the inputdata. Non-finite values (e.g., NaN or inf) in thedataorerrorarray are automatically masked.- mask2D bool
ndarray, optional A boolean mask with the same shape as
datawhere aTruevalue indicates the corresponding element ofdatais masked. Masked data are excluded from all calculations.- method{‘exact’, ‘center’, ‘subpixel’}, optional
The method used to determine the overlap of the aperture on the pixel grid:
'exact'(default): The exact fractional overlap of the aperture and each pixel is calculated. The aperture weights will contain values between 0 and 1.'center': A pixel is considered to be entirely in or out of the aperture depending on whether its center is in or out of the aperture. The aperture weights will contain values only of 0 (out) and 1 (in).'subpixel': A pixel is divided into subpixels (see thesubpixelskeyword), each of which are considered to be entirely in or out of the aperture depending on whether its center is in or out of the aperture. Ifsubpixels=1, this method is equivalent to'center'. The aperture weights will contain values between 0 and 1.
- subpixelsint, optional
For the
'subpixel'method, resample pixels by this factor in each dimension. That is, each pixel is divided intosubpixels**2subpixels. This keyword is ignored unlessmethod='subpixel'.
- data2D
Examples
>>> import numpy as np >>> from astropy.modeling.models import Gaussian2D >>> from photutils.centroids import centroid_2dg >>> from photutils.datasets import make_noise_image >>> from photutils.profiles import CurveOfGrowth
Create an artificial single source. Note that this image does not have any background.
>>> gmodel = Gaussian2D(42.1, 47.8, 52.4, 4.7, 4.7, 0) >>> yy, xx = np.mgrid[0:100, 0:100] >>> data = gmodel(xx, yy) >>> bkg_sig = 2.1 >>> noise = make_noise_image(data.shape, mean=0., stddev=bkg_sig, seed=0) >>> data += noise >>> error = np.zeros_like(data) + bkg_sig
Create the curve of growth.
>>> xycen = centroid_2dg(data) >>> radii = np.arange(1, 26) >>> cog = CurveOfGrowth(data, xycen, radii, error=error)
>>> print(cog.radius) [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25]
>>> print(cog.profile) [ 135.14750208 514.49674293 1076.4617132 1771.53866121 2510.94382666 3238.51695898 3907.08459943 4456.90125492 4891.00892262 5236.59326527 5473.66400376 5643.72239573 5738.24972738 5803.31693644 5842.00525018 5850.45854739 5855.76123671 5844.9631235 5847.72359025 5843.23189459 5852.05251106 5875.32009699 5869.86235184 5880.64741302 5872.16333953]
>>> print(cog.profile_error) [ 3.72215309 7.44430617 11.16645926 14.88861235 18.61076543 22.33291852 26.05507161 29.7772247 33.49937778 37.22153087 40.94368396 44.66583704 48.38799013 52.11014322 55.8322963 59.55444939 63.27660248 66.99875556 70.72090865 74.44306174 78.16521482 81.88736791 85.609521 89.33167409 93.05382717]
Plot the curve of growth.
(
Source code,png,hires.png,pdf,svg)
Normalize the profile and plot the normalized curve of growth.
(
Source code,png,hires.png,pdf,svg)
Plot a couple of the apertures on the data.
(
Source code,png,hires.png,pdf,svg)
Attributes Summary
A list of
CircularApertureobjects used to measure the profile.The unmasked area in each circular aperture as a function of radius as a 1D
ndarray.The curve-of-growth profile as a 1D
ndarray.The curve-of-growth profile errors as a 1D
ndarray.The profile radius in pixels as a 1D
ndarray.Methods Summary
calc_ee_at_radius(radius)Calculate the encircled energy at a given radius using a cubic interpolator based on the profile data.
Calculate the radius at a given encircled energy using a cubic interpolator based on the profile data.
normalize([method])Normalize the profile.
plot([ax])Plot the profile.
plot_error([ax])Plot the profile errors.
Unnormalize the profile back to the original state before any calls to
normalize.Attributes Documentation
- apertures#
A list of
CircularApertureobjects used to measure the profile.
- profile_error#
The curve-of-growth profile errors as a 1D
ndarray.If no
errorarray was provided, an empty array with shape(0,)is returned.
- radius#
The profile radius in pixels as a 1D
ndarray.This is the same as the input
radii.Note that these are the radii of the circular apertures used to measure the profile. Thus, they are the radial values that enclose the given flux. They can be used directly to measure the encircled energy/flux at a given radius.
Methods Documentation
- calc_ee_at_radius(radius)[source]#
Calculate the encircled energy at a given radius using a cubic interpolator based on the profile data.
Note that this method assumes that input data has been normalized such that the total enclosed flux is 1 for an infinitely large radius. You can also use the
normalizemethod before calling this method to normalize the profile to be 1 at the largest inputradii.
- calc_radius_at_ee(ee)[source]#
Calculate the radius at a given encircled energy using a cubic interpolator based on the profile data.
Note that this method assumes that input data has been normalized such that the total enclosed flux is 1 for an infinitely large radius. You can also use the
normalizemethod before calling this method to normalize the profile to be 1 at the largest inputradii.This interpolator returns values only for regions where the curve-of-growth profile is monotonically increasing.
- normalize(method='max')#
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)#
Plot the profile.
- Parameters:
- ax
matplotlib.axes.AxesorNone, optional The matplotlib axes on which to plot. If
None, then the currentAxesinstance is used.- **kwargsdict, optional
Any keyword arguments accepted by
matplotlib.pyplot.plot.
- ax
- Returns:
- lineslist of
Line2D A list of lines representing the plotted data.
- lineslist of
- plot_error(ax=None, **kwargs)#
Plot the profile errors.
- Parameters:
- ax
matplotlib.axes.AxesorNone, optional The matplotlib axes on which to plot. If
None, then the currentAxesinstance is used.- **kwargsdict, optional
Any keyword arguments accepted by
matplotlib.pyplot.fill_between.
- ax
- Returns:
- poly
matplotlib.collections.PolyCollectionorNone A
PolyCollectioncontaining the plotted polygons, orNoneif no errors were input.
- poly