src.superphot_plus.plotting.utils

This module contains helper functions to access/manipulate data for plotting more concisely.

Module Contents

Functions

lighten_color(color[, amount])

Lightens the given color by multiplying (1-luminosity) by the given amount.

get_survey_fracs()

Return catalog with supernova fractions from existing

read_probs_csv(probs_fn)

Helper function to read in a probability csv file

get_alerce_pred_class(ztf_name, alerce[, superphot_style])

Get alerce probabilities corresponding to the four (no SN IIn)

create_alerce_pred_csv(probs_fn, save_fn)

Generate csv with ALeRCE's predicted

retrieve_four_class_info(probs_csv, probs_alerce_csv)

Extract Superphot+ and ALeRCE predictions and true class info.

gaussian(inputs, amp, mean, sigma)

Evaluate a gaussian with params A at the values in x.

histedges_equalN(vals, nbin)

Generate histogram bin edges, such that counts are equal in each bin.

add_snr_to_prob_csv(probs_csv, data_dir, new_csv)

Adds 10% SNR and num of SNR > 5 points columns

calc_precision_recall(y_true, y_score, folds)

Calculate purity recall values at

roc_curve_w_uncertainties(y_true, y_score, folds)

Incorporate K-fold uncertainties.

rebin_prec_recall(t, r, rerr, p, perr)

Turn completeness to the independent variable,

calc_calibration_curve(y_true, y_score, folds)

Return confidence vs. fraction of true positives.

lighten_color(color, amount=0.5)[source]

Lightens the given color by multiplying (1-luminosity) by the given amount. Input can be matplotlib color string, hex string, or RGB tuple.

get_survey_fracs()[source]

Return catalog with supernova fractions from existing catalogue datasets. referenced in papers.

read_probs_csv(probs_fn)[source]

Helper function to read in a probability csv file and return the columns as numpy arrays.

get_alerce_pred_class(ztf_name, alerce, superphot_style=False)[source]

Get alerce probabilities corresponding to the four (no SN IIn) classes in our ZTF classifier.

Parameters:
  • ztf_name (str) – ZTF name of the object.

  • superphot_style (bool, optional) – If True, change format of output labels. Default is False.

Returns:

Predicted class label.

Return type:

str

create_alerce_pred_csv(probs_fn, save_fn)[source]

Generate csv with ALeRCE’s predicted classes for SN names in probs_csv.

retrieve_four_class_info(probs_csv, probs_alerce_csv, p07=False)[source]

Extract Superphot+ and ALeRCE predictions and true class info.

gaussian(inputs, amp, mean, sigma)[source]

Evaluate a gaussian with params A at the values in x.

Parameters:
  • inputs (array-like or float) – Value(s) to evaluate gaussian at

  • amp (float) – Amplitude of the Gaussian.

  • mean (float) – Mean of Gaussian

  • sigma (float) – Standard deviation of Gaussian

Returns:

Gaussian values evaluated at x

Return type:

array-like or float

histedges_equalN(vals, nbin)[source]

Generate histogram bin edges, such that counts are equal in each bin.

Parameters:
  • vals (array-like or float) – Value(s) to bin in histogram

  • nbin (integer) – number of bins

add_snr_to_prob_csv(probs_csv, data_dir, new_csv)[source]

Adds 10% SNR and num of SNR > 5 points columns to probability CSV. Useful for plots.

calc_precision_recall(y_true, y_score, folds)[source]

Calculate purity recall values at multiple threshholds for plot. Assumes y_true only contains 0s and 1s (target), and y_score are probabilities of being class 1.

roc_curve_w_uncertainties(y_true, y_score, folds)[source]

Incorporate K-fold uncertainties.

rebin_prec_recall(t, r, rerr, p, perr)[source]

Turn completeness to the independent variable, and bin precision accordingly.

calc_calibration_curve(y_true, y_score, folds)[source]

Return confidence vs. fraction of true positives.