How Astronomers Find Galaxies in Survey Data
This guide explains the core techniques astronomers use to identify galaxies within large telescope survey datasets. You will learn the steps from raw image processing to cataloging, including how to distinguish galaxies from stars and artifacts, and how to handle the sheer volume of data.
What You’ll Need
- A survey dataset (e.g., FITS files from SDSS, DES, or Euclid) – these are publicly available.
- Astronomical software: Python with libraries like Astropy, NumPy, and SciPy; or specialized tools like SExtractor (Source Extractor).
- Basic knowledge of Python scripting and command-line operations.
- Access to a computer with sufficient memory (16 GB RAM or more for large surveys).
- Optional: a catalog from a previous survey (e.g., SDSS DR16) for cross-matching and validation.
Step-by-Step
- Obtain and understand the data. Download the survey images in FITS format. Each FITS file contains a 2D image (pixel values) plus a header with metadata (coordinates, exposure time, filter). Familiarize yourself with the pixel scale (arcseconds per pixel) and the units of the pixel values (often ADU or electrons).
- Preprocess the images. Apply standard calibrations if not already done: subtract bias, divide by flat field, and remove cosmic rays. Many surveys provide already-calibrated images, but you must check the header. If not calibrated, use the calibration frames provided by the survey.
- Subtract the background. Estimate the sky background level (the signal from the atmosphere and zodiacal light) using a median filter or a mesh grid. Subtract this background to make faint objects stand out. Be careful not to subtract the wings of bright galaxies.
- Detect sources. Run a source detection algorithm like SExtractor or Python’s
photutilspackage. Set a detection threshold (e.g., 1.5–3 sigma above the background noise) and a minimum number of connected pixels (e.g., 5 pixels). This will create a list of all objects (stars, galaxies, artifacts). - Measure photometric and morphological properties. For each detected source, measure: total flux (magnitude), centroid position, and shape parameters like ellipticity, half-light radius, and the Sérsic index (a measure of the light profile). These are your primary galaxy indicators.
- Distinguish galaxies from stars. Use the fact that stars have a point-spread function (PSF) that is consistent across the image, while galaxies are extended. Common methods:
- Size-magnitude diagram: Plot half-light radius vs. magnitude. Stars cluster along a narrow locus (constant size), while galaxies scatter to larger sizes.
- SExtractor’s CLASS_STAR parameter: A value close to 1 indicates a star, close to 0 a galaxy. Set a threshold (e.g., CLASS_STAR < 0.5 for galaxy candidates).
- Morphological fitting: Fit a PSF model and a Sérsic profile; if the Sérsic fit is significantly better, it’s likely a galaxy.
- Remove artifacts. Discard sources that are:
- Near the image edges (within a few pixels).
- On saturated star spikes or diffraction patterns.
- Cosmic rays (they appear as single bright pixels with no extended shape).
- Reflections or ghost images (often symmetric around bright stars).
- Apply a magnitude cut. Set a minimum signal-to-noise ratio (e.g., S/N > 5) to ensure the object is real and not a noise fluctuation. Also apply a magnitude limit (e.g., brighter than 22nd magnitude in the survey’s band) to keep only reliable detections.
- Cross-match with existing catalogs (optional). If you have a reference catalog, match your sources by sky coordinates (using a matching radius of a few arcseconds). This helps validate your detections and provides redshifts or classifications.
- Create the final galaxy catalog. Output a table with columns: right ascension, declination, magnitude, size, ellipticity, and any other measured parameters. Save as a CSV or FITS table for further analysis.
Common Mistakes
- Using a single detection threshold for all images: Noise levels vary; use a threshold relative to each image’s background noise.
- Confusing stars and galaxies: A very compact galaxy can look like a star, especially at high redshift. Always use multiple criteria (size + color + morphology).
- Ignoring the PSF: The PSF varies across the field; use a spatially varying PSF model if available.
- Not debiasing the background: A poorly subtracted background will cause false detections or miss faint galaxies.
- Using a fixed pixel threshold: The minimum number of connected pixels should scale with the PSF size; too small will pick up noise, too large will miss small galaxies.
Tips
- Use SExtractor in dual-image mode: Detect on a deep image (e.g., combined bands) and measure on each band separately for accurate colors.
- Visual inspection: Always plot a random sample of your detections on the images to check for obvious errors.
- Use color-color diagrams: Galaxies occupy distinct regions compared to stars (e.g., u-g vs. g-r). This helps separate them.
- Leverage machine learning: For very large surveys, train a simple classifier (e.g., random forest) on the measured features (size, magnitude, colors) using a labeled sample (e.g., from SDSS spectra).
- Work in a controlled environment: Use a virtual environment for Python to avoid dependency conflicts.
Troubleshooting
- Too many false detections: Increase the detection threshold (e.g., from 1.5 to 3 sigma) or increase the minimum pixel area. Also check if the background subtraction is too aggressive (subtracting real galaxy flux).
- Missing faint galaxies: Lower the detection threshold, but then you must apply a more stringent S/N cut. Also try using a matched filter (convolve the image with the PSF before detection).
- Stars misclassified as galaxies: If your CLASS_STAR threshold is too low, you’ll include stars. Plot the size-magnitude diagram and adjust the threshold based on the stellar locus. Also, check if the PSF model is accurate; if not, the stellar locus will be broad.
- Memory errors: Process images in tiles (e.g., 2048×2048 blocks) with a small overlap. Use
astropy.nddata.Cutout2Dto work on cutouts. - Coordinates are off: Ensure the WCS (world coordinate system) in the FITS header is correct. If not, use
astropy.wcsto update it with a reference catalog.
Frequently Asked Questions
How do astronomers know a faint blob is a galaxy and not a noise fluctuation?
They require a detection significance (S/N) of at least 5, meaning the signal is 5 times the background noise. Additionally, the object must have a spatial extent larger than the PSF and appear in multiple independent images (e.g., different bands).
What is the difference between a star and a galaxy in survey images?
Stars are point sources – their light is spread only by the telescope’s PSF, so they have the same size everywhere. Galaxies are extended – they have a larger half-light radius and a different light profile (Sérsic index > 0.5, whereas stars have a Gaussian-like profile).
Why do we need to subtract the background?
The background (sky glow, zodiacal light) adds a constant signal to every pixel. If not subtracted, faint galaxies are hidden in the background noise, and photometric measurements would be biased.
Can I use a simple magnitude cut to find galaxies?
No, because stars and galaxies overlap in magnitude. A magnitude cut alone will include many stars. You must combine it with size and morphology criteria.
What is the best software for galaxy detection?
SExtractor is the industry standard for source detection and measurement. In Python, photutils provides similar functionality and is more flexible for custom pipelines.
How do I handle overlapping galaxies?
Use deblending algorithms (SExtractor has a built-in deblending option). For close pairs, you may need to fit two Sérsic profiles simultaneously using a tool like GALFIT.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.