Geda 2022 AJ 163 202
Geda 2022 AJ 163 202
3847/1538-3881/ac5908
© 2022. The Author(s). Published by the American Astronomical Society.
PetroFit: A Python Package for Computing Petrosian Radii and Fitting Galaxy Light
Profiles
Robel Geda1 , Steven M. Crawford9 , Lucas Hunt2,3 , Matthew Bershady4,5,6 , Erik Tollerud1 , and
1
Solohery Randriamampandry5,7,8
Space Telescope Science Institute (STScI), 3700 San Martin Drive, Baltimore, MD 21218, USA; robel@princeton.edu
2
United States Naval Observatory, 3450 Massachusetts Avenue NW, Washington, DC 20392, USA
3
Computational Physics, Inc., 8001 Braddock Road, Suite 210, Springfield, VA 22151-2110, USA
4
University of Wisconsin–Madison, Department of Astronomy, 475 North Charter Street, Madison, WI 53706-1582, USA
5
South African Astronomical Observatory, P.O. Box 9, Observatory 7935, Cape Town, South Africa
6
Department of Astronomy, University of Cape Town, Private Bag X3, Rondebosch 7701, South Africa
7
Southern African Large Telescope, P.O. Box 9, Observatory 7935, Cape Town, South Africa
8
A&A, Department of Physics, Faculty of Sciences, University of Antananarivo, B.P. 906, Antananarivo 101, Madagascar
Received 2021 September 26; revised 2022 February 10; accepted 2022 February 23; published 2022 April 8
Abstract
PetroFit is an open-source Python package based on Astropy and Photutils that can calculate Petrosian profiles and
fit galaxy images. It offers end-to-end tools for making accurate photometric measurements, estimating
morphological properties, and fitting 2D models to galaxy images. Petrosian metric radii can be used for model
parameter estimation and aperture photometry to provide accurate total fluxes. Correction tools are provided for
improving Petrosian radii estimates affected by galaxy morphology. PetroFit also provides tools for sampling
Astropy-based models (including custom profiles and multicomponent models) onto image grids and enables
point-spread function convolution to account for the effects of seeing. These capabilities provide a robust means of
modeling and fitting galaxy light profiles. We have made the PetroFit package publicly available on GitHub
( PetroFit/petrofit) and PyPi (pip install petrofit).
Unified Astronomy Thesaurus concepts: Astronomy software (1855); CCD photometry (208); Regression (1914);
Galaxies (573)
1
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Graham et al. (1996) and Graham & Driver (2005) solved for L
(r) by substituting x = bn (r re )1 n , which yields
e bn
L (r ) = Ie re2 2pn g (2 n , x ) , (3 )
(bn )2n
where γ(2n, x) is the incomplete gamma function,
x
g (2 n , x ) = ò0 e-t t 2n - 1dt. (4 )
⎨ ⎢
⎩ ⎣⎝ re ⎠ ⎦⎭ Equation (7). Thus, bn is defined as the value that satisfies the
following relation between the complete and incomplete
where I is the intensity at position (x, y); r is the radius from the gamma functions (Ciotti 1991):
center that corresponds to (x, y); re is the effective radius, which
is equal to the projected half-light radius; Ie is the intensity at 1
g (2n , bn) = G (2 n ). (7 )
the half-light radius (Ie = I(re)); and n is the Sérsic index that 2
determines the steepness of the profile. The constant bn is The effective intensity (Ie) is the intensity exactly at re and
defined such that re contains half of the total flux. Figure 2 can be defined as Ie = I(re), where Ie determines the amplitude
shows an example Sérsic profile with (n = 1, Ie = 1, re = 25). of the profile and is related to the intensity at the center of the
2
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Figure 2. The COG represents the total flux enclosed at each radius and
asymptotically approaches the total flux (black dashed–dotted horizontal line). Figure 3. Plot of the Petrosian profile (η(r)) of a Sérsic profile with (Ie = 1,
This example shows the COG of a Sérsic profile with (n = 1, Ie = 1, re = 25). re = 25, n = 1). Note that the profile has the property where η(0) = 1 at the
The half-light radius (re = 25) contains half of the total flux that is contributed center of the galaxy (r = 0) and drops to zero at the edge.
by the blue dotted area in Figure 1.
where
Sérsic profile (I0 = I(0)) as follows:
rmaj (x , y) = (x - x 0) · cos (q ) + ( y - y0) · sin (q ) ,
Ie =
I0
. (8 ) rmin (x , y) = - (x - x 0) · sin (q ) + ( y - y0) · cos (q ).
exp {bn }
2.1.4. Ellipticity, Elongation, and Orientation 2.1.5. Curve of Growth
Real galaxies that are well described by Sérsic profiles are The curve of growth (COG) of a galaxy is the relationship
usually not perfectly symmetrical and often have elliptical between the radius (from the galaxy center) and the total
distributions (Ferrari et al. 2004). We define two quantities, intensity within that radius. It represents the cumulative flux
ellipticity (ellip) and elongation (elong), that can be used to enclosed at a given radius. For an ideal galaxy that is well
describe the elliptical distribution of Sérsic profiles: described by a Sérsic profile, the COG is given by L(r).
Figure 2 shows an example COG for a Sérsic profile with
b elong - 1
ellip = 1 - = , (9 ) (n = 1, Ie = 1, re = 25).
a elong
2.2. Petrosian Profiles
a 1
elong = = , (10) The Petrosian profile or Petrosian index (η) is a dimension-
b 1 - ellip
less profile that represents the rate of change in the enclosed
where a is the unit length of the semimajor axis, and b is the light as a function of radius. It was first introduced by Petrosian
(1976), who conceptualized it as a means of defining the sizes
corresponding semiminor axis. A circle corresponds to
(radii) of galaxies. Petrosian originally defined the Petrosian
ellip = 0 and elong = 1. Ellipticity ranges from zero to 1, index as a ratio of the average surface brightness up to a radius
while elongation ranges from 1 to infinity. The SExtractor divided by the surface brightness at that radius. Since η is
(Bertin & Arnouts 1996) and Photutils packages use elonga- defined as an intensity ratio, it is not affected by the surface
tions for apertures, while the Astropy modeling submodule brightness dimming effects that result from the cosmological
uses ellipticity for Sérsic models. expansion of the universe. PetroFit follows Kron (1980) and
Ellipticities (ellip) and rotation angles (θ) are used to relate Bershady et al. (2000) and defines the Petrosian profile (η) as
Cartesian coordinates to elliptical radii with the Astropy and the reciprocal of the original formulation by Petrosian. This
PetroFit packages. For an elliptical profile centered at (x0, y0) results in a profile that has the property where η(0) = 1 at the
with an effective radius re, the following relation is used:10 center of the galaxy and drops to zero at the edge (see
Figure 3). As such, the Petrosian profile (η(r)) is defined as
2
r (x , y ) ⎞ I (r ) A (r )
r (x , y ) = (rmaj (x , y))2 - ⎜⎛ min ⎟ , (11) h (r ) = = I (r ) , (12)
⎝ 1 - ellip) ⎠
( áI (r )ñ L (r )
where η(r) is the Petrosian index at r, I(r) is the surface
10
See Astropy’s (v4.2) Sérsic2D.evaluate function brightness at r, 〈I(r)〉 is the average surface brightness within r,
3
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
L(r) is the total flux within r, and A(r) is the aperture area. 2.3.1. Petrosian Half-light Radius
For elliptical apertures, the area is given as A(r) = π · The Petrosian half-light radius is the radius that contains half
(1 − ellip) · r2. of the Petrosian total flux. This quantity is especially important
Graham & Driver (2005) and Graham et al. (2005) derived because it is approximately (or exactly, in ideal cases) equal to
the Petrosian profile of a Sérsic profile as a function of the the Sérsic effective radius. The Petrosian half-light radius can
logarithmic slope of the Sérsic profile α(x, n),11 be computed by numerically finding the radius that encloses
2 2 n g (2 n , x ) half of the Petrosian total flux. Consequently, the Petrosian
h (x , n ) = = , (13) half-light radius (r50) can be defined as the radius that satisfies
a (x , n ) e-x x 2n
the following expression:
where x is given by the function x (r ) = bn (r re )1 n , n is the 1
Sérsic index, and γ is the incomplete gamma function. L (r50) = L (rtotal ). (16)
2
2.2.1. Petrosian Radius and Eta
2.3.2. Concentration Index
The Petrosian radius is the radius where the Petrosian profile
is equal to a special Petrosian index eta (ηpetro). Following The concentration index is the ratio of the radii containing a
Bershady et al. (2000), the Petrosian radius is defined as the specified fraction of the total flux and can be generalized as
radius where η = 0.2. Thus, the Petrosian radius (rpetro) and eta follows (Kent 1985; Bershady et al. 2000):
(ηpetro) can be expressed as r
Cio º 5 · log ⎛ o ⎞ , (17)
hpetro º h 0.2 = h (rpetro) = 0.2.
⎜ ⎟
(14) ⎝ ri ⎠
where ro and ri are the outer and inner radii, enclosing o% and i
2.2.2. Petrosian Total Flux Radius and Epsilon % of the total flux, respectively. The concentration index is
The Petrosian total flux radius is, as the name implies, the related to the profile shape and can be used as a proxy for
radius that encloses the total flux of the galaxy. Since Sérsic morphology (Graham et al. 2001; Crawford 2006). Some
profiles extend to infinity, it is not possible to define a radius commonly used concentration indices are C2080 (Kent 1985;
that contains 100% of the total flux (that would equate to a Bershady et al. 2000; Conselice 2003) and C5090 (Blanton et al.
radius at infinity). It is also not practical to consider minute flux 2001):
values at very large radii because real images of galaxies
contain noise. For these reasons, PetroFit considers the radius r
C2080 = 5 · log ⎛ 80 ⎞ ,
⎜ ⎟ (18)
that contains 99% of the galaxy’s light to be the Petrosian total ⎝ r20 ⎠
flux radius (Crawford 2006). To calculate the Petrosian total
flux radius, we must multiply the Petrosian radius by a r
C5090 = 5 · log ⎛ 90 ⎞.
⎜ ⎟ (19)
constant. This constant is called “epsilon” and is set to 2 by ⎝ r50 ⎠
default (Bershady et al. 2000). This default value is also
The C2080 correlates better with the Sérsic index (and epsilon).
adopted by the Sloan Digital Sky Survey (SDSS; Strauss et al.
2002). Thus, we can define the Petrosian total flux radius as However, in the presence of image degradation, C5090 may be
follows: more immune from systematic effects.
rtotal = · rpetro. (15) 2.3.3. Petrosian Concentration Index
We define the concentration of radii derived from Petrosian
2.3. Total Flux and Petrosian Corrections indices as follows:
The Petrosian total flux is computed by setting ò = 2 by r (h )
default (see Section 2.2.2). But this approach is an approx- Pio º 5 · log ⎛⎜ o ⎞⎟ , (20)
imation and is susceptible to errors that arise from different ⎝ r (hi ) ⎠
galaxy morphologies. In particular, ò is dependent on how where r(η0) and r(ηi) are the outer and inner Petrosian radii,
concentrated a galaxy’s light profile is. The more concentrated
corresponding to η0 and ηi Petrosian indices, respectively. This
a galaxy’s light profile is, the larger the value of ò needed to
produce r99. To understand this, let us consider two profiles, A definition of concentration is useful because it can be computed
and B, with the same total flux radii (i.e., equal to r99) but directly from the Petrosian profile, without the need to estimate
different concentrations (i.e., n(A) > n(B)). Since profile A has radii using the COG (see Appendix B.2.4).
a higher concentration, it will have an rpetro closer to the center We also define a Petrosian concentration index, P0502, as
of the profile relative to r99 simply because its profile is more follows:
concentrated. Thus, the multiplication factor (ò) needed to r (h 0.2) ⎞
produce the total flux radius (r99 or rtotal) for A is relatively P0502 = 5 · log ⎛⎜ ⎛ rpetro ⎞⎟.
⎟ = 5 · log ⎜ (21)
larger than B. Thus, to accurately estimate r99, we must apply ⎝ r (h 0.5) ⎠ ⎝ r (h 0.5) ⎠
corrections by first estimating the appropriate ò value. Once the
appropriate ò value is estimated, rtotal (which PetroFit defines as 3. Software
rtotal ≡ r99) can be computed by rtotal = rpetro · ò.
PetroFit is a Python-based package for computing and fitting
11
Graham et al. (2005) used the original definition of the Petrosian profile; various galaxy profiles. It builds on packages such as Astropy
thus, the expression they provided is the reciprocal of Equation (13). and Photutils to provide a set of tools for end-to-end profile
4
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
construction and parameter fitting. As an open-source package, The plane model is fit using a linear least-squares fitting
PetroFit is made available to the public and can be installed algorithm provided by Astropy’s modeling module and directly
via PyPi. We discuss some of PetroFit’s key features in this sampled (without integrating or oversampling) into a 2D model
section. image. The user can then subtract the background image from
the initial image to produce a background-subtracted image.
3.1. Photometry Tools
In order to make accurate measurements of galaxy proper- 3.1.3. Aperture Photometry
ties, we need to make accurate photometric measurements The COG and the Petrosian η function are both radial
while processing images of galaxies. Photutils (Bradley et al. profiles. As such, photometric measurements must be made
2020), an Astropy-affiliated package for photometry, offers a using apertures of varying radii from the center of the source. It
wide array of tools to perform photometry. We modify or build is also important to track the aperture areas and account for
on the tools in Photutils, and in this subsection, we introduce masked pixels, since the Petrosian is computed using the
some of the photometry utilities we have made available in average surface brightness (see Equation (12) and
PetroFit. Section 3.2.2).
The PetroFit photometry_step function constructs
3.1.1. Image Segmentation and Source Catalogs multiple concentric elliptical apertures and makes accurate
flux measurements using Photutils. The elliptical shape of the
It is often necessary to identify and make a catalog of
apertures can be set by providing an elongation and rotation
sources in an image before making photometric measurements.
angle (default values correspond to a circle). The radii of the
It is also useful to identify pixels in the image that are
apertures are defined by the user and provided as a Python list
associated with a given source so a mask can be constructed for
or array. PetroFit offers utility functions that can make lists of
that source. This is used to exclude the light from neighboring
linearly or logarithmically spaced radii. Error images and mask
objects that would otherwise contaminate or bias the light
maps can be provided for error estimation and pixel masking,
profile. The PetroFit make_catalog function uses photo-
respectively. The method returns the result in a tuple of three
metry routines in Photutils to make segmentation maps,
separate arrays that contain the flux measurements, error
deblend sources that overlap in the image, and produce a
estimates, and aperture areas. This function can also overplot
catalog with useful photometric information about the sources.
the apertures used for the measurement on the input image.
To identify sources, the image is partitioned into multiple
The PetroFit source_photometry function is designed
segments, and a segmentation map is constructed. To achieve to work with Photutils source catalogs and segmentation maps.
this, the image is first smoothed with a Gaussian kernel if a
Given a source in the Photutils catalog, the function masks
kernel size is provided and segmented using Photutils’
surrounding pixels that belong to nearby sources (each source
detect_sources functionality. Photutils constructs a seg-
pixel is assigned to a single source), optionally performs
mentation map by assigning a label to every pixel in the
background subtraction using a 2D plane model, and then runs
smoothed image such that pixels with the same label are part of
the photometry_step function. The source_photome-
the same source. A minimum source size can be specified by
try function also determines the appropriate aperture shape
providing a cutoff for the number of connected pixels that have
(i.e., elongation or ellipticity) and orientation using the
values above a user-provided threshold. Overlapping sources
information in the Photutils catalog.
are separated using Photutils’ deblend_sources function
that uses a combination of multithresholding and watershed
segmentation. The resulting catalog and segmentation map can 3.2. Petrosian Tools
then be used to identify sources of interest and mask pixels of Given photometric measurements, PetroFit can compute the
nearby sources when performing photometry measurements. Petrosian profile, as well as associated radii and concentrations.
PetroFit also provides plotting tools to visualize Photutils In this section, we discuss how the Petrosian η(r) is discretely
segmentation maps. computed and how galaxy properties can be derived from it.
We also discuss corrections applied to the measurements to
3.1.2. Background Noise Subtraction provide accurate photometry.
To construct a COG that converges to the total flux of a
galaxy, we must carefully estimate the noise in the image and 3.2.1. Analytically Computed Profiles
make the appropriate subtractions. This is especially important PetroFit includes functions to analytically compute Petrosian
for faint galaxies that have low signal-to-noise ratios. To deal profiles and curves of growth for ideal Sérsic profiles with
with this, PetroFit offers an “image continuum” fitting tool, known parameters. The following profiles and utilities are
fit_background, that fits background pixels using an available as part of the package.
Astropy model, and then that model can be subtracted from
the image. petrosian_profile (η(r)). Given the effective radius and
The background subtraction tool first makes a background Sérsic index of a Sérsic profile, this function computes the
image by masking all of the sources identified in the Petrosian profile using Equation (13). A 1D Astropy fittable
segmentation stage. Note that our definition of background model version is also available for this function but may not
here is pixels that do not belong to a source. Once the be useful for fitting profiles derived from real galaxy images
background image is made, background pixels above a (see Section 3.2.4).
specified threshold value are also masked. The remaining sersic_enclosed (L( r)). Given the effective intensity,
unmasked pixels are used to fit an Astropy model. The default effective radius, and Sérsic index of a Sérsic profile, this
model is set to an Astropy Planar2D model. function computes the total enclosed flux at an input radius
5
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
according to Equation (3). This function can be used to make adjusted, and interpolation can be switched off (to find the
a COG for ideal Sérsic profiles. A 1D Astropy fittable model closest data point) if necessary.
version is also available for this function. r_total_flux (rtotal). The total flux radius is computed by
sersic_enclosed_inv (r(L)). This function computes the multiplying r_petrosian with epsilon (see Section 2.2.2).
inverse of Equation (3) by solving for r. Given the effective Epsilon is set to 2 by default and can be adjusted. The rtotal
intensity, effective radius, and Sérsic index of a Sérsic depends on the assumed functional form of the radial profile
profile, this function computes the radius that encloses the of the galaxy, and we discuss how to make these corrections
input fraction of the total light flux. in Section 3.2.4. If the image includes a World Coordinate
System (WCS), PetroFit will convert the radius into
arcsecond units based on the corresponding pixel scale.
3.2.2. Discretely Computed Petrosian Profiles
total_flux (L(rtotal)). The total Petrosian flux is computed by
Given an array of enclosed fluxes (L) and corresponding referring to the input COG and identifying the total enclosed
aperture areas (A), the Petrosian profile can be computed flux at r_total_flux. If the COG does not extend to the
discretely as follows. r_total_flux, a Numpy nan is returned. Note that one
can set r_total_flux to the largest aperture radius
1. Estimate the surface brightness by finding the average available in the photometric data (rmax) by defining the
flux between the current index (i) and the last index appropriate epsilon value (i.e., = rmax rpetro ).
(i − 1). Note that the gap between apertures affects the total_flux_uncertainty. The uncertainty or error in the total
accuracy of the surface brightness at i; thus, it is enclosed flux at r_total_flux is only available if
recommended to use apertures with radii that are photometric uncertainties (astropy.uncertainty
incremented by a small number of pixels: object) are provided.
L [i ] - L [i - 1 ] r_half_light (r50). The half-light radius is computed by
I [i ] » . (22) finding the radius that encloses half of total_flux in the
A [i ] - A [i - 1 ]
COG (see Figure 1 and 2). This value can be converted into
2. Estimate the average surface brightness by taking the flux arcsec by providing a WCS.
at i and dividing it by the corresponding aperture area: concentration_index (Cio). The concentration index is
L [i ] computed by first identifying the radii that contain the
áI [i ]ñ = . (23) requested fractions of the total flux and computing their
A [i ]
concentration ratio as described in Section 2.3.2.
3. Compute the Petrosian index at i using the estimated
values in steps 1 and 2:
I [i ] L [i ] - L [i - 1 ] ⎞ A [i ] 3.2.4. Petrosian Corrections
h [i ] = =⎛ ⎜ · ⎟ . (24)
áI [i ]ñ ⎝ A [i ] - A [i - 1 ] ⎠ L [i ] To first order, the Petrosian magnitude is independent of
redshift in the local universe, as it depends on the ratio of two
surface brightnesses, but because it is based on profile shape,
In discrete computations, the Petrosian profile cannot be changes in the profile due to morphological k-corrections still
computed at the first index even if it corresponds to the center apply (Crawford 2006). However, the real strength of Petrosian
pixel (r[i0] = 0). In real images, the surface brightness of a magnitudes versus other variable aperture photometry, such as
galaxy is binned into pixels, and to accurately determine I0, one Kron magnitudes (Kron 1980), is that the Petrosian radius only
would need to infinitely oversample the central region. In other depends on the light interior to this radius. This aspect leads to
words, each pixel corresponds to a total surface brightness small random errors in the measurement of rpetro. Nonetheless,
integrated within the area of the pixel as opposed to the surface the magnitude within 2 · rpetro, relative to a true, total
brightness at the pixel coordinates. As such, PetroFit sets the magnitude, is still profile-dependent. Although 99% of the
first Petrosian value to numpy.nan when returning a light from an exponential profile (n = 1) is recovered within
discretely computed array of Petrosian indices. PetroFit takes 2 · rpetro, only 82% of the light for an r1/4 profile is measured
advantage of fact that the Petrosian index at the center of a within 2 · rpetro (Graham & Driver 2005). Similar results apply
galaxy is equal to 1 when computing radii internally. to the Kron (Kron 1980) scheme, as discussed in Bershady
(1995). Because of this, we need to adjust rtotal by finding the
3.2.3. Petrosian Radii and Concentration Indices appropriate epsilon (ò) value (see Section 2.2.2).
The concentration index and “correct” rtotal are related; thus,
Given a COG measurement in the form of arrays containing
a relationship between the concentration index and ò can be
aperture radii, aperture areas, and enclosed fluxes, PetroFit
derived. We attempt to derive this relationship by simulating
constructs a Petrosian profile as described in Section 3.2.2.
Sérsic profiles with varying concentrations and measuring the
Once the Petrosian profile is constructed, Petrosian radii and
radii that contain 99% of the total fluxes (i.e., rtotal; see
concentrations can be computed. We describe how each
Appendix B). Real images of galaxies contain distortions
property is computed in this section.
through passing through the atmosphere or the optics of a
r_petrosian (rpetro). The Petrosian radius is computed by telescope, and the images are smeared according to the point-
identifying the radius where the Petrosian profile reaches the spread function (PSF). The smearing of light results in a
Petrosian eta (ηpetro) value. By default, ηpetro is set to 0.2 as reduction in profile concentration, causing a skew in the
discussed in Section 2.2.1. The values of the Petrosian profile relationship derived from simulated profiles (see Figures 4 and
are interpolated, and the radius where the profile intersects 5). To accurately calculate the total flux, further corrections
with ηpetro is identified as rpetro. The eta value can be user must be applied to the estimates of η based on the PSF,
6
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
7
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
8
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Table 1 Table 3
Gaussian Profile n = 0.5 De Vaucouleurs Profile n = 4
Table 2
Exponential Profile n = 1 Photometric measurements were then performed on the
simulated profiles. First, the synthetic images were segmented
Values Sérsic Uncorrected Corrected using the make_catalog catalog function. The COG for
eta 0.2 0.2 (1.0) 0.2 (1.0) each image was constructed using source_photometry
epsilon 1.82 2.0 (1.1) 1.8 (0.99) without background subtraction. A Petrosian profile was
r_petrosian 108.77 108.77 (1.0) 108.77 (1.0) constructed using the COG. The total flux radius was defined
r_half_light 50 49.76 (1.0) 49.51 (0.99)
using the Petrosian profile and the default ò value of 2. We refer
r_total_flux 197.76 217.54 (1.1) 195.66 (0.99)
total_flux 29,871.24 29,703.68 (0.99) 29,553.21 (0.99)
to the radii and concentrations derived using the default ò value
r_20 24.39 24.5 (1.0) 24.5 (1.0) as “uncorrected.” We also use a correction grid to generate an
r_80 87.64 88.27 (1.01) 87.52 (1.0) improved estimate of ò using the PetrosianCorrection
c2080 2.78 2.78 (1.0) 2.76 (0.99) class.
Tables 1–3 show the resulting measurements. The “Sérsic”
column represents analytical values derived from equations in
is used for nonlinear 2D models. Astropy implements this Section 1, the “Uncorrected” column shows measurements
algorithm using SciPy’s optimize.leastsq function, derived using ò = 2, and the “Corrected” column shows values
which is a wrapper around MINPACK’s lmdif and lmder derived using improved estimates of ò. The values in
algorithms (Moré et al. 1980). parentheses show the ratios of measurements to their corresp-
onding analytical values. As can be seen in these results, the
4. Demonstration of the Software corrected photometric values provide reasonably accurate
measurements for these ideal cases.
In this section, we showcase the capabilities outlined in the
prior sections by testing the software on simulated and real data
sets. To test the accuracy of PetroFit’s parameter estimates, we 4.2. Single-component Galaxy
perform photometry on synthetic images of galaxies (generated
by sampling Sérsic models onto pixel grids) and predict their Real images of galaxies contain background noise and are
Sérsic parameters. We also test PetroFit’s fitting capability by smeared by a PSF. In this subsection, we demonstrate how the
modeling the light profiles of real galaxies in optical and near- different tools in PetroFit can be used together to do a
infrared images taken by the Hubble Space Telescope comprehensive analysis of galaxy light profiles. We first
and SDSS. perform photometric measurements and estimate the Sérsic
parameters for the galaxy. Using the estimated Sérsic
4.1. Synthetic Sérsic Images parameters as an initial guess, we construct a PSFModel
and fit the galaxy image.
We first demonstrate photometric measurements made by The data we use in this section are a cutout of a group of
PetroFit in ideal conditions by simulating images of Sérsic bright galaxies in Abell 2744. The original data have a
profiles with no noise. We simulate the Sérsic profiles resolution of 60 mas pixel–1 and were acquired by the Hubble
described in Section 2.1.2, namely, Gaussian (n = 0.5), Frontier Fields (Lotz et al. 2017) team via the WFC3
exponential (n = 1), and de Vaucouleurs (n = 4). To simulate
instrument (using the F105W filter). This data set can be
the images, we defined Astropy Sérsic2D models and placed
directly downloaded from the Mikulski Archive for Space
the center of the models at the center of the output image. We
set the image dimensions to 3500 pixels, a large image size, in Telescopes. The galaxy we selected for this demonstration is an
order to include the flux without encountering any image edge elliptical galaxy (α = 3°. 596248, δ = −30°. 388517) that can be
effects in the measurement. For each simulated profile, the well described by a single-component Sérsic profile (see the
parameters of the Sérsic model were set to (Ie = 1, re = 50, center of the first panel in Figure 7). A 150 × 150 pixel cutout
x0 = 1750, y0 = 1750, ellip = 0, θ = 0). We used PSFModel of the target was made for this demonstration, and its
to sample the model onto a pixel grid (note that PSFModel is background was subtracted by fitting a 2D plane (see
independent of the photometric measurement machinery) and Section 3.1.2) to a 3σ clipped version of the cutout. We refer
applied an oversampling factor of 10 to the center 100 × 100 to this cutout as the galaxy image to avoid confusion with other
pixels for all of the model images. cutouts.
9
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Figure 7. The inputs, steps, and results of fitting a single-component galaxy are shown in this figure. The top row shows, left to right, (a) the background-subtracted
input F105W image of the target, (b) the masked image used for photometric measurements (also overplots the apertures as white ellipses), (c) the COG from
photometric measurements as a function of aperture radius, and (d) the Petrosian profile derived from the photometric measurements. The bottom row shows, left to
right, (e) an overplot of Petrosian radii to show their extent, (f) the fitted Sérsic model sampled onto an image (PSF convolved), (g) the residual produced by
subtracting the model image from the original data, and (h) the normalized PSF (cutout of a bright star) that was used for fitting.
10
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Figure 8. These panels show Lupton-RGB ([i, r, g]-band) images of M91, a corresponding multicomponent Sérsic fit, and the resulting residual. Three components
were used to fit this light profile, one each for the disk, bar, and central core. The images were made using a stretch factor of 0.9 and Q = 2. The left panel shows the
SDSS M91 cutout that was used for fitting, the middle panel shows the fitted model image, and the right panel shows the residual. The spiral arm, as well as the blue
clusters (zoomed-in white box), can also be seen in the residual image.
Using sersic_enclosed, we compute the analytical To perform a full analysis of the light profile, we also fit the
total Sérsic flux of the model at infinity and compare it to the galaxy in the g, r, and z bands. For each of these bands, the fit
photometrically derived Petrosian total flux of the galaxy in the from the i band was used as the initial guess of the compound
image. The total Sérsic flux is 21.684 mag, while the corrected model parameters. This allowed us to skip the photometry,
Petrosian total flux of the galaxy image was measured to be Petrosian, and preliminary fitting steps for these bands. After
21.7593 ± 0.0026 mag. The corrected Petrosian total flux of the fitting the models, we combine the i, r, and, g bands into an
model was measured to be 21.75899 mag, which is 93% of the RBG image to illustrate the galaxy, fitted model, and residual
total Sérsic flux (see Section 2.2.2). (see Figure 8). The resulting residual image clearly shows the
spiral arms of M91, as well as blue clusters embedded in it. The
bar component oversubtracts the profile, mostly because the
4.3. Multicomponent Galaxy radial profile used was elliptical as opposed to “boxy,” and
We further demonstrate PetroFit’s fitting capabilities by actual galaxy bars quickly truncate at their edges. We plan on
fitting the light profile of Messier 91 (M91), a barred galaxy introducing various radial profiles, including boxy profiles, in
with multiple Sérsic components. Unlike single-component the future versions of PetroFit (see Section 6 and Figure 11).
galaxies, multicomponent light profiles require careful and The final fits running on an Intel Core i9-10900K processor
complex decompositions. To achieve this, we used multiband (20 MB cache, 3.7 GHz) completed the fit under 2.5 minutes
SDSS images (1000 × 1000 pixels covering 20′) centered on band–1. For the core of the galaxy, each band had a Sérsic index
M91 (α = 188°. 860221, δ = 14°. 496339). After subtracting the of approximately 4, while the disk and bar components had an
background by fitting a plane to a 3σ clipped version of the index of 0.5.
image, we used the i band to estimate the morphological
parameters of the source as described in Section 4.2.1. We
4.4. Simultaneously Fitting Overlapping Galaxies
derived rough estimates for our initial guesses by following the
steps outlined in Section 4.2.2. For fitting the galaxy, we A key capability of PetroFit is its ability to simultaneously fit
zoomed into the galaxy by creating a cutout of 300 × 300 and measure the photometry of multiple sources. Images of
pixels. Using the rough parameter guess we derived, we galaxies with nearby neighbors pose a challenge because their
defined three Sérsic components, one for the disk and two light profiles overlap. This is especially true in cluster
oversampled components for the core and bar. Using a nearby environments. In this section, we demonstrate how PetroFit
star (α = 188°. 740014, δ = 14°. 495436) as a PSF, we found that can be used to construct photometry catalogs of overlapping
the image had enough resolution such that the PSF was not sources and fit compound models. The group of galaxies we
needed for the galaxy decomposition; therefore, we disabled selected for this measurement are a part of the Hubble Frontier
that feature for all components. For the disk, we applied a Fields data discussed in Section 4.2.1. The group of galaxies
sigma mask to mask out the core and bar of the galaxy. We located at (α = 3°. 579222, δ = −30°. 380186) are faint and
then fit the disk using this masked image to better constrain our isolated from bright sources. The image is background-
initial guess. The core and bar components were oversampled subtracted using a 2D plane model as described in
by a factor of 5. For the core, we masked out the disk and bar Section 3.1.2. We first make photometric and size measure-
using an elliptical mask that was visually parameterized. Lastly, ments to inform our initial guesses. We construct a catalog
the bar was fit after masking out the core and disk using a mask using make_catalog with the following settings: the
that was also visually parameterized. These three preliminary detection threshold was set to the standard deviation computed
fits bring the components closer to the final fit. We combined using sigma_clipped_stats (3σ clipping), a smoothing
the three components into a compound model and wrapped it in kernel size of 3 pixels, a smoothing kernel FWHM of 3, a
a PSFModel model with an oversampling factor of 5. We then minimum of 16 connected pixels above the threshold, zero
fit the entire galaxy cutout, which resulted in the final i-band fit. contrast, and deblending enabled. This results in the
11
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Figure 9. This plot shows some of the inputs, steps, and results of fitting a multicomponent model. The top row shows, left to right, (a) the input F105W image of the
group of galaxies, (b) a deblended segmentation map with color-coding for pixels that belong to the same source, and (c) an overplot of the Petrosian radii of each
source. The bottom row shows, left to right, (d) the fitted compound model with 11 Sérsic components sampled onto an image (PSF convolved), (e) the residual image
produced by subtracting the model image from the original data, and (f) a histogram of pixel values in the residual image and a 3σ clipped version of the original
image. Note that the residual image histogram takes on a Gaussian form centered closer to zero than the original image.
identification of 11 galaxies in the image. Once a Photutils field images and compare it to the ASTRODEEP catalogs
catalog is generated, we loop through the catalog and calculate (Merlin et al. 2016). To catalog and measure the sizes of the
the Petrosian profile of each source. From the Petrosian sources in the image, we selected the F105W filter as our
profiles, we compute the sizes of each source. detection image. We estimated the image background by taking
For the fitting step, we construct a Sérsic2D model and a patch in the image with no sources and measuring its standard
make initial guesses for each object as described in deviation, which we used to define a segmentation threshold of
Section 4.2.2, except we do not apply Petrosian corrections 3σ. We segmented and deblended the image using a kernel size
and assume a Sérsic index of 1. This is because the sources are of 3 pixels, FWHM = 3, and a minimum source size of 16
likely to have a low concentration and demonstrate that the pixels. For the deblending step, we set the contrast to 1/100.
initial guesses can be rough estimates. We sum the Sérsic2D Since we planned to use Petrosian radii as apertures for our
models together to create a single compound model. The catalog, we measured the COG and Petrosian radii of each
compound model will have parameters corresponding to each source in the segmentation map we generated. Petrosian
submodel’s parameters, resulting in 77 parameters in total (11 corrections were applied to sources with uncorrected half-light
submodels times 7 parameters for each Sérsic2D submodel). radii greater than 10 pixels (0 6). If the Petrosian profile could
Fitting such a large parameter space is possible because the not be measured for a source, we used twice the bounding box
initial guesses help the fitter converge to a solution. We wrap of the sources’ segmentation as an estimate of the aperture
the compound model in a PSFModel and set it to oversample radius. Using the Petrosian total flux radii as aperture sizes, we
the entire image by a factor of 4. We use the same star cutout as made photometric measurements of each source in the F435W,
Section 4.2.2 as the convolving PSF. The resulting PSFModel F606W, F814W, F105W, F125W, F140W, and F160W filters.
is fit using a Levenberg–Marquardt fitter. The fitter, running on This was conveniently possible (without having to segment
an Intel Core i9-10900K processor (20 MB cache, 3.7–5.3 each image) because the images are pixel-aligned and have the
GHz), was able to simultaneously fit the 11-component model same pixel scales (60 mas pixel–1). This allowed us to apply the
under 4.5 minutes. Figure 9 shows the results. same apertures to all filters. We applied local background
subtractions by fitting a plane to 1σ pixels in cutouts of targets.
Figure 10 shows the results from the multi-aperture measure-
4.5. Large-scale Photometry Catalogs
ments. The first plot shows a magnitude comparison between
In this section, we perform large-scale multiband aperture the PetroFit measurements and the corresponding ASTRO-
photometry on the Hubble Frontier Fields Abell 2744 parallel DEEP catalog.
12
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Figure 10. Left: multifilter absolute AB magnitude comparison between PetroFit aperture photometry and the ASTRODEEP catalog. Right: PetroFit Petrosian
apertures plotted over the F105W image (detection image).
Figure 11. Examples of azimuthal shape functions implemented as custom 2D Astropy (fittable) models. Inspired by PHIR models (Peng et al. 2010), the left and
middle panels show Sérsic models that apply simple rotations to the profile as a function of radius (i.e., θ(r[x, y], m, rin), where m is the number of full rotations, and rin
is the rotation cutoff). The right panel shows a barred Sérsic profile that was generated using a generalized ellipse.
13
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
easily interact with fitted compound models. PetroFit offers would like to thank the developers of Photutils, as much of this
tools to make initial guesses of model parameters. Lastly, work is built on top of the tools they provided.
PetroFit allows for custom models or parameters to be defined This work was made possible by NASA grant AR 15058.
on the fly by virtue of Astropy’s custom modeling. We give thanks to the Space Telescope Science Institute and
the Technical Staff Research Committee (TSRC), a group that
facilitates matching research projects with interested technical
6. Conclusion staff. This research is based on observations made with the
NASA/ESA Hubble Space Telescope obtained from the Space
In this paper, we introduce PetroFit, an open-source Python Telescope Science Institute, which is operated by the Associa-
package for fitting galaxy light profiles and measuring tion of Universities for Research in Astronomy, Inc., under
Petrosian properties. PetroFit offers a wide range of tools for NASA contract NAS 526555.
making accurate photometric measurements, constructing Funding for the SDSS and SDSS-II has been provided by the
curves of growth, and computing Petrosian profiles. Computed Alfred P. Sloan Foundation, the Participating Institutions, the
Petrosian profiles can be used to estimate the projected radii of National Science Foundation, the U.S. Department of Energy,
galaxies, as well as their concentrations. PetroFit includes a 2D the National Aeronautics and Space Administration, the
image-fitting tool set that is built using the modeling package in Japanese Monbukagakusho, the Max Planck Society, and the
Astropy. We demonstrate capabilities, limitations, and potential Higher Education Funding Council for England. The SDSS
use cases for the software by analyzing images of simulated website is http://www.sdss.org/.
and real galaxy light profiles. The SDSS is managed by the Astrophysical Research
The version of PetroFit described in this paper represents an Consortium for the Participating Institutions. The Participating
initial step toward our goal of a robust package for making Institutions are the American Museum of Natural History, the
galaxy size measurements. We plan on continuously improving Astrophysical Institute Potsdam, the University of Basel, the
the software and hope to gain useful feedback from the University of Cambridge, Case Western Reserve University,
astronomical community. In the next iterations, we hope to add the University of Chicago, Drexel University, Fermilab, the
features such as better error estimations in fitted models, Institute for Advanced Study, the Japan Participation Group,
Astropy unit support for Petrosian measurements, and Johns Hopkins University, the Joint Institute for Nuclear
advanced machine learning–based parameter estimates (an Astrophysics, the Kavli Institute for Particle Astrophysics and
experimental decision tree regressor is currently available for Cosmology, the Korean Scientist Group, the Chinese Academy
Petrosian corrections). In future versions of PetroFit, we hope of Sciences (LAMOST), Los Alamos National Laboratory, the
to allow for corrections to be computed using ò80 and P0502. We Max Planck Institute for Astronomy (MPIA), the Max Planck
also hope to officially implement azimuthal shape functions Institute for Astrophysics (MPA), New Mexico State Uni-
defined by Peng et al. (2010), which we refer to as Peng–Ho– versity, Ohio State University, the University of Pittsburgh, the
Impey–Rix (PHIR) models, which use Fourier and bending University of Portsmouth, Princeton University, the United
modes to create complex profiles (see Figure 11 for examples States Naval Observatory, and the University of Washington.
of simple azimuthal Astropy models). We aim to make PetroFit Software: PetroFit (Geda et al. 2022b), Astropy (Astropy
more compatible with similar packages for the purposes of Collaboration et al. 2013), Photutils (Bradley et al. 2020),
interoperability and testing. As part of this effort, we also hope SciPy (Virtanen et al. 2020), Numpy (Harris et al. 2020),
to contribute to Photutils and Astropy features that have been MatPlotLib (Hunter 2007), statmorph (Rodriguez-Gomez
developed here that may be useful beyond the goals of PetroFit. et al. 2019), GALFIT (Peng et al. 2010).
Due to the ability to accurately measure galaxy photometry
and sizes systematically, PetroFit can support a wide range of Appendix A
galaxy evolution studies, including classification of galaxies, List of Models
assessing changes in the size of galaxies, and measurements in
A.1. Astropy
the luminosity function of galaxies. The flexible, object-
oriented design of the code makes it ideal for use in the next All Astropy (v4.2) 2D Models
generation of high-resolution galaxy surveys that will be Model Name Decription
produced by the James Webb Space Telescope and the Roman
Space Telescope. AiryDisk2D Airy disk
We openly invite and strongly encourage all interested Box2D 2D box profile
Disk2D Disk profile with a constant amplitude
parties to leave feedback, bug reports, and feature requests by
TrapezoidDisk2D Disk with a slope
opening tickets in the PetroFit/petrofit GitHub reposi-
Ellipse2D Ellipse with major and minor axis and rotation angle
tory. We hope this package is as useful for the general Gaussian2D 2D Gaussian (can be elliptical) distribution with a
astronomical community as it has been for the authors. rotation angle
Moffat2D Moffat profile (can be elliptical) with alpha (power
We thank our collaborators Dr. Gregory D. Wirth and Dr. index) and gamma (core width)
D. J. Pisano for their close guidance and support throughout RickerWavelet2D Symmetric Ricker wavelet function with the speci-
this project. We would like to thank Alan Kahn (Department of fied sigma
Physics, Columbia University) for useful conversations about Sérsic2D Sérsic profile with an effective half-light radius,
machine learning and its potential applications. This research rotation, and Sérsic index
Ring2D 2D ring with inner and outer radii
made use of Photutils, an Astropy package for detection and
Const2D 2D constant (flat plane)
photometry of astronomical sources (Bradley et al. 2020). We
14
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
A.2. PetroFit
Model Name Deception
Appendix B
Approximations of Sérsic and Petrosian Quantities
In this section, we discuss various methods of approximating
Sérsic and Petrosian quantities. In particular, we look at the
relationships between Sérsic indices and corrected and
uncorrected concentrations. We also cover why correction
grids are necessary despite the availability of the approxima-
tions discussed in this Appendix.
Equations (3) and (5), along with x (r ) = bn (r re )1 n , the 4. Use the radius list and petrosian_profile to
concentration radii can be expressed as follows: construct an ideal Petrosian profile. We oversample the
n inner r80 by a factor of 10,000 to produce accurate
ri = re ⎜
(
⎛ g -1 2n , G (2n) 100
i
)⎞ , (B.1)
measurements for high-concentration profiles. For radii
⎟⎟ larger than r80, we sample at a maximum of 1000 points
⎜ bn
⎝ ⎠ (equally spaced).
n 5. Using η = 0.2 and the ideal Petrosian profile, find rpetro.
ro = re ⎜
(
⎛ g -1 2n , G (2n) 100
o
)⎞ , (B.2)
6. Using ò = 2 and rpetro, compute the uncorrected rtotal, r50,
⎟⎟ r20, r80, and C2080.
⎜ bn
⎝ ⎠ 7. Find the corrected ò value using òcorrect = r99_sersic/rpetro.
n 8. Using òcorrect and rpetro, compute the corrected rtotal, r50,
ro
=⎜
(
⎛ g -1 2n , G (2n) 100
o
)⎞ , (B.3)
r20, r80, and C2080.
ri
⎝ (
⎜ g -1 2 n , G ( 2 n ) i
100 ) ⎟⎟⎠ The approximations in the subsections that follow were
derived by fitting models using Astropy modeling.
r ⎛ g -1
Cio = 5 · log ⎛ o ⎞ = 5 · n · log ⎜
(2n, G(2n) ) ⎞.o
100
(B.4) B.2.1. Corrected versus Uncorrected Concentration Index
(2n, G(2n) ) ⎟⎟⎠
⎜ ⎟
⎝ ri ⎠ ⎜ g -1 i
⎝ 100 Because uncorrected concentrations are derived from radii
calculated using ò = 2, errors in the radii estimates propagate to
B.2. Approximations estimates of concentrations. This effect is especially severe for
profiles with high concentrations. We estimate the corrected
We approximate the following relationships by first C2080 using the uncorrected C2080 for 0.5 n 15 using a
generating a grid of quantities using ideal Sérsc and Petrosian sixth-degree polynomial (see Figure 12). For clarity, we denote
profiles for 0.5 n 15. We then make corrected and the corrected C2080 with C and uncorrected C2080 with U:
uncorrected Petrosian measurements. Note that “uncorrected”
means that the Petrosian radii and concentrations were C (U ) » 2.26194802 - 3.61130833 · U
computed using the default ò = 2. For each value of n, we + 3.8219758 · U 2 - 1.6414660 · U 3
followed the steps below to generate the profiles and quantities + 0.38059409 · U 4 - 0.0450384 · U 5
used to derive relationships.
+ 0.00221922 · U 6. (B.5)
1. Calculate Sérsic radii containing fluxes of interest,
including r99_sersic (which we define as the total flux
B.2.2. Sérsic Index versus Concentration Index
radius), using sersic_enclosed_inv.
2. Construct a radius list to sample analytical functions Since both the concentration index and Sérsic index are
discussed in Section 3.2.1. measures of concentration, they are correlated. We estimate the
3. Use the radius list and sersic_enclosed to construct Sérsic index n using the corrected C2080 for 0.5 n 15 using
a COG (flux array). a fifth-degree polynomial (see Figure 13). The relationship
15
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Figure 13. Sérsic index n estimated using the corrected and uncorrected C2080 for 0.5 n 15 using Equations (B.6) and (B.7) (red lines).
Figure 14. Epsilon (ò) estimated using the Sérsic index n corrected and uncorrected C2080 for 0.5 n 15 using Equations (B.8) and (B.9) (red lines).
between the uncorrected C2080 and Sérsic index n can be we denote the corrected C2080 with C and uncorrected C2080
computed by first computing the corrected C2080 using with U:
Equation (B.5). For clarity, we denote the corrected C2080
(n) » - 6.54870813 - 2.15040843 · n
with C and uncorrected C2080 with U:
- 0.28993623 · n2 - 0.04099376 · n3
n (C ) » -0.41844073 + 0.20487513 · C + 0.08626531 · C 2 - 0.00046837 · n4 - 0.00022305 · n5
+0.0106707 · C 3 - 0.00082523 · C 4 + 0.00002486 · C 5,
(B.6) + 7.48787292 · exp
n
{
2.6876055
, } (B.8)
n (U ) » n (C (U )). (B.7) (C ) » (n (C ))
(U ) » (n (C (U ))). (B.9)
B.2.3. Epsilon versus Concentration Index and Sérsic Index
B.2.4. Epsilon versus Petrosian Concentration Index
Epsilon (ò) is the multiplying factor that is used to compute
r99. We estimate epsilon (ò) using the Sérsic index n using a Though it is difficult to approximate the corrected ò value
combination of a fifth-degree polynomial and an exponential using the uncorrected concentration index (C2080), we can use
(see Figure 14). We also use the formulations in Section B.2.2 the Petrosian concentration index P0502 (that is, an uncorrected
to compute the relationship between ò and C2080. For clarity, quantity; see Section 2.3.3) to estimate ò. We use a combination
16
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Figure 15. Approximation of eta using the Petrosian concentration index P0502 for 0.5 n 15.
of a sixth-degree polynomial and a single exponential for this relationship between morphology, total Sérsic magnitudes, and
approximation. For clarity, we denote the Petrosian concentra- Petrosian profiles. Using Equation (3), we can define the total
tion index P0502 with P (see Figure 15): Sérsic (ms) and Petrosian (mp) magnitudes as a function of the
Petrosian radius (rpetro) and ò as follows:
(P) » 1.09339566 - 0.14524911 · P + 0.50361697 · P 2
ms (r ) = - 2.5 · log10 (L (r )) , (B.12)
- 0.1215809 · P 3 + 0.02533795 · P 4
- 0.00196243 · P 5 + 0.00009081 · P 6 m p ( · rpetro) = - 2.5 · log10 (L ( · rpetro)). (B.13)
+ 0.03312881 · exp { P
1.83616642
. }
(B.10) Using the uncorrected r50 and r90/r50, Graham et al. (2005,
their Equation (6)) provided the following approximation
for the “missing” magnitude (for Sérsic profiles with 0.1
This approximation is useful because the radii used to n 10 ):
compute P0502 do not depend on ò itself. This means that P0502
can be computed directly from the data (no need for Dm º m p - ms = P1 · exp [(r90 r50 ) P2 ] , (B.14)
corrections), and its value can be used to compute ò without where P1 and P2 equal 5.1 · 10−4 and 1.451. We build on this
the need to know any of the radii that enclose a fraction of the
work and extend the domain of the approximation to
total flux (i.e., r20, r80, r50, r90, etc.).
0.1 n 15 using a combination of an exponential and a
B.2.5. Sérsic Effective and Petrosian Half-light Radii polynomial. We provide this approximation as a function of
uncorrected C2080 (U) that estimates the “missing” magnitudes
Graham et al. (2005) gave the following approximation for re within 0.01 mag (see Figure 16):
using the uncorrected r50 and r90/r50 (for Sérsic profiles with
0.1 n 10): Dm » - 0.04990413 + 0.07810246 · U
r50 - 0.04810471 · U 2
re » . (B.11) + 0.00929017 · U 3 + 3.241416 · 10-6
[1 - (8 ´ 10-6)(r90 r50 )8.47]
B.3. Recovering Total Sérsic Magnitudes · exp {U
0.519920
. } (B.15)
Because Petrosian profiles depend on the morphology of
galaxies, the Petrosian total flux radius computed using the
B.4. Effects of PSFs on Approximations
default parameters (rtotal = r(η0.2) · 2) often results in an
aperture radius that underestimates the total Sérsic magnitudes The PSFs and seeing effects greatly diminish our ability to
(see Section 3.2.4). Graham et al. (2005) discussed in detail the approximate Sérsic profile parameters and Sérsic radii. This is
17
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Figure 16. The left panel shows the fraction of the total corrected flux that is recovered by using the default epsilon value (ò = 2). The right panel shows a line of best
fit that approximates the difference in corrected and uncorrected magnitudes (i.e., Δm) for 0.5 n 15.
because these optical effects smear the light coming from Appendix C
astronomical sources, causing a change in their intensity profiles Morphology and Fitting Comparisons
(see Figure 17) and curves of growth. For example, the corrected Here we perform quantitative tests to compare and demonstrate
half-light radius is not equal to the Sérsic half-light radius if the the advantages of PetroFit (v0.3.0; Geda et al. 2022b),
profile is convolved with a PSF (which stretches out the profile). statmorph (v0.4.0), and GALFIT (v3.0.5). We chose
Since each PSF smears the intensity profiles of galaxies in a statmorph for this comparison because it is an Astropy- and
unique way (see Figures 4 and 5), a correction unique to the PSF Photutils-based package that can produce morphological diag-
must be applied to reconstruct the Sérsic radii. This adds an extra noses that can be compared to PetroFit’s radial and concentration
layer to the error corrections and is the reason why we must measurements. For fitting, GALFIT was the best package to
generate a grid, using a known PSF, that maps the smeared compare to because it has been extensively tested and is widely
uncorrected/corrected measurements to the intrinsic Sérsic adopted. We run two kinds of tests, one on morphology-related
parameters and Sérsic profile–derived quantities. measurements and a second on fitting. For the morphology tests,
18
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Figure 17. Three 1D Sérsic profiles are defined with re = 25 but varying Sérsic indices. Each of the three profiles is convolved with the same PSF modeled by a
Moffat function. Notice how the de Vaucouleurs profile (n = 4) is most affected by the PSF convolution.
we ran PetroFit and statmorph on ideal Sérsic profiles C.1. Fitting Test
(convolved with a Moffat PSF) that were simulated using As a demonstration of PetroFit’s fitting libraries, we compare
GALFIT. For the fitting test, we ran statmorph and GALFIT the results from Section 4.2.2 to fits we perform using GALFIT
on the data set discussed in Section 4.2 to see if we could and statmorph. We provided both GALFIT and statmorph
reproduce similar results. To limit the tests to the fitting or with the same background-subtracted image used by PetroFit. For
morphology parameters, we provided statmorph the same statmorph, we follow the same segmentation step as used by
segmentation maps as PetroFit and used the same background- PetroFit. We provided GALFIT with the same source mask used
subtracted images as input for all three packages. Further details by PetroFit. We also provided GALFIT with parameter estimates
are discussed in the following subsections. close to those of PetroFit and statmorph (after fitting using the
19
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Table 5 Table 8
Comparison Table of Fitted Parameters De Vaucouleurs Profile n = 4
Values GALFIT Inputs PetroFit statmorph similar outputs, as expected. PetroFit and statmorph produced
similar models and, upon visual inspection, showed the least
amplitude 0.0004903 0.00049024 0.00049019
amount of residual.
reff 15 15.001 15.002
n 0.5 0.49977 0.4999
x0 450 450 450
y0 450 450 450
C.2. Morphology Test
ellip 0 9.15E-07 1.88E-05 For this test, we first generated mock galaxies using single-
theta 0 1.5676 1.4208 component Sérsic profiles and an ideal Moffat PSF. The
rpetro 29.39 30.606 29.896 Sérsic profiles shared the same parameters (reff = 15 pixels,
r20 8.5108 8.6417 8.6407
ellip=0, θ = 0), except for the Sérsic index and effective
r80 22.857 22.955 23.181
C2080 2.1452 2.1213 2.1429
intensity. The Sérsic index was set to (0.5, 1, 4, or 5), and the
Total flux 0.99 0.98875 0.99987 effective intensity was defined such that the total Sérsic flux
Time 0 9.8942 4.1861 of the profile was equal to 1 (total flux equal to 0.99 by
PetroFit definition; see Section 2.3). The Moffat profile was
generated by first fitting the real Hubble F105W PSF shown in
Table 7
Figure 7 and converting that model into an image. This was
Exponential Profile n = 1 done so we could create a PSF with no noise and exactly
centered in the image. Using the model parameters and the
Values GALFIT Inputs PetroFit statmorph Moffat PSF, we used GALFIT to create model images of size
amplitude 0.00037197 0.00037223 0.00037173 900 pixels on each axis. A correction grid was generated
reff 15 14.998 15.005 using the new PSF for PetroFit. We carried out the
n 1 0.99749 0.99936 segmentation and deblending step using the makecatalog
x0 450 450 450 function. This gave us Photutils segmentation maps that we
y0 450 450 450 used for both tools (both tools used the same maps). We ran
ellip 0 0 9.43E-07
statmorph using its SourceMorphology class. We
theta 0 −6.2832 1.507
rpetro 32.37 33.847 32.888
placed PetroFit’s photometry, morphology, and fitting steps
r20 7.3679 7.5615 7.5143 into a single function for this test. For profiles with a Sérsic
r80 26.761 26.555 25.874 index greater than 3, PetroFit oversampled the model by a
C2080 2.8008 2.7277 2.6849 factor of 10 within a box of 50 by 50 pixels of the center. Both
Total flux 0.99 0.98838 0.99431 functions computed morphology parameters and fit the input
Time 0 10.912 8.7325 images using the Moffat PSF.
Table 6–9 show the results of the tests. We show the results
from each profile in a separate table. The “Values” column
shows the parameter name, and the “GALFIT Inputs” column
shows the Sérsic parameters that were used to create the
latter packages). To make fair timing comparisons, we consider
image. Values such as r20 and total flux in the “GALFIT
runtimes that include loading the data from the files and refer to
Inputs” column were calculated using analytical equations
it as the “total runtime.” We do not include segmentation time, defined in Sections 1 and 2. It is important to note that these
since all three packages use maps and masks from the same ideal values are proxies, since they do not account for PSF
segmentation steps. Running on an Intel Core i7-2600 CPU at smearing (see Appendix B.4); thus, radii close to the center
3.40 GHz, PetroFit finished with a total runtime under 1.2 s, (such as r20) will be skewed. Lastly, the “PetroFit” and
statmorph under 0.8 s, and GALFIT under 1.8 s. The fit results “statmorph” columns show the runtime of each tool in
are given in Table 5. Radii are given in pixels, while photometric seconds (running on an Intel Core i7-2600 CPU at 3.40 GHz).
flux measurements are given in electrons per second (except Radii are given in pixels, while photometric flux measure-
magnitudes, which are given in the AB system). The results show ments are given in electrons per second. The two packages
20
The Astronomical Journal, 163:202 (21pp), 2022 May Geda et al.
Table 9 References
High-index Profile n = 5
Andredakis, Y. C., Peletier, R. F., & Balcells, M. 1995, MNRAS, 275, 874
Values GALFIT Inputs PetroFit statmorph Astropy Collaboration, Robitaille, T. P., Tollerud, E. J., et al. 2013, A&A,
amplitude 0.000176 0.00017547 0.00016352 558, A33
Bershady, M. A. 1995, AJ, 109, 87
reff 15 15.019 15.598
Bershady, M. A., Jangren, A., & Conselice, C. J. 2000, AJ, 119, 2645
n 5 5.0149 4.787 Bertin, E., & Arnouts, S. 1996, A&AS, 117, 393
x0 450 450 449.88 Blanton, M. R., Dalcanton, J., Eisenstein, D., et al. 2001, AJ, 121, 2358
y0 450 450 449.88 Bradley, L., Sipőcz, B., Robitaille, T., et al. 2020, astropy/photutils, v1.0.0,
ellip 0 0 −0.00017608 Zenodo, doi:10.5281/zenodo.4044744
theta 0 −6.2832 0.37224 Ciotti, L. 1991, A&A, 249, 99
rpetro 23.78 26.735 25.157 Conselice, C. J. 2003, ApJS, 147, 1
r20 3.653 4.5009 3.4316 Crawford, S. M. 2006, The distribution of star-forming galaxies in intermediate
r80 54.582 51.58 20.844 redshift galaxy clusters, Zenodo doi:10.5281/zenodo.4587776
C2080 5.872 5.2959 3.9174 de Vaucouleurs, G. 1948, Annales d’Astrophysique, 11, 247
Total flux 0.99 0.985 0.78326 Ferrari, F., Dottori, H., Caon, N., Nobrega, A., & Pavani, D. B. 2004, MNRAS,
347, 824
Time 0 13.446 32.105
Geda, R., Crawford, S. M., Hunt, L., et al. 2022a, PetroFit/petrofit_papers:
v1.0, Zenodo, doi:10.5281/zenodo.6040890
Geda, R., Crawford, S. M., Hunt, L., et al. 2022b, PetroFit/petrofit: v0.3,
Zenodo, doi:10.5281/zenodo.6040781
Graham, A., Lauer, T. R., Colless, M., & Postman, M. 1996, ApJ, 465, 534
Graham, A. W. 2001, AJ, 121, 820
have similar runtimes, with PetroFit performing better with Graham, A. W., & Driver, S. P. 2005, PASA, 22, 118
high-index sources. As stated in Section 5, statmorph Graham, A. W., Driver, S. P., Petrosian, V., et al. 2005, AJ, 130, 1535
computes additional parameters, such as Gini-M20 statistics, Graham, A. W., Erwin, P., Caon, N., & Trujillo, I. 2001, ApJL, 563, L11
that contribute to its runtime. PetroFit’s correction grids allow Harris, C. R., Millman, K. J., van der Walt, S. J., et al. 2020, Natur, 585,
it to get much better estimates of r80 and C2080 for highly 357
Hunter, J. D. 2007, CSE, 9, 90
concentrated profiles (see n = 4 and 5). For example, for a Kent, S. M. 1985, ApJS, 59, 115
profile with n = 4, statmorph measures a total flux of Khosroshahi, H. G., Wadadekar, Y., & Kembhavi, A. 2000, ApJ, 533, 162
0.83519 e− s–1, which is 84% of the total Sérsic flux (this is Kron, R. G. 1980, ApJS, 43, 305
expected; see Figure 16). It is also important to note that Levenberg, K. 1944, QApMa, 2, 164
Lotz, J. M., Koekemoer, A., Coe, D., et al. 2017, ApJ, 837, 97
PetroFit was able to predict these values before fitting the Marquardt, D. 1963, SIAM J. Appl. Math., 11, 431
images. Another important result is that oversampling the Merlin, E., Amorín, R., Castellano, M., et al. 2016, A&A, 590, A30
high-index images allowed PetroFit to produce better fits Möllenhoff, C., & Heidt, J. 2001, A&A, 368, 16
for n. Moré, J. J., Garbow, B. S., & Hillstrom, K. E. 1980, Technical Report, ANL-
80-74
Moriondo, G., Giovanardi, C., & Hunt, L. K. 1998, A&A, 339, 409
ORCID iDs Peng, C. Y., Ho, L. C., Impey, C. D., & Rix, H.-W. 2010, AJ, 139, 2097
Petrosian, V. 1976, ApJL, 210, L53
Robel Geda https://orcid.org/0000-0003-1509-9966 Rodriguez-Gomez, V., Snyder, G. F., Lotz, J. M., et al. 2019, MNRAS,
Steven M. Crawford https://orcid.org/0000-0002- 483, 4140
8969-5229 Sérsic, J. L. 1963, BAAA, 6, 41
Lucas Hunt https://orcid.org/0000-0001-8587-9285 Sérsic, J. L. 1968, Atlas de Galaxias Australes (Cordoba: Observatorio
Matthew Bershady https://orcid.org/0000-0002-3131-4374 Astronomico)
Strauss, M. A., Weinberg, D. H., Lupton, R. H., et al. 2002, AJ, 124, 1810
Erik Tollerud https://orcid.org/0000-0002-9599-310X Trujillo, I., Graham, A. W., & Caon, N. 2001, MNRAS, 326, 869
Solohery Randriamampandry https://orcid.org/0000-0001- Virtanen, P., Gommers, R., Oliphant, T. E., et al. 2020, Nature Methods,
5373-6669 17, 261
21