FRBGalaxy Class
Module for galaxies related to FRBs
- class frb.galaxies.frbgalaxy.FRBGalaxy(ra, dec, frb, cosmo=None)[source]
Bases:
objectParent class for galaxies in FRB fields
Simple object to hold key observable and derived quantities
Warning: Generating hundreds of these objects will likely be slow. Especially SkyCoord generation. A new class will be warranted for that
- Parameters:
- classmethod from_dict(frb, idict, override: bool = False, **kwargs)[source]
Instantiate from a dict
- Parameters:
Returns:
- classmethod from_json(frb, json_file, verbose: bool = True, **kwargs)[source]
- Parameters:
frb (frb.FRB)
json_file
**kwargs
- Returns:
FRBGalaxy or None
- property z_err
Return the redshift error of the galaxy
- Returns:
redshift or nadda
- Return type:
float or None
- calc_nebular_lum(line)[source]
Calculate the line luminosity Applies dust extinction if self.derived[‘AV_nebular’] is filled
Mainly a wrapper to nebular.calc_lum()
- Parameters:
line (str) – Name of the line
- calc_nebular_AV(method='Ha/Hb', min_AV=None, **kwargs)[source]
Calculate an A_V extinction from a pair of Nebular lines
Mainly a wrapper to nebular.calc_dust_extinct
self.derived[‘AV_nebular’] is filled
- Parameters:
Returns:
- calc_nebular_SFR(method='Ha', **kwargs)[source]
Calculate a SFR from a nebular line
Mainly a wrapper to nebular.calc_SFR
self.derived[‘AV_nebular’] is filled with units SFR/yr
- Parameters:
method (str) – Method to use, e.g. ‘Ha’ for Halpha
**kwargs – passed to nebular.calc_SFR
Returns:
- calc_tot_uncert()[source]
Calculate total uncertainty in arcsec of FRB localization + Host localization in the reference frame of the FRB
- Returns:
uncerta, uncertb [arcsec]
- Return type:
- parse_photom(phot_tbl, max_off=<Quantity 1. arcsec>, overwrite=True, EBV=None)[source]
Parse photometry from an input table
Fills the self.photom dict
Also fills fluxes in mJy
- Parameters:
Returns:
- run_cigale(data_file='cigale_in.fits', config_file='pcigale.ini', wait_for_input=False, save_sed=True, plot=True, outdir='out', **kwargs)[source]
Generates the input data file for CIGALE given the photometric points and redshift of a galaxy
- Parameters:
ID – str, optional An ID for the galaxy. If none, “GalaxyA” is assigned.
data_file (str, optional) – Root name for the photometry data file generated used as input to CIGALE
config_file (str, optional) – Root name for the file where CIGALE’s configuration is generated
wait_for_input (bool, optional) – If true, waits for the user to finish editing the auto-generated config file before running.
save_sed (bool, optional) – Saves the best fit SED if true
plot (bool, optional) – Plots the best fit SED if true
cores (int, optional) – Number of CPU cores to be used. Defaults to all cores on the system.
outdir (str, optional) – Path to the many outputs of CIGALE If not supplied, the outputs will appear in a folder named out/
- kwargs: These are passed into gen_cigale_in() and _initialise()
- sed_modules (list of ‘str’, optional):
A list of SED modules to be used in the PDF analysis. If this is being input, there should be a corresponding correct dict for sed_modules_params.
- sed_module_params (dict, optional):
A dict containing parameter values for the input SED modules. Better not use this unless you know exactly what you’re doing.
- get_metaspec(instr=None, return_all=False, specdb_file=None)[source]
Return the meta data and spectra for this FRBGalaxy from the specDB
If there is more than one spectrum, the code returns the first unless return_all=True
- Parameters:
- Returns:
meta data, spectra
- Return type:
astropy.table.Table, linetools.spectra.XSpectrum1D
- parse_cigale(cigale_file, sfh_file=None, overwrite=True)[source]
Parse the output file from CIGALE
Read into self.derived
- Parameters:
Returns:
- parse_galfit(galfit_file, overwrite=True, twocomponent=False)[source]
- Parse an output GALFIT file
or a gallight JSON file
Loaded into self.morphology
- Parameters:
galfit_file (str) – processed ‘out.fits’ file produced by frb.galaxies.galfit.run. Contains a binary table with fit parameters. Or a JSON file from gallight
overwrite (bool, optional) – Need to overwrite the object’s attributes?
twocomponent (bool, optional) – Should the morphology attribute generated contain fit parameters of two components?
- parse_ppxf(ppxf_file, overwrite=True, format='ascii.ecsv')[source]
Parse an output pPXF file generated by our custom run
Loaded into self.lines
- Parameters:
Returns:
- vet_all()[source]
Vette all of the main dicts
- Parameters:
dict
valid_defs
- Returns:
True = passed
- Return type:
- make_outfile()[source]
Auto-generate an output name for the class
- Returns:
Output filename
- Return type:
- class frb.galaxies.frbgalaxy.FRBHost(ra, dec, frb, z_frb=None, **kwargs)[source]
Bases:
FRBGalaxyChild of FRBGalaxy specific for an FRB host
- calc_dm_halo(**kwargs)[source]
Calculate the Halo contribution to the host DM given the host stellar mass in its derived properties dict and the FRB coordinates.
- Parameters:
**kwargs – Passed to dm_host.dm_host_halo
- Returns:
Halo contribution to the DM in pc/cm^3
- Return type:
DM_halo (float)
- make_outfile()[source]
Overloads the parent method for Host specific naming
Naming is FRBXXXXXX_host.json with XXXXXXX supplied by self.frb
- Returns:
Name of the default outfile
- Return type:
- class frb.galaxies.frbgalaxy.FGGalaxy(ra, dec, frb, **kwargs)[source]
Bases:
FRBGalaxyForeground galaxy class (child of FRBGalaxy)
Overview
This module provides the core functionality for handling galaxies related to Fast Radio Bursts (FRBs). It contains the main FRBGalaxy class which serves as a parent class for galaxies in FRB fields, providing a simple object to hold key observable and derived quantities.
Classes
FRBGalaxy
- class frb.galaxies.frbgalaxy.FRBGalaxy(ra, dec, frb, cosmo=None)[source]
Bases:
objectParent class for galaxies in FRB fields
Simple object to hold key observable and derived quantities
Warning: Generating hundreds of these objects will likely be slow. Especially SkyCoord generation. A new class will be warranted for that
- Parameters:
The FRBGalaxy class is designed to hold key observable and derived quantities for galaxies associated with FRB events.
Key Attributes:
redshift (dict): Redshift measurements and estimates
photom (dict): Photometric data across multiple bands
morphology (dict): Morphological properties
neb_lines (dict): Nebular emission line measurements
kinematics (dict): Kinematic measurements
derived (dict): Derived physical quantities
offsets (dict): Positional offsets from FRB coordinates
positional_error (dict): Astrometric and source position errors
Warning
Generating hundreds of these objects will likely be slow, especially due to SkyCoord generation. A new class will be warranted for that use case.
- classmethod from_dict(frb, idict, override: bool = False, **kwargs)[source]
Instantiate from a dict
- Parameters:
Returns:
- classmethod from_json(frb, json_file, verbose: bool = True, **kwargs)[source]
- Parameters:
frb (frb.FRB)
json_file
**kwargs
- Returns:
FRBGalaxy or None
- property z_err
Return the redshift error of the galaxy
- Returns:
redshift or nadda
- Return type:
float or None
- calc_nebular_lum(line)[source]
Calculate the line luminosity Applies dust extinction if self.derived[‘AV_nebular’] is filled
Mainly a wrapper to nebular.calc_lum()
- Parameters:
line (str) – Name of the line
- calc_nebular_AV(method='Ha/Hb', min_AV=None, **kwargs)[source]
Calculate an A_V extinction from a pair of Nebular lines
Mainly a wrapper to nebular.calc_dust_extinct
self.derived[‘AV_nebular’] is filled
- Parameters:
Returns:
- calc_nebular_SFR(method='Ha', **kwargs)[source]
Calculate a SFR from a nebular line
Mainly a wrapper to nebular.calc_SFR
self.derived[‘AV_nebular’] is filled with units SFR/yr
- Parameters:
method (str) – Method to use, e.g. ‘Ha’ for Halpha
**kwargs – passed to nebular.calc_SFR
Returns:
- calc_tot_uncert()[source]
Calculate total uncertainty in arcsec of FRB localization + Host localization in the reference frame of the FRB
- Returns:
uncerta, uncertb [arcsec]
- Return type:
- parse_photom(phot_tbl, max_off=<Quantity 1. arcsec>, overwrite=True, EBV=None)[source]
Parse photometry from an input table
Fills the self.photom dict
Also fills fluxes in mJy
- Parameters:
Returns:
- run_cigale(data_file='cigale_in.fits', config_file='pcigale.ini', wait_for_input=False, save_sed=True, plot=True, outdir='out', **kwargs)[source]
Generates the input data file for CIGALE given the photometric points and redshift of a galaxy
- Parameters:
ID – str, optional An ID for the galaxy. If none, “GalaxyA” is assigned.
data_file (str, optional) – Root name for the photometry data file generated used as input to CIGALE
config_file (str, optional) – Root name for the file where CIGALE’s configuration is generated
wait_for_input (bool, optional) – If true, waits for the user to finish editing the auto-generated config file before running.
save_sed (bool, optional) – Saves the best fit SED if true
plot (bool, optional) – Plots the best fit SED if true
cores (int, optional) – Number of CPU cores to be used. Defaults to all cores on the system.
outdir (str, optional) – Path to the many outputs of CIGALE If not supplied, the outputs will appear in a folder named out/
- kwargs: These are passed into gen_cigale_in() and _initialise()
- sed_modules (list of ‘str’, optional):
A list of SED modules to be used in the PDF analysis. If this is being input, there should be a corresponding correct dict for sed_modules_params.
- sed_module_params (dict, optional):
A dict containing parameter values for the input SED modules. Better not use this unless you know exactly what you’re doing.
- get_metaspec(instr=None, return_all=False, specdb_file=None)[source]
Return the meta data and spectra for this FRBGalaxy from the specDB
If there is more than one spectrum, the code returns the first unless return_all=True
- Parameters:
- Returns:
meta data, spectra
- Return type:
astropy.table.Table, linetools.spectra.XSpectrum1D
- parse_cigale(cigale_file, sfh_file=None, overwrite=True)[source]
Parse the output file from CIGALE
Read into self.derived
- Parameters:
Returns:
- parse_galfit(galfit_file, overwrite=True, twocomponent=False)[source]
- Parse an output GALFIT file
or a gallight JSON file
Loaded into self.morphology
- Parameters:
galfit_file (str) – processed ‘out.fits’ file produced by frb.galaxies.galfit.run. Contains a binary table with fit parameters. Or a JSON file from gallight
overwrite (bool, optional) – Need to overwrite the object’s attributes?
twocomponent (bool, optional) – Should the morphology attribute generated contain fit parameters of two components?
- parse_ppxf(ppxf_file, overwrite=True, format='ascii.ecsv')[source]
Parse an output pPXF file generated by our custom run
Loaded into self.lines
- Parameters:
Returns:
- vet_all()[source]
Vette all of the main dicts
- Parameters:
dict
valid_defs
- Returns:
True = passed
- Return type:
- make_outfile()[source]
Auto-generate an output name for the class
- Returns:
Output filename
- Return type:
Key Methods
Class Methods
Instance Methods
- FRBGalaxy.set_z(z, origin, err=None)[source]
Set the redshift value(s) in self.redshift
- Parameters:
Returns:
Set the redshift value(s) with specified origin (spectroscopic or photometric).
- FRBGalaxy.calc_nebular_lum(line)[source]
Calculate the line luminosity Applies dust extinction if self.derived[‘AV_nebular’] is filled
Mainly a wrapper to nebular.calc_lum()
- Parameters:
line (str) – Name of the line
Calculate line luminosity with optional dust extinction correction.
- FRBGalaxy.run_cigale(data_file='cigale_in.fits', config_file='pcigale.ini', wait_for_input=False, save_sed=True, plot=True, outdir='out', **kwargs)[source]
Generates the input data file for CIGALE given the photometric points and redshift of a galaxy
- Parameters:
ID – str, optional An ID for the galaxy. If none, “GalaxyA” is assigned.
data_file (str, optional) – Root name for the photometry data file generated used as input to CIGALE
config_file (str, optional) – Root name for the file where CIGALE’s configuration is generated
wait_for_input (bool, optional) – If true, waits for the user to finish editing the auto-generated config file before running.
save_sed (bool, optional) – Saves the best fit SED if true
plot (bool, optional) – Plots the best fit SED if true
cores (int, optional) – Number of CPU cores to be used. Defaults to all cores on the system.
outdir (str, optional) – Path to the many outputs of CIGALE If not supplied, the outputs will appear in a folder named out/
- kwargs: These are passed into gen_cigale_in() and _initialise()
- sed_modules (list of ‘str’, optional):
A list of SED modules to be used in the PDF analysis. If this is being input, there should be a corresponding correct dict for sed_modules_params.
- sed_module_params (dict, optional):
A dict containing parameter values for the input SED modules. Better not use this unless you know exactly what you’re doing.
Run CIGALE SED fitting analysis on the galaxy’s photometry.
Properties
Examples
Creating an FRBGalaxy instance:
from frb.frb import FRB
from frb.galaxies.frbgalaxy import FRBGalaxy
# Create FRB object
frb = FRB.by_name('FRB180924')
# Create galaxy object
galaxy = FRBGalaxy(ra=349.24, dec=-40.9, frb=frb)
# Set redshift
galaxy.set_z(0.3214, 'spec', err=0.0001)
Loading from dictionary:
# Load from dictionary
galaxy_dict = {
'ra': 349.24,
'dec': -40.9,
'cosmo': 'Planck18'
}
galaxy = FRBGalaxy.from_dict(frb, galaxy_dict)