Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

FRB is a Python package for Fast Radio Burst (FRB) calculations, observations, estimations, and analysis. It provides tools for DM (Dispersion Measure) calculations, host galaxy analysis, FRB-galaxy associations, and survey data handling.

## Build and Test Commands

```bash
# Install dependencies
pip install -r frb/requirements.txt
pip install git+https://github.com/FRBs/ne2001.git#egg=ne2001
pip install git+https://github.com/FRBs/astropath.git#egg=astropath
pip install git+https://github.com/linetools/linetools#egg=linetools

# Install package in development mode
pip install -e .

# Run all tests
pytest --pyargs frb

# Run specific test file
pytest frb/tests/test_frb.py

# Run with tox (specific Python version)
tox -e 3.11-test

# Run with coverage
tox -e 3.11-test-cov
```

## Architecture

### Core Classes

- **`frb.frb.FRB`**: Main class representing an observed FRB event. Load by name with `FRB.by_name('FRB20121102A')`. Contains coordinates, DM, RM, redshift, and links to host galaxies.

- **`frb.galaxies.frbgalaxy.FRBGalaxy`** / **`FRBHost`**: Classes for galaxies in FRB fields and confirmed host galaxies. Store photometry, redshifts, morphology, and derived properties.

- **`frb.associate.frbassociate.FRBAssociate`**: Extends the astropath PATH class for probabilistic FRB-galaxy association analysis.

### Key Modules

- **`frb/dm/`**: Dispersion measure calculations
- `igm.py`: IGM DM contributions, cosmic DM estimates
- `host.py`: Host galaxy DM contributions
- `cosmic.py`: Cosmological DM calculations
- `prob_dmz.py`: DM-redshift probability distributions

- **`frb/galaxies/`**: Host galaxy analysis
- `photom.py`: Photometry handling and conversions
- `nebular.py`: Nebular emission line analysis
- `eazy.py` / `cigale.py`: SED fitting interfaces

- **`frb/surveys/`**: Survey data access (PanSTARRS, SDSS, DECaLS, WISE, 2MASS, etc.)

- **`frb/halos/`**: Halo mass function and foreground halo DM models

### Data Storage

FRB and host galaxy data are stored as JSON files in `frb/data/FRBs/` and `frb/data/Galaxies/`. Access via class methods like `FRB.by_name()` or `FRBHost.by_frb()`.

### Cosmology

Default cosmology is Planck18, defined in `frb/defs.py` as `frb_cosmo`. All calculations use this unless explicitly overridden.

### External Dependencies

Critical external packages (not on PyPI):
- `ne2001`: Galactic electron density model for ISM DM
- `astropath`: PATH probabilistic association framework
- `linetools`: Spectroscopic analysis utilities
7 changes: 6 additions & 1 deletion frb/builds/build_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def read_lit_table(lit_entry, coord=None):
idx = int(np.where(match)[0])
return lit_tbl[idx:idx+1]
else:
embed(header="Multiple matches in literature table!")
raise ValueError("More than one match in the table!!!")
else:
# Return
Expand Down Expand Up @@ -261,7 +262,7 @@ def run(host_input:pandas.core.series.Series,
survey = survey_utils.load_survey_by_name(key,
gal_coord,
search_r)
srvy_tbl = survey.get_catalog(print_query=True)
srvy_tbl = survey.get_catalog()#print_query=True)

if srvy_tbl is None or len(srvy_tbl) == 0:
continue
Expand Down Expand Up @@ -489,6 +490,10 @@ def run(host_input:pandas.core.series.Series,

# Vet all
assert Host.vet_all()
#try:
# assert Host.vet_all()
#except AssertionError as e:
# embed(header='Host galaxy failed vetting! 494')

# Write
if out_path is None:
Expand Down
14 changes: 14 additions & 0 deletions frb/data/Galaxies/20220204A/FRB20220204A_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
"cosmo": "Planck18",
"dec": 69.7222,
"dec_FRB": 69.722503,
"derived": {
"AV_old": 1.5444,
"AV_old_loerr": -0.143,
"AV_old_ref": "Sharma2024",
"AV_old_uperr": 0.1565,
"Mtotal": 7521422760.871608,
"Mtotal_loerr": -1305310446.3409758,
"Mtotal_ref": "Sharma2024",
"Mtotal_uperr": 838456401.7401981,
"SFR_SED": 4.3058,
"SFR_SED_loerr": -0.8752,
"SFR_SED_ref": "Sharma2024",
"SFR_SED_uperr": 1.3978
},
"offsets": {
"ang_avg": 2.5888449308348185,
"ang_avg_err": 1.2189686474990278,
Expand Down
19 changes: 14 additions & 5 deletions frb/data/Galaxies/20220207C/FRB20220207C_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
"cosmo": "Planck18",
"dec": 72.88274916666666,
"dec_FRB": 72.882327,
"derived": {
"AV_old": 0.0956,
"AV_old_loerr": -0.0181,
"AV_old_ref": "Sharma2024",
"AV_old_uperr": 0.0233,
"Mtotal": 13976550562.990356,
"Mtotal_loerr": -1023751341.5691204,
"Mtotal_ref": "Sharma2024",
"Mtotal_uperr": 1089520098.8770945,
"SFR_SED": 0.7124,
"SFR_SED_loerr": -0.1347,
"SFR_SED_ref": "Sharma2024",
"SFR_SED_uperr": 0.1244
},
"offsets": {
"ang_avg": 2.6272483853172286,
"ang_avg_err": 0.5904731793305108,
Expand All @@ -12,11 +26,6 @@
"physical_err": 0.5242639894130404
},
"photom": {
"2MASS_H": 15.089434621876995,
"2MASS_H_err": 0.04,
"2MASS_H_flux": 3.3436910716867603,
"2MASS_H_flux_err": 0.12318613147589151,
"2MASS_H_ref": "Sharma2024",
"EBV": 0.6973,
"Pan-STARRS_g": 13.954235698639348,
"Pan-STARRS_g_err": 0.03,
Expand Down
21 changes: 15 additions & 6 deletions frb/data/Galaxies/20220208A/FRB20220208A_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
"cosmo": "Planck18",
"dec": 70.042,
"dec_FRB": 70.041042,
"derived": {
"AV_old": 0.7248,
"AV_old_loerr": -0.0375,
"AV_old_ref": "Sharma2024",
"AV_old_uperr": 0.0433,
"Mtotal": 19480495532.907654,
"Mtotal_loerr": -1021682479.1121788,
"Mtotal_ref": "Sharma2024",
"Mtotal_uperr": 721766508.6799965,
"SFR_SED": 0.6764,
"SFR_SED_loerr": -0.0796,
"SFR_SED_ref": "Sharma2024",
"SFR_SED_uperr": 0.073
},
"offsets": {
"ang_avg": 5.226895038582604,
"ang_avg_err": 0.8423572215214188,
Expand All @@ -27,12 +41,7 @@
"Pan-STARRS_z_err": 0.21,
"Pan-STARRS_z_flux": 0.0414075477001926,
"Pan-STARRS_z_flux_err": 0.008008929774039882,
"Pan-STARRS_z_ref": "Sharma2024",
"WIRC_J": 20.214088099135417,
"WIRC_J_err": 0.08,
"WIRC_J_flux": 0.02981019072439763,
"WIRC_J_flux_err": 0.0021964960250018353,
"WIRC_J_ref": "Sharma2024"
"Pan-STARRS_z_ref": "Sharma2024"
},
"ra": 322.57199999999995,
"ra_FRB": 322.575125,
Expand Down
26 changes: 15 additions & 11 deletions frb/data/Galaxies/20220307B/FRB20220307B_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
"cosmo": "Planck18",
"dec": 72.19188972222223,
"dec_FRB": 72.192386,
"derived": {
"AV_old": 1.874,
"AV_old_loerr": -0.0838,
"AV_old_ref": "Sharma2024",
"AV_old_uperr": 0.0672,
"Mtotal": 21562544068.071934,
"Mtotal_loerr": -1912153185.334015,
"Mtotal_ref": "Sharma2024",
"Mtotal_uperr": 1820443566.727192,
"SFR_SED": 3.1663,
"SFR_SED_loerr": -1.0276,
"SFR_SED_ref": "Sharma2024",
"SFR_SED_uperr": 1.3512
},
"offsets": {
"ang_avg": 2.540982048954476,
"ang_avg_err": 1.1512380152408117,
Expand Down Expand Up @@ -37,17 +51,7 @@
"Pan-STARRS_z_err": 0.06,
"Pan-STARRS_z_flux": 0.07429603274964809,
"Pan-STARRS_z_flux_err": 0.004105750499470491,
"Pan-STARRS_z_ref": "Sharma2024",
"WIRC_H": 18.624185903942895,
"WIRC_H_err": 0.02,
"WIRC_H_flux": 0.1289215839608663,
"WIRC_H_flux_err": 0.0023748233391477683,
"WIRC_H_ref": "Sharma2024",
"WIRC_J": 19.18250216694357,
"WIRC_J_err": 0.02,
"WIRC_J_flux": 0.07709019203465596,
"WIRC_J_flux_err": 0.001420053815960377,
"WIRC_J_ref": "Sharma2024"
"Pan-STARRS_z_ref": "Sharma2024"
},
"ra": 350.87468666666666,
"ra_FRB": 350.874496,
Expand Down
35 changes: 19 additions & 16 deletions frb/data/Galaxies/20220310F/FRB20220310F_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
"cosmo": "Planck18",
"dec": 73.49095694444445,
"dec_FRB": 73.490833,
"derived": {
"AV_old": 0.0401,
"AV_old_loerr": -0.027,
"AV_old_ref": "Sharma2024",
"AV_old_uperr": 0.0607,
"Mtotal": 14702798319.828363,
"Mtotal_loerr": -1854901314.8669643,
"Mtotal_ref": "Sharma2024",
"Mtotal_uperr": 2595365272.322706,
"SFR_SED": 0.9706,
"SFR_SED_loerr": -0.2879,
"SFR_SED_ref": "Sharma2024",
"SFR_SED_uperr": 0.3159
},
"offsets": {
"ang_avg": 2.1771155286258366,
"ang_avg_err": 1.1640176640813238,
Expand All @@ -25,6 +39,10 @@
"DECaL_z_flux": 0.028049599219039715,
"DECaL_z_flux_err": 0.0005673137020713931,
"EBV": 0.0254,
"GALEX_NUV": 22.543869802588716,
"GALEX_NUV_err": 0.226373971,
"GALEX_NUV_flux": 0.0034870010107275074,
"GALEX_NUV_flux_err": 0.0007270331985063052,
"Pan-STARRS_g": 22.193716137054263,
"Pan-STARRS_g_err": 0.1555899977684021,
"Pan-STARRS_g_flux": 0.004814082620479617,
Expand All @@ -44,25 +62,10 @@
"Pan-STARRS_z_flux": 0.019590731646687037,
"Pan-STARRS_z_flux_err": 0.00018043730660203308,
"Pan-STARRS_z_ref": "Sharma2024",
"WIRC_H": 20.27685233211026,
"WIRC_H_err": 0.23,
"WIRC_H_flux": 0.028135786606411944,
"WIRC_H_flux_err": 0.005960223939401883,
"WIRC_H_ref": "Sharma2024",
"WIRC_J": 20.198669547695637,
"WIRC_J_err": 0.21,
"WIRC_J_flux": 0.030236545732084938,
"WIRC_J_flux_err": 0.005848266435171848,
"WIRC_J_ref": "Sharma2024",
"WIRC_K": 20.401723512098595,
"WIRC_K_err": 0.3,
"WIRC_K_flux": 0.025079021597690106,
"WIRC_K_flux_err": 0.006929589753326034,
"WIRC_K_ref": "Sharma2024",
"WISE_W1": 19.996196746826172,
"WISE_W1_err": 0.23000000417232513,
"WISE_W1_flux": 0.03643519803881645,
"WISE_W1_flux_err": 0.007718353066593409,
"WISE_W1_flux_err": 0.007718353997915983,
"WISE_W1_ref": "Sharma2024",
"WISE_W2": 20.477563858032227,
"WISE_W2_err": 0.36000001430511475,
Expand Down
29 changes: 14 additions & 15 deletions frb/data/Galaxies/20220319D/FRB20220319D_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
"cosmo": "Planck18",
"dec": 71.035875,
"dec_FRB": 71.03526,
"derived": {
"AV_old": 0.34,
"AV_old_loerr": -0.01,
"AV_old_ref": "Sharma2024",
"AV_old_uperr": 0.01,
"Mtotal": 19787913352.337383,
"Mtotal_loerr": -123404260.04777144,
"Mtotal_ref": "Sharma2024",
"Mtotal_uperr": 137163262.62660217,
"SFR_SED": 0.4238,
"SFR_SED_loerr": -0.0209,
"SFR_SED_ref": "Sharma2024",
"SFR_SED_uperr": 0.0222
},
"offsets": {
"ang_avg": 9.259871760563033,
"ang_avg_err": 0.5777504427130394,
Expand All @@ -12,21 +26,6 @@
"physical_err": 0.13715840112809607
},
"photom": {
"2MASS_H": 11.990261074483097,
"2MASS_H_err": 0.02,
"2MASS_H_flux": 58.0624776949647,
"2MASS_H_flux_err": 1.0695503648218,
"2MASS_H_ref": "Sharma2024",
"2MASS_J": 11.947014523022894,
"2MASS_J_err": 0.02,
"2MASS_J_flux": 60.421873190788446,
"2MASS_J_flux_err": 1.1130120359990885,
"2MASS_J_ref": "Sharma2024",
"2MASS_K": 12.323423798287955,
"2MASS_K_err": 0.02,
"2MASS_K_flux": 42.71992435220384,
"2MASS_K_flux_err": 0.7869300878977431,
"2MASS_K_ref": "Sharma2024",
"EBV": 0.6957,
"Pan-STARRS_g": 11.159852963003852,
"Pan-STARRS_g_err": 0.02,
Expand Down
14 changes: 14 additions & 0 deletions frb/data/Galaxies/20220330D/FRB20220330D_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
"cosmo": "Planck18",
"dec": 70.35032222222222,
"dec_FRB": 70.35075,
"derived": {
"AV_old": 3.8468,
"AV_old_loerr": -0.0242,
"AV_old_ref": "Sharma2024",
"AV_old_uperr": 0.0214,
"Mtotal": 49636368488.45584,
"Mtotal_loerr": -1121105414.4343948,
"Mtotal_ref": "Sharma2024",
"Mtotal_uperr": 1815363649.709877,
"SFR_SED": 2.0125,
"SFR_SED_loerr": -0.0749,
"SFR_SED_ref": "Sharma2024",
"SFR_SED_uperr": 0.1225
},
"offsets": {
"ang_avg": 3.468386547707636,
"ang_avg_err": 1.373186664162618,
Expand Down
Loading