Galaxy Offsets
Methods related to offsets
- frb.galaxies.offsets.angular_offset(frb, galaxy, nsigma=5.0, nsamp=2000, gal_sig=None)[source]
Warning: All calculations in arcsec – Do not use for large localization error
- Parameters:
frb (frb.frb.FRB)
galaxy (frb.galaxies.FRBGalaxy)
nisgma – Number of sigma around the FRB uncertainty ellipse from which the grid is build
nsamp – Grid sample points for each 1D Gaussian (one in RA and Dec)
gal_sig (tuple) – RA, DEC errors in arcsec as floats
- Returns:
- float, float, float, float
avg_off, sig_off, best_off, sig_best
- Return type:
- frb.galaxies.offsets.incorporate_hst(hst_astrom: DataFrame, host)[source]
Updates coordinates and offsets for galaxies observed with HST
Offsets ang_avg, ang_best are updated in place
Currently for Mannings+2021 only
- Parameters:
hst_astrom (pandas.DataFrame) – [description]
host (frb.galaxies.frbgalaxy.FRBHost) – [description]
Overview
This module provides functions for calculating positional offsets between FRBs and their potential host galaxies. It handles both angular and physical offset measurements, accounting for localization uncertainties and coordinate transformations.
Functions
Primary Offset Functions
- frb.galaxies.offsets.angular_offset(frb, galaxy, nsigma=5.0, nsamp=2000, gal_sig=None)[source]
Warning: All calculations in arcsec – Do not use for large localization error
- Parameters:
frb (frb.frb.FRB)
galaxy (frb.galaxies.FRBGalaxy)
nisgma – Number of sigma around the FRB uncertainty ellipse from which the grid is build
nsamp – Grid sample points for each 1D Gaussian (one in RA and Dec)
gal_sig (tuple) – RA, DEC errors in arcsec as floats
- Returns:
- float, float, float, float
avg_off, sig_off, best_off, sig_best
- Return type:
Calculate angular offset between FRB position and galaxy coordinates.
This is the primary function for computing separations, handling:
FRB localization error ellipses
Galaxy position uncertainties
Statistical error propagation
Multiple offset definitions (best estimate vs. averaged)
Error Analysis Functions
Coordinate System Functions
Statistical Functions
Offset Types and Definitions
The module implements several offset definitions:
- Angular Offsets
ang_best: Offset from FRB localization centroid to galaxy center
ang_avg: Offset averaged over FRB localization probability distribution
Angular offsets reported in arcseconds
- Physical Offsets
Proper physical distance in kpc at galaxy redshift
Corrected for cosmological expansion
Uses ang_best by default unless specified
- Deprojected Offsets
Corrected for galaxy inclination angle
Represents true separation within galaxy disk
Requires morphological information
Error Propagation
Comprehensive error handling includes:
- FRB Localization Errors
Error ellipse semi-major and semi-minor axes
Position angle of error ellipse
Confidence level specification
- Galaxy Position Errors
Astrometric tie uncertainties
Source extraction errors
Proper motion corrections (for nearby galaxies)
- Systematic Uncertainties
Absolute astrometric calibration
Reference frame differences
Coordinate epoch corrections
Examples
Basic offset calculation:
from frb.galaxies import offsets
from frb.frb import FRB
from frb.galaxies.frbgalaxy import FRBGalaxy
# Create FRB and galaxy objects
frb = FRB.by_name('FRB180924')
galaxy = FRBGalaxy(ra=349.24, dec=-40.9, frb=frb)
# Calculate angular offsets (done automatically in FRBGalaxy.__init__)
ang_avg, ang_avg_err, ang_best, ang_best_err = offsets.angular_offset(frb, galaxy)
print(f"Angular offset (best): {ang_best:.2f} ± {ang_best_err:.2f} arcsec")
print(f"Angular offset (averaged): {ang_avg:.2f} ± {ang_avg_err:.2f} arcsec")
Physical offset calculation:
# Set galaxy redshift first
galaxy.set_z(0.3214, 'spec', err=0.0001)
# Calculate physical offset
phys_offset = offsets.physical_offset(
ang_best, # angular offset in arcsec
galaxy.z, # redshift
cosmo=galaxy.cosmo
)
print(f"Physical offset: {phys_offset:.1f} kpc")
Including position errors:
# Set galaxy position uncertainties
galaxy.positional_error['ra_astrometric'] = 0.1 # arcsec
galaxy.positional_error['dec_astrometric'] = 0.1 # arcsec
galaxy.positional_error['ra_source'] = 0.05 # arcsec
galaxy.positional_error['dec_source'] = 0.05 # arcsec
# Recalculate with position errors included
ang_avg, ang_avg_err, ang_best, ang_best_err = offsets.angular_offset(frb, galaxy)
print(f"Offset with position errors: {ang_best:.2f} ± {ang_best_err:.2f} arcsec")
Position angle calculation:
# Calculate position angle of FRB relative to galaxy
pa = offsets.position_angle(frb.coord, galaxy.coord)
print(f"Position angle: {pa:.1f} degrees East of North")
Probability assessment:
# Assess chance alignment probability
# (requires galaxy surface density information)
prob_chance = offsets.offset_probability(
ang_best, # observed offset
galaxy_density=1000, # galaxies per sq. arcmin
magnitude_limit=25.0 # survey depth
)
print(f"Chance alignment probability: {prob_chance:.3f}")
Working with morphology:
# For galaxies with inclination information
if 'inclination' in galaxy.morphology:
# Calculate deprojected offset
deprojected = offsets.deproject_offset(
ang_best,
galaxy.morphology['inclination'],
galaxy.morphology['position_angle'],
frb_pa=pa
)
print(f"Deprojected offset: {deprojected:.2f} arcsec")
Bulk analysis:
from frb.galaxies.utils import list_of_hosts
# Get all hosts and calculate offset distribution
frbs, hosts = list_of_hosts()
offsets_list = []
for host in hosts:
if host.z is not None:
phys_off = offsets.physical_offset(
host.offsets['ang_best'],
host.z,
cosmo=host.cosmo
)
offsets_list.append(phys_off)
import numpy as np
median_offset = np.median(offsets_list)
print(f"Median host offset: {median_offset:.1f} kpc")