astro_prost
Submodules
Functions
|
Associates a transient with its most likely host galaxy. |
|
Wrapper function for associating sample of transients. |
|
Prints summary statistics from association run. |
|
Plots a host-galaxy match with panstarrs postage stamp. |
Package Contents
- associate_transient(idx, row, glade_catalog, n_samples, priors, likes, cosmo, catalogs, cat_priority, name_col, coord_cols, redshift_col, cat_cols, log_fn, n_hosts=2, calc_host_props=False, verbose=0, coord_err_cols=('ra_err', 'dec_err'), strict_checking=False, warn_on_fallback=True, plot_match=False, best_redshift=False)[source]
Associates a transient with its most likely host galaxy.
- Parameters:
idx (int) – Index of the transient from a larger catalog (used to cross-match properties after association).
row (pandas Series) – Full row of transient properties.
glade_catalog (pandas.DataFrame) – GLADE catalog of galaxies, with sizes and photo-zs.
n_samples (int) – Number of samples for the Monte Carlo sampling of associations.
priors (dict) – Dictionary of priors for the run (at least one of redshift, offset, absolute magnitude).!
likes (dict) – Dictionary of likelihoods for the run (at least one of offset, absolute magnitude).
cosmo (astropy.cosmology) – Assumed cosmology for the run (defaults to LambdaCDM if unspecified).
catalogs (dict) – Dict of source catalogs to query, with required key “name” and optional key “release”.
cat_priorities (dict) – The priority order to run the associations (with value 1 will run first, 2nd will run 2nd, etc). If None, defaults to the order the catalogs are provided in.
cat_cols (boolean) – If true, concatenates the source catalog fields to the returned dataframe.
log_fn (str, optional) – The fn associated with the logger.Logger object.
calc_host_props (boolean) – If true, calculates host galaxy properties even if not needed for association
verbose (int) – The verbosity level of the output.
coord_err_cols (tuple of strings) – The column names associated with positional uncertainties on the transient positions.
strict_checking (boolean, optional) – If true, raises error if catalog doesn’t support conditioning on a property requested.
warn_on_fallback (boolean, optional) – If true, raises warning if catalog doesn’t support conditioning on a property requested.
plot_match (boolean, optional) – If true, attempts to generate a plot image.
best_redshift (boolean, optional) – If True, queries NED for spectroscopic redshift when host is found within 1 arcsec. Default is False.
- Returns:
Properties of the first and second-best host galaxy matches, and a dictionary of catalog columns (empty if cat_cols=False)
- Return type:
tuple
- associate_sample(transient_catalog, catalogs, name_col=None, coord_cols=None, redshift_col=None, cat_priority=None, run_name=None, priors=None, likes=None, n_samples=1000, verbose=1, n_hosts=2, parallel=True, save=True, save_path='./', log_path=None, cat_cols=False, progress_bar=False, cosmology=None, n_processes=None, calc_host_props=True, coord_err_cols=None, best_redshift=False)[source]
Wrapper function for associating sample of transients.
- Parameters:
transient_catalog (pandas.DataFrame) – Dataframe containing transient name and coordinates.
priors (dict) – Dictionary of prior distributions on redshift, fractional offset, and/or absolute magnitude
likes (dict) – Dictionary of likelihood distributions on redshift, fractional offset, absolute magnitude
catalogs (list) – List of catalogs to query (can include ‘glade’, ‘decals’, ‘panstarrs’)
cat_priority (dict) – Dict of catalog priority (determines what gets run first)
run_name (str or None) – Optional name for the run – used to name logfiles
n_samples (int) – List of samples to draw for monte-carlo association.
verbose (int) – Verbosity level for logging; can be 0 - 3.
n_hosts (int) – Number of potential hosts to return.
parallel (boolean) – If True, runs in parallel with multiprocessing. Cannot be used with ipython!
save (boolean) – If True, saves resulting association table to save_path.
save_path (str) – Path where the association table should be saved (when save=True).
log_path (str) – Path where the logfile should be saved. If none, log everything to screen
cat_cols (boolean) – If True, contatenates catalog columns to resulting DataFrame.
progress_bar (boolean) – If True, prints a loading bar for each association (when parallel=True).
cosmology (astropy.cosmology) – Assumed cosmology for the run (defaults to LambdaCDM if unspecified).
n_processes (int) – Number of parallel processes to run when parallel=True (defaults to n_cores-4 if unspecified).
calc_host_props (boolean) – If True, calculates all host properties (redshift, absmag, and fractional offset) regardless of whether or not they’re needed for association.
best_redshift (boolean, optional) – If True, queries NED for spectroscopic redshift when host is found within 1 arcsec. Default is False.
- Returns:
The transient dataframe with columns corresponding to the associated transient.
- Return type:
pandas.DataFrame
- diagnose_ranking(true_index, post_probs, galaxy_catalog, post_offset, post_z, post_absmag, galaxy_ids, z_sn, transient_position, logger, post_offset_true=None, post_z_true=None, post_absmag_true=None)[source]
Prints summary statistics from association run.
- Parameters:
true_index (int) – Index of the true host in galaxy_ids.
post_probs (list) – List of total posterior probabilities for candidate hosts.
galaxy_catalog (str) – Galaxy catalog used for association.
post_offset (list) – Posterior probabilities for fractional offset.
post_z (list) – Posterior probabilities for redshift.
post_absmag (list) – Posterior probabilities for absolute magnitude.
galaxy_ids (list) – List of catalog ids for candidate hosts.
z_sn (float) – Redshift of the transient.
transient_position (astropy.coordinates SkyCoord) – Position of the associated transient.
logger (logging.Logger) – Logger instance for messages to console or output file.
post_offset_true (float) – Posterior probability for true host’s fractional offset.
post_z_true (float) – Posterior probability for true host’s redshift.
post_absmag_true (float) – Posterior probability for true host’s absolute magnitude.
- Returns:
true_rank (int) – Rank of the true host galaxy in final association.
post_probs[true_index] (float) – Total posterior probability for true host
- plot_match(host_ra, host_dec, host_redshift_mean, host_redshift_std, transient_ra, transient_dec, transient_name, transient_redshift, bayesflag, fn, logger, true_host_ra=None, true_host_dec=None)[source]
Plots a host-galaxy match with panstarrs postage stamp.
- Parameters:
host_ra (list) – List of right ascension coordinates for associated hosts, in decimal degrees. (Can provide up to 10 hosts)
host_dec (list) – List of declination coordinates for associated hosts, in decimal degrees.
host_redshift_mean (float) – Point estimate of host-galaxy redshift.
host_redshift_std (float) – Error on host_redshift_mean.
transient_ra (float) – Right ascension of transient, in decimal degrees.
transient_dec (float) – Declination of transient, in decimal degrees.
transient_name (str) – Name of transient for plot.
transient_redshift (float) – Redshift of transient, if available.
bayesflag (int) – Flag from association run. If 0, bayes factor is sufficient for confident association. If 1, bayes factor is weak. If 2, bayes factor is strong.
fn (str) – Name of saved image.
logger (logging.Logger) – Logger instance for messages to console or output file.
true_host_ra (float) – Right ascension of the true galaxy in decimal degrees.
true_host_dec (float) – Declination of the true galaxy in decimal degrees.