Gnuastro: measuring radial profiles from images

Radial profiles play a crucial role in the analysis and interpretation of astronomical data, facilitating the extraction of spatial information. However, highly customizable (for different scenarios) measurements over each elliptical annulus can be challenging. In response, we present 'astscript-radial-profile', which is part of Gnuastro from version 0.15 and has an extensive documentation. A convenient feature of this program is its capability to make the measurements with different operators (mean, median, sigma-clipping, and many more) over ellipses, very quickly and directly on the command-line with minimal dependencies. This research note is reproducible with Maneage, on the Git commit 104aad5.


INTRODUCTION
A radial profile consists of measurements over elliptical annuli at increasing distances/radii.In general, a radial profile can be generalized to any number of dimensions.For example, in a 3D dataset (cube), a radial profile consists of measurements over growing ellipsoidal shells.Radial profiles are most commonly employed in 2D images because the third dimension in 3D astronomical data (IFUs or radio data cubes) is spectral, not spatial.The radial profile is a table with two columns: the distance to the center and the measured quantity.
Even with good visualization tools and proper color bars set, quantifying the spatial variation of an object's brightness, and comparing it with other objects is challenging.A radial profile is therefore Corresponding author: Raúl Infante-Sainz infantesainz@gmail.com a convenient way of extracting spatial information of an astronomical target.
Astronomical sources can have irregular shapes (for example stellar streams and Galactic cirrus).In these cases, it is possible to compute radial profiles for a specified azimuth angle or direction.More generally, astronomical sources, driven by gravitational forces, tend to exhibit symmetrical, often ellipse-symmetric shapes.As a consequence, this type of aperture is very useful to derive physical properties such as surface brightness profiles, mass density profiles, and star formation rate profiles, among others, as demonstrated in recent studies (see e.g., Infante-Sainz et al. 2020;Liu et al. 2022;Mosenkov et al. 2020;Martínez-Lombilla et al. 2023;Watkins et al. 2023).
Once the annuli are defined, selecting the appropriate operator for measuring the properties becomes crucial.While simple mean or sum measurements are common, other situations require arXiv:2401.05303v1[astro-ph.IM] 10 Jan 2024 more sophisticated operators.For instance, measuring the brightness within each radius with a simple mean or sum can be severely affected by outliers at certain radii: foreground or background objects or star-forming regions within the galaxy itself (see Figure 1).As a consequence, robust estimators of the measurement such as median or sigma clipping operators are desired, but a diverse set of measurements are rarely implemented in many implementations of radial profiles.
In this research note, we present a powerful solution to address these problems: the Gnuastro executable program astscript-radial-profile.This program addresses the complexities arising from the generation of radial profiles on astronomical images.It is able to create radial profiles of astronomical sources very fast, from the command-line, and with an enormous variety of measurements 1 .The following section provides an overview, using the radial profile of the M81 galaxy as an illustrative example.

CREATING RADIAL PROFILES
Gnuastro's astscript-radial-profile is an installed script (written in POSIX shell), and it uses several Gnuastro programs (that are installed with it and available on the host operating system) to generate the radial profile.It is possible to run the script and keep the intermediate files (passed between the programs) to inspect and optimize the execution for each particular science case.A summary of the general steps are described below.
• Aperture construction.The script uses Gnuastro's MakeProfiles (astmkprof) to construct elliptical annuli based on user-defined parameters, including the center position, axis ratio, position angle, azimuthal angle, and others.
• Output generation.The script produces a formatted table (possibly FITS) containing the resulting radial profile.
By default, if no options are specified, the program computes the radial profile using circular apertures centered on the input image center, employing a simple mean as the measurement operator.To customize the radial profile, users can modify multiple options and parameters, allowing adjustments to the ellipse positioning, shape, and measurement operators.Beyond the large number of possible measurements, we find particularly interesting the possibility of changing the size of the apertures by undersampling or oversampling, as well as the generation of radial profiles with subpixel precision.For a comprehensive understanding of the different parameters and how to use this script in more detail, we refer to the Gnuastro manual2 .
The left panel of Figure 1 depicts a color (and gray background) visualization of the M81 galaxy captured from the J-PLUS DR3 (Cenarro et al. 2019) using the iSDSS, rSDSS, and gSDSS filters.
This color image has been obtained with another Gnuastro's installed scripts astscript-color-faint-gray script (for more details, see Infante-Sainz & Akhlaghi 2024).In this image there are several other sources and over M81, star-forming regions produce non elliptically-symmetric features.The right panel of Figure 1 shows the radial profiles computed by using two different operators: simple mean and sigma-clipped mean.The radial profiles look quite different.While the simple mean radial profile has several peaks that are due to the presence of nearby objects (bright stars in the surroundings of the M81 galaxy), the sigma clipping radial profile is smoother and does not have these peaks.In contrast, the blue squares represent the measurements obtained using a 3σ clipped mean, resulting in a smoother profile by removing the extreme outlier values (for example those from contaminant sources).

Figure 1 .
Figure 1.Color image and surface brightness radial profiles of M81 galaxy.Left: Color image with gray background obtained by using the astscript-color-faint-gray script (Infante-Sainz & Akhlaghi 2024).Right: Surface brightness radial profiles of the rSDSS image, measured with two different operators.The y-axis represents the surface brightness (SB), while the x-axis represents the distance to the center of the galaxy.The red circles correspond to the measurements obtained by a simple mean, and they exhibit peaks due to the bright objects (stars).In contrast, the blue squares represent the measurements obtained using a 3σ clipped mean, resulting in a smoother profile by removing the extreme outlier values (for example those from contaminant sources).