API Reference
This section contains detailed documentation for all modules, classes, and functions in the FRB package.
Core Modules
The FRB package is organized into several key modules:
- frb.frb - FRB Event Module
- frb.analysis
- frb.dm - Dispersion Measure Module
- Galaxies
- frb.halos - Halo Models
- frb.surveys - Survey Data Access
- frb.associate - FRB-Galaxy Association
- frb.builds
- frb.figures
- frb.scripts
- frb.dm_kde
- frb.frb_surveys - FRB Survey Data
- frb.defs
- frb.io
- frb.utils
- frb.turb_scattering - Turbulent Scattering
- frb.rm - Rotation Measure
- frb.mw - Milky Way
- frb.em - Emission Measure
- frb.dlas - Intervening Galaxies (DLAs)
- frb.frbcat - FRB Catalog
- frb.experiment - FRB Experiments
Quick Reference
Most Common Functions
Loading FRBs:
from frb.frb import FRB
frb_obj = FRB.by_name('FRB20121102A')
DM Calculations:
from frb.dm import igm
DM_cosmic = igm.DM_cosmic(z=0.5)
z_est = igm.z_from_DM(DM_obs)
Building FRB Tables:
from frb.frb import build_table_of_frbs
frb_tbl, tbl_units = build_table_of_frbs()
Scattering Analysis:
from frb import turb_scattering as ts
theta = ts.theta_mist(n_e, nu_obs)
Function Index
Core Functions by Category
Dispersion Measure:
|
Macquart Relation |
|
Calculate the average cosmic electron number density as a function of redshift. |
|
Report back an estimated redshift from an input IGM DM Any contributions from the Galaxy and/or host need to have been 'removed' |
|
Compute average halo DM contribution along FRB sightline. |
PDF(Delta) following the McQuinn formalism describing the DM_cosmic PDF |
|
Estimate DM_host from the surface density of SFR |
Scattering:
Estimate the scattering angle for a mist, following the calculations by M. |
|
Temporal broadening for a mist of spherical clouds following the calculations by M. |
|
n_e from temporal broadening for a mist of spherical clouds following the calculations by M. |
FRB Tables:
Generate a Pandas table of FRB data |
|
Generate a list of FRB objects for all the FRBs in the Repo |
FRB Objects:
Method to instantiate an FRB by its name |
|
Returns the FRBHost object for this FRB |
Class Hierarchy
FRB
├── FRB.by_name()
├── FRB.grab_host()
└── FRB.set_ee()
FRBHost
├── FRBHost.by_frb()
├── FRBHost.derived
├── FRBHost.photom
└── FRBHost.get_metaspec()
Constants and Defaults
The package uses several default values and constants:
Cosmological Parameters:
# Default cosmology (defined in frb.defs)
frb_cosmo = astropy.cosmology.Planck18
Default Scattering Parameters:
# Default structure sizes
L_default = 50 * u.kpc # Structure size
R_default = 1 * u.pc # Cloud size
fV_default = 1.0 # Filling factor
Physical Constants:
The package uses astropy constants throughout for physical calculations.
Error Handling
The FRB package uses standard Python exception handling:
Common Exceptions:
FileNotFoundError: When FRB data files are not foundValueError: When invalid parameters are passed to functionsAttributeError: When accessing properties not available for a particular FRBImportError: When optional dependencies are not available
Error Handling Example:
try:
frb_obj = FRB.by_name('NonExistentFRB')
except FileNotFoundError:
print("FRB data not found")
except ValueError as e:
print(f"Invalid FRB name: {e}")
Data Types
The package primarily works with astropy quantities and coordinates:
Common Data Types:
astropy.coordinates.SkyCoord- Sky positionsastropy.units.Quantity- Physical quantities with unitsastropy.table.Table- Tabular data (catalogues)numpy.ndarray- Numerical arraysdict- Configuration and metadata
Unit Conventions:
Dispersion Measure:
pc / cm³Distances:
kpc,Mpc,GpcFrequencies:
MHz,GHzTime:
s,ms,μsAngles:
deg,arcmin,arcsec,mas,μas
Contributing to the API
If you’re contributing new functions or classes:
Follow the existing documentation style
Include comprehensive docstrings
Add type hints where appropriate
Include examples in docstrings
Update this API documentation
See also
Quick Start Guide - Get started with basic usage
Dispersion Measure - Dispersion measure calculations
Gas in Halos - Halo modeling tools