Photometry

Methods related to galaxy photometry

frb.galaxies.photom.merge_photom_tables(new_tbl, old_file, tol=<Quantity 1. arcsec>, debug=False)[source]

Merge photometry tables

Parameters:
  • new_tbl (astropy.table.Table) – New table of photometry

  • old_file (str or Table) – Path to the old table

Returns:

Merged tables

Return type:

astropy.table.Table

frb.galaxies.photom.photom_by_name(name, filelist)[source]

Generate a Table for a given galaxy from a list of photom files

Warning: Order matters! Use best data last

Parameters:
Return type:

astropy.table.Table

frb.galaxies.photom.extinction_correction(filt, EBV, RV=3.1, max_wave=None, required=True)[source]

calculate MW extinction correction for given filter

Uses the Gordon 2024 extinction model

Parameters:
  • filt (str) – filter name (name of file without .dat extension)

  • EBV (float) – E(B-V) (can get from frb.galaxies.nebular.get_ebv which uses IRSA Dust extinction query

  • RV – from gbrammer/threedhst eazyPy.py – characterizes MW dust

  • max_wave (float, optional) – If set, cut off the calculation at this maximum wavelength. A bit of a hack for the near-IR, in large part because the MW extinction curve ends at 1.4 microns.

  • required (bool, optional) – Crash out if the transmission curve is not present

Returns:

linear extinction correction

Return type:

float

frb.galaxies.photom.correct_photom_table(photom, EBV, name, max_wave=None, required=True)[source]

Correct the input photometry table for Galactic extinction Table is modified in place

If there is SDSS photometry, we look for the extinction values provided by the Survey itself.

Uses extinction_correction()

Parameters:
  • photom (astropy.table.Table) – Required keys: ‘Name’, filters

  • EBV (float) – E(B-V) (can get from frb.galaxies.nebular.get_ebv which uses IRSA Dust extinction query

  • name (str) – Name of the object to correct

  • required (bool, optional) – Crash out if the transmission curve is not present

Returns:

Return code

-1: No matches to the input name 0: One match

Return type:

int

frb.galaxies.photom.sb_at_frb(host, cut_dat: ndarray, cut_err: ndarray, wcs: WCS, fwhm=3.0, physical=False, min_uncert=2)[source]

Measure the surface brightness at an FRB location in a host galaxy

Parameters:
  • host (Host object) – host galaxy object from frb repo

  • cut_dat (np.ndarray) – data (data from astorpy 2D Cutout object)

  • cut_err (np.ndarray) – inverse variance of data (from astropy 2D Cutout object)

  • wcs (WCS) – WCS for the cutout

  • fwhm (float, optional) – FWHM of the PSF of the image in either pixels or kpc. Defaults to 3 [pix].

  • physical (bool, optional) – If True, FWHM is in kpc. Defaults to False.

  • min_uncert (int, optional) – Minimum localization unceratainty for the FRB, in pixels. Defaults to 2.

Returns:

sb_average, sb_average_err [counts/sqarcsec]

Return type:

tuple

frb.galaxies.photom.fractional_flux(cutout, frbdat, hg, nsig=3.0)[source]

Calculate the fractional flux at the FRB location

Parameters:
  • cutout (WCS Cutout2D) – astropy 2D Cutout of data around host galaxy

  • frbdat (frb.FRB) – frb object loaded from frb repo

  • hg (frb.galaxies.frbgalaxy.FRBHost) – host galaxy object loaded from frb repo

  • nsig (float, optional) – sigma for FRB localization within which the measurement should be made. Defaults to 3.

Returns:

median_ff, sig_ff, ff_weight [no units]

Median fractional flux, uncertainty

Return type:

tuple

Overview

This module provides functions for photometric analysis of FRB host galaxies, including magnitude-to-flux conversions, aperture photometry corrections, and integration with various survey photometric systems.

Functions

Photometric Conversions

Aperture Corrections

Survey Integration

Color and SED Analysis

Quality Assessment

Examples

Basic magnitude-flux conversions:

from frb.galaxies import photom
import numpy as np

# Convert AB magnitude to flux density in mJy
mag = 22.5
mag_err = 0.1

flux, flux_err = photom.mag_to_flux(mag, mag_err, units='mJy')
print(f"Flux: {flux:.2f} ± {flux_err:.2f} mJy")

# Convert back to magnitude
mag_check, mag_err_check = photom.flux_to_mag(flux, flux_err)
print(f"Magnitude: {mag_check:.2f} ± {mag_err_check:.3f}")

Extinction corrections:

# Apply Galactic extinction correction
ebv_gal = 0.05  # E(B-V) from dust maps

# Correct r-band magnitude
r_obs = 22.8
r_corr = photom.extinction_correct(
    r_obs,
    ebv_gal,
    filter_name='r',
    extinction_law='ccm89',
    rv=3.1
)

print(f"Observed r: {r_obs:.2f}")
print(f"Corrected r: {r_corr:.2f}")
print(f"Correction: {r_corr - r_obs:.3f} mag")

Color calculations:

# Calculate colors from photometry dictionary
photom_dict = {
    'DES_g': 23.1, 'DES_g_err': 0.05,
    'DES_r': 22.3, 'DES_r_err': 0.03,
    'DES_i': 21.9, 'DES_i_err': 0.04
}

# Calculate g-r color
gr_color, gr_err = photom.calculate_colors(
    photom_dict, 'DES_g', 'DES_r'
)

# Calculate r-i color
ri_color, ri_err = photom.calculate_colors(
    photom_dict, 'DES_r', 'DES_i'
)

print(f"g-r = {gr_color:.2f} ± {gr_err:.3f}")
print(f"r-i = {ri_color:.2f} ± {ri_err:.3f}")

Working with galaxy objects:

from frb.galaxies.frbgalaxy import FRBGalaxy

# Assuming galaxy object with photometry loaded
galaxy = FRBGalaxy(ra=180.0, dec=45.0, frb=frb_object)

# Calculate synthetic V-band magnitude from available photometry
v_synth = photom.synthetic_photometry(
    galaxy.photom,
    target_filter='V',
    method='interpolation'
)

print(f"Synthetic V magnitude: {v_synth:.2f}")

SED fitting preparation:

# Prepare photometry for SED fitting
clean_photom = photom.detect_outliers(galaxy.photom)

# Apply quality flags
quality_flags = photom.photom_quality_flags(galaxy.photom)

# Remove flagged measurements
sed_photom = {}
for filt, mag in clean_photom.items():
    if quality_flags.get(filt, 0) == 0:  # Good quality
        sed_photom[filt] = mag

print(f"Clean photometry: {len(sed_photom)} measurements")
print(f"Rejected: {len(galaxy.photom) - len(sed_photom)} measurements")

Multi-survey combination:

# Combine photometry from multiple surveys
survey_data = {
    'DES': {'g': 22.1, 'r': 21.5, 'i': 21.2},
    'SDSS': {'g': 22.0, 'r': 21.4, 'i': 21.1},
    'Pan-STARRS': {'g': 22.05, 'r': 21.45, 'i': 21.15}
}

combined_photom = photom.match_survey_photometry(
    survey_data,
    weight_by_error=True,
    apply_systematic_corrections=True
)

print("Combined photometry:")
for filt, data in combined_photom.items():
    print(f"  {filt}: {data['mag']:.2f} ± {data['err']:.3f}")