redback.transient.transient.OpticalTransient
- class redback.transient.transient.OpticalTransient(name: str, data_mode: str = 'magnitude', time: ndarray = None, time_err: ndarray = None, time_mjd: ndarray = None, time_mjd_err: ndarray = None, time_rest_frame: ndarray = None, time_rest_frame_err: ndarray = None, Lum50: ndarray = None, Lum50_err: ndarray = None, flux: ndarray = None, flux_err: ndarray = None, flux_density: ndarray = None, flux_density_err: ndarray = None, magnitude: ndarray = None, magnitude_err: ndarray = None, redshift: float = nan, photon_index: float = nan, frequency: ndarray = None, bands: ndarray = None, system: ndarray = None, active_bands: ndarray | str = 'all', plotting_order: ndarray | str = None, use_phase_model: bool = False, optical_data: bool = True, **kwargs: None)[source]
Bases:
Transient- __init__(name: str, data_mode: str = 'magnitude', time: ndarray = None, time_err: ndarray = None, time_mjd: ndarray = None, time_mjd_err: ndarray = None, time_rest_frame: ndarray = None, time_rest_frame_err: ndarray = None, Lum50: ndarray = None, Lum50_err: ndarray = None, flux: ndarray = None, flux_err: ndarray = None, flux_density: ndarray = None, flux_density_err: ndarray = None, magnitude: ndarray = None, magnitude_err: ndarray = None, redshift: float = nan, photon_index: float = nan, frequency: ndarray = None, bands: ndarray = None, system: ndarray = None, active_bands: ndarray | str = 'all', plotting_order: ndarray | str = None, use_phase_model: bool = False, optical_data: bool = True, **kwargs: None) None[source]
This is a general constructor for the Transient class. Note that you only need to give data corresponding to the data mode you are using. For luminosity data provide times in the rest frame, if using a phase model provide time in MJD, else use the default time (observer frame).
- Parameters:
name (str) – Name of the transient.
data_mode (str, optional) – Data mode. Must be one from OpticalTransient.DATA_MODES.
time (np.ndarray, optional) – Times in the observer frame.
time_err (np.ndarray, optional) – Time errors in the observer frame.
time_mjd (np.ndarray, optional) – Times in MJD. Used if using phase model.
time_mjd_err (np.ndarray, optional) – Time errors in MJD. Used if using phase model.
time_rest_frame (np.ndarray, optional) – Times in the rest frame. Used for luminosity data.
time_rest_frame_err (np.ndarray, optional) – Time errors in the rest frame. Used for luminosity data.
Lum50 (np.ndarray, optional) – Luminosity values.
Lum50_err (np.ndarray, optional) – Luminosity error values.
flux (np.ndarray, optional) – Flux values.
flux_err (np.ndarray, optional) – Flux error values.
flux_density (np.ndarray, optional) – Flux density values.
flux_density_err (np.ndarray, optional) – Flux density error values.
magnitude (np.ndarray, optional) – Magnitude values for photometry data.
magnitude_err (np.ndarray, optional) – Magnitude error values for photometry data.
redshift (float, optional) – Redshift value.
photon_index (float, optional) – Photon index value.
frequency (np.ndarray, optional) – Array of band frequencies in photometry data.
bands (np.ndarray, optional) – Band values.
system (np.ndarray, optional) – System values.
active_bands (Union[list, np.ndarray], optional) – List or array of active bands to be used in the analysis. Use all available bands if ‘all’ is given.
plotting_order (Union[np.ndarray, str], optional) – Order in which to plot the bands/and how unique bands are stored.
use_phase_model (bool, optional) – Whether we are using a phase model.
optical_data (bool, optional) – Whether we are fitting optical data, useful for plotting.
kwargs (dict, optional) –
Additional callables: bands_to_frequency: Conversion function to convert a list of bands to frequencies. Use
redback.utils.bands_to_frequency if not given.
- __call__(**kwargs)
Call self as a function.
Methods
__init__(name[, data_mode, time, time_err, ...])This is a general constructor for the Transient class.
estimate_bb_params([distance, bin_width, ...])Estimate the blackbody temperature and photospheric radius as functions of time by fitting a blackbody SED to the multi‑band photometry.
estimate_bolometric_luminosity([distance, ...])Estimate the bolometric luminosity as a function of time by fitting the blackbody SED to the multi‑band photometry and then integrating that spectrum.
fit_gp(mean_model, kernel[, prior, ...])Fit a GP to the data using george and scipy minimization.
from_lasair_data(name[, data_mode, ...])Constructor method to built object from LASAIR data.
from_lightcurvelynx(name[, data, data_mode, ...])Constructor method to built object from a LightCurveLynx simulated light curve.
from_open_access_catalogue(name[, ...])Constructor method to built object from Open Access Catalogue
from_otter(name[, data_mode, obs_type, ...])Constructor method to build object from OTTER database
from_simulated_optical_data(name[, ...])Constructor method to built object from SimulatedOpticalTransient.
get_colors(filters)Used to filter flux density, photometry or integrated flux data, so we only use data that is using the active bands.
Used to filter data by active bands, returning detection information alongside the usual data.
load_data(processed_file_path[, data_mode])Loads data from specified directory and file, and returns it as a tuple.
load_data_generic(processed_file_path[, ...])Loads data from specified directory and file, and returns it as a tuple.
plot_data([axes, filename, outdir, save, ...])Plots the Transient data and returns Axes.
plot_lightcurve(model[, filename, outdir, ...])plot_multiband([figure, axes, filename, ...])plot_multiband_lightcurve(model[, filename, ...])plot_residual(model[, filename, outdir, ...])set_bands_and_frequency(bands, frequency)Sets bands and frequencies at the same time to keep the logic consistent.
Check that upper limit data points have finite y-values.
Attributes
DATA_MODESList of active bands used.
bandsThe currently active data mode (one in Transient.DATA_MODES).
Default list of filters to use.
True=detection, False=upper limit.
Path to the metadata table.
The band names only associated with the active bands.
The frequencies only associated with the active bands.
The list indices in bands associated with the active bands.
The sncosmo bands only associated with the active bands.
Used band frequencies :rtype: np.ndarray
Returns True if any data points are upper limits.
Indices that map between bands in the data and the unique bands we obtain.
The transient directory given the name of the transient.
All bands that we get from the data, eliminating all duplicates.
All frequencies that we get from the data, eliminating all duplicates.
The sigma level of the upper limits (e.g. 3.0 for 3-sigma limits).
True=upper limit, False=detection.
The time values given the active data mode.
The time error values given the active data mode.
xlabel used in plotting functions :rtype: str
The y values given the active data mode.
The y error values given the active data mode.
ylabel used in plotting functions :rtype: str
ylabel_dict- property active_bands: list
List of active bands used. :rtype list:
- Type:
return
- property data_mode: str
The currently active data mode (one in Transient.DATA_MODES). :rtype: str
- Type:
return
- property default_filters: list
Default list of filters to use. :rtype: list
- Type:
return
- property detections: ndarray | None
True=detection, False=upper limit. None if all points are detections.
- Type:
Boolean array
- estimate_bb_params(distance: float = 1e+27, bin_width: float = 1.0, min_filters: int = 3, **kwargs)[source]
Estimate the blackbody temperature and photospheric radius as functions of time by fitting a blackbody SED to the multi‑band photometry.
The method groups the photometric data into time bins (epochs) of width bin_width (in the same units as self.x, typically days). For each epoch with at least min_filters measurements (from distinct filters), it fits a blackbody model to the data. When working with photometry provided in an effective flux density format (data_mode == “flux_density”) the effective–wavelength approximation is used. When the data_mode is “flux” (or “magnitude”) users have the option (via use_eff_wavelength=True) to instead use the effective wavelength approximation by converting AB magnitudes to flux density (using redback.utils.calc_flux_density_from_ABmag). If this flag is not provided (or is False) then the full bandpass integration is applied.
- Parameters:
distance (float, optional) – Distance to the transient in centimeters. Default is 1e27 cm.
bin_width (float, optional) – Width of the time bins (in days) used to group the photometric data. Default is 1.0.
min_filters (int, optional) – Minimum number of measurements (from distinct filters) required in a bin to perform the fit. Default is 3.
kwargs (Additional keyword arguments) –
maxfev : int, optional, default is 1000 T_init : float, optional, default is 1e4, used as the initial guess for the fit. R_init : float, optional, default is 1e15, used as the initial guess for the fit. use_eff_wavelength : bool, optional, default is False.
If True, then even for photometry provided as magnitudes (or bandpass fluxes), the effective wavelength approximation is used. In that case the AB magnitudes are converted to flux densities via redback.utils.calc_flux_density_from_ABmag. If False, full bandpass integration is used.
- Returns:
df_bb –
- A DataFrame containing columns:
epoch_times : binned epoch times,
temperature : best-fit blackbody temperatures (Kelvin),
radius : best-fit photospheric radii (cm),
temp_err : 1σ uncertainties on the temperatures,
radius_err : 1σ uncertainties on the radii.
Returns None if insufficient data are available.
- Return type:
pandas.DataFrame or None
- estimate_bolometric_luminosity(distance: float = 1e+27, bin_width: float = 1.0, min_filters: int = 3, **kwargs)[source]
Estimate the bolometric luminosity as a function of time by fitting the blackbody SED to the multi‑band photometry and then integrating that spectrum. For each epoch the bolometric luminosity is computed using the Stefan–Boltzmann law evaluated at the source:
L_bol = 4 π R² σ_SB T⁴
Uncertainties in T and R are propagated assuming
(ΔL_bol / L_bol)² = (2 ΔR / R)² + (4 ΔT / T)².
Optionally, two corrections can be applied:
A boost–factor to “restore” missing blue flux. If a cutoff wavelength is provided via the keyword ‘lambda_cut’ (in angstroms), it is converted to centimeters and a boost factor is calculated as:
Boost = (F_tot / F_red)
where F_tot = σ_SB T⁴ and F_red is computed by numerically integrating π * B_λ(T) from the cutoff wavelength (in cm) to infinity. The final (boosted) luminosity becomes:
L_boosted = Boost × (4π R² σ_SB T⁴).
An extinction correction. If the bolometric extinction (A_ext, in magnitudes) is supplied via the keyword ‘A_ext’, the luminosity will be reduced by a factor of 10^(–0.4·A_ext) to account for dust extinction. (A_ext defaults to 0.)
- Parameters:
distance (float, optional) – Distance to the transient in centimeters. (Default is 1e27 cm.)
bin_width (float, optional) – Width of the time bins (in days) used for grouping photometry. (Default is 1.0.)
min_filters (int, optional) – Minimum number of independent filters required in a bin to perform a fit. (Default is 3.)
kwargs (dict, optional) – Additional keyword arguments to pass to estimate_bb_params (e.g., maxfev, T_init, R_init, use_eff_wavelength, etc.). Additionally:
'lambda_cut' (-) – to account for missing blue flux.
'A_ext' (-) – 10^(+0.4·A_ext). (Default is 0.)
- Returns:
df_bol –
- A DataFrame containing columns:
epoch_times: Mean time of the bin (days).
temperature: Fitted blackbody temperature (K).
radius: Fitted photospheric radius (cm).
- lum_bol: Derived bolometric luminosity (1e50 erg/s) computed as 4π R² σ_SB T⁴
(boosted and extinction-corrected if requested).
- lum_bol_bb: Derived bolometric blackbody luminosity (1e50 erg/s) computed as 4π R² σ_SB T⁴,
before applying either the boost or extinction correction.
lum_bol_err: 1σ uncertainty on L_bol (1e50 erg/s) from error propagation.
time_rest_frame: Epoch time divided by (1+redshift), i.e., the rest-frame time in days.
Returns None if no valid blackbody fits were obtained.
- Return type:
pandas.DataFrame or None
- property event_table: str
Path to the metadata table. :rtype: str
- Type:
return
- property filtered_bands: array
The band names only associated with the active bands. :rtype: np.ndarray
- Type:
return
- property filtered_frequencies: array
The frequencies only associated with the active bands. :rtype: np.ndarray
- Type:
return
- property filtered_indices: list | None
The list indices in bands associated with the active bands. :rtype: Union[list, None]
- Type:
return
- property filtered_sncosmo_bands: array
The sncosmo bands only associated with the active bands. :rtype: np.ndarray
- Type:
return
- fit_gp(mean_model, kernel, prior=None, use_frequency=True)
Fit a GP to the data using george and scipy minimization.
- Parameters:
mean_model – Mean model to use in the GP fit. Can be a string to refer to a redback model, a callable, or None
kernel – George GP to use. User must ensure this is set up correctly.
prior – Prior to use when fitting with a mean model.
use_frequency – Whether to use the effective frequency in a 2D GP fit. Cannot be used with most mean models.
- Returns:
Named tuple with George GP object and additional useful data.
- property frequency: ndarray
Used band frequencies :rtype: np.ndarray
- Type:
return
- classmethod from_lasair_data(name: str, data_mode: str = 'magnitude', active_bands: ndarray | str = 'all', use_phase_model: bool = False, plotting_order: ndarray | str = None) Transient
Constructor method to built object from LASAIR data.
- Parameters:
name (str) – Name of the transient.
data_mode (str, optional) – Data mode used. Must be from OpticalTransient.DATA_MODES. Default is magnitude.
active_bands (Union[np.ndarray, str]) – Sets active bands based on array given. If argument is ‘all’, all unique bands in self.bands will be used.
plotting_order (Union[np.ndarray, str], optional) – Order in which to plot the bands/and how unique bands are stored.
use_phase_model (bool, optional) – Whether to use a phase model.
- Returns:
A class instance.
- Return type:
- classmethod from_lightcurvelynx(name: str, data: DataFrame = None, data_mode: str = 'magnitude', active_bands: ndarray | str = 'all', plotting_order: ndarray | str = None, use_phase_model: bool = False, frequency: ndarray = None, include_upper_limits: bool = False, upper_limit_sigma: float | ndarray = 3.0) Transient
Constructor method to built object from a LightCurveLynx simulated light curve. https://github.com/lincc-frameworks/lightcurvelynx Only the time, bands, magnitude and magnitude error columns are used. The rest are computed from those.
- Parameters:
name (str) – Name of the transient.
data (pd.DataFrame, optional) – DataFrame containing the light curve data. If None, it will try to load from “simulated/{name}.csv”.
data_mode (str, optional) – Data mode used. Must be from OpticalTransient.DATA_MODES. Default is magnitude.
active_bands (Union[np.ndarray, str]) – Sets active bands based on array given. If argument is ‘all’, all unique bands in self.bands will be used.
plotting_order (Union[np.ndarray, str], optional) – Order in which to plot the bands/and how unique bands are stored.
use_phase_model (bool, optional) – Whether to use a phase model.
frequency (np.ndarray, optional) – Array of frequencies corresponding to each observation. If None, will be computed from bands using bands_to_frequency.
include_upper_limits (bool, optional) – Whether to include non-detection data points as upper limits. If False (default), non-detections are filtered out (backward compatible behavior). If True, non-detections are preserved and flagged in the detections array.
upper_limit_sigma (Union[float, np.ndarray], optional) – The sigma level of the upper limits. Default is 3.0 (3-sigma limits).
- Returns:
A class instance.
- Return type:
- classmethod from_open_access_catalogue(name: str, data_mode: str = 'magnitude', active_bands: ndarray | str = 'all', plotting_order: ndarray | str = None, use_phase_model: bool = False) OpticalTransient[source]
Constructor method to built object from Open Access Catalogue
- Parameters:
name (str) – Name of the transient.
data_mode (str, optional) – Data mode used. Must be from OpticalTransient.DATA_MODES. Default is magnitude.
active_bands (Union[np.ndarray, str]) – Sets active bands based on array given. If argument is ‘all’, all unique bands in self.bands will be used.
plotting_order (Union[np.ndarray, str], optional) – Order in which to plot the bands/and how unique bands are stored.
use_phase_model (bool, optional) – Whether to use a phase model.
- Returns:
A class instance
- Return type:
- classmethod from_otter(name: str, data_mode: str = 'magnitude', obs_type: str = 'uvoir', active_bands: ndarray | str = 'all', plotting_order: ndarray | str = None, use_phase_model: bool = False) OpticalTransient[source]
Constructor method to build object from OTTER database
- Parameters:
name (str) – Name of the transient in OTTER database.
data_mode (str, optional) – Data mode used. Must be from OpticalTransient.DATA_MODES. Default is magnitude.
obs_type (str, optional) – Observation type: ‘uvoir’ (default), ‘radio’, or ‘xray’.
active_bands (Union[np.ndarray, str]) – Sets active bands based on array given. If argument is ‘all’, all unique bands in self.bands will be used.
plotting_order (Union[np.ndarray, str], optional) – Order in which to plot the bands/and how unique bands are stored.
use_phase_model (bool, optional) – Whether to use a phase model.
- Returns:
A class instance
- Return type:
- classmethod from_simulated_optical_data(name: str, data_mode: str = 'magnitude', active_bands: ndarray | str = 'all', plotting_order: ndarray | str = None, use_phase_model: bool = False, include_upper_limits: bool = False, upper_limit_sigma: float | ndarray = 3.0) Transient
Constructor method to built object from SimulatedOpticalTransient.
- Parameters:
name (str) – Name of the transient.
data_mode (str, optional) – Data mode used. Must be from OpticalTransient.DATA_MODES. Default is magnitude.
active_bands (Union[np.ndarray, str]) – Sets active bands based on array given. If argument is ‘all’, all unique bands in self.bands will be used.
plotting_order (Union[np.ndarray, str], optional) – Order in which to plot the bands/and how unique bands are stored.
use_phase_model (bool, optional) – Whether to use a phase model.
include_upper_limits (bool, optional) – Whether to include non-detection data points as upper limits. If False (default), non-detections are filtered out (backward compatible behavior). If True, non-detections are preserved and flagged in the detections array.
upper_limit_sigma (Union[float, np.ndarray], optional) – The sigma level of the upper limits. Default is 3.0 (3-sigma limits).
- Returns:
A class instance.
- Return type:
- static get_colors(filters: ndarray | list) Colormap
- Parameters:
filters (Union[np.ndarray, list]) – Array of list of filters to use in the plot.
- Returns:
Colormap with one color for each filter.
- Return type:
matplotlib.colors.Colormap
- get_filtered_data() tuple
Used to filter flux density, photometry or integrated flux data, so we only use data that is using the active bands. :return: A tuple with the filtered data. Format is (x, x_err, y, y_err) :rtype: tuple
- get_filtered_data_with_limits() tuple
Used to filter data by active bands, returning detection information alongside the usual data.
- Returns:
A tuple with the filtered data. Format is (x, x_err, y, y_err, detections) where detections is a boolean array (True=detection, False=upper limit) or None if all points are detections.
- Return type:
tuple
- property has_upper_limits: bool
Returns True if any data points are upper limits.
- property list_of_band_indices: list
Indices that map between bands in the data and the unique bands we obtain. :rtype: list
- Type:
return
- static load_data(processed_file_path, data_mode='magnitude')[source]
Loads data from specified directory and file, and returns it as a tuple.
- Parameters:
processed_file_path (str) – Path to the processed file to load
data_mode (str, optional) – Name of the data mode. Must be from [‘magnitude’, ‘flux_density’, ‘all’]. Default is magnitude.
- Returns:
Six elements when querying magnitude or flux_density data, Eight for ‘all’
- Return type:
tuple
- static load_data_generic(processed_file_path, data_mode='magnitude')
Loads data from specified directory and file, and returns it as a tuple.
- Parameters:
processed_file_path (str) – Path to the processed file to load
data_mode (str, optional) – Name of the data mode. Must be from [‘magnitude’, ‘flux_density’, ‘all’]. Default is magnitude.
- Returns:
Six elements when querying magnitude or flux_density data, Eight for ‘all’.
- Return type:
tuple
- plot_data(axes: Axes = None, filename: str = None, outdir: str = None, save: bool = True, show: bool = True, plot_others: bool = True, color: str = 'k', **kwargs) Axes
Plots the Transient data and returns Axes.
- Parameters:
axes – Matplotlib axes to plot the lightcurve into. Useful for user specific modifications to the plot.
filename – Name of the file to be plotted in.
outdir – The directory in which to save the file in.
save – Whether to save the plot. (Default value = True)
show – Whether to show the plot. (Default value = True)
plot_others – Whether to plot inactive bands. (Default value = True)
color – Color of the data.
kwargs – Additional keyword arguments passed to the Plotter. All KwargsAccessorWithDefault attributes on redback.plotting.Plotter are accepted. Run
redback.plotting.get_plotter_kwargs_docs()to see all options and defaults.
- Returns:
The axes with the plot.
- plot_lightcurve(model: callable, filename: str = None, outdir: str = None, axes: Axes = None, save: bool = True, show: bool = True, random_models: int = 100, posterior: DataFrame = None, model_kwargs: dict = None, **kwargs: None) Axes
- Parameters:
model – The model used to plot the lightcurve.
filename – The output filename. Otherwise, use default which starts with the name attribute and ends with *lightcurve.png.
axes – Axes to plot in if given.
save – Whether to save the plot.
show – Whether to show the plot.
random_models – Number of random posterior samples plotted faintly. (Default value = 100)
posterior – Posterior distribution to which to draw samples from. Is optional but must be given.
outdir – Out directory in which to save the plot. Default is the current working directory.
model_kwargs – Additional keyword arguments to be passed into the model.
kwargs – Additional keyword arguments to pass in the Plotter methods.
Available in the online documentation under at redback.plotting.Plotter.
- Keyword Arguments:
capsize – Same as matplotlib capsize.
bands_to_plot – List of bands to plot in plot lightcurve and multiband lightcurve. Default is active bands.
legend_location – Same as matplotlib legend location.
legend_cols – Same as matplotlib legend columns.
color – Color of the data points.
band_colors – A dictionary with the colors of the bands.
band_labels – List with the names of the bands.
band_scaling – Dict with the scaling for each band. First entry should be {type: ‘+’ or ‘x’} for different types.
dpi – Same as matplotlib dpi.
elinewidth – same as matplotlib elinewidth
errorbar_fmt – ‘fmt’ argument of ax.errorbar.
model – str or callable, the model to plot.
ms – Same as matplotlib markersize.
axis_tick_params_pad – pad argument in calls to ax.tick_params when setting the axes.
max_likelihood_alpha – alpha argument, i.e. transparency, when plotting the max likelihood curve.
random_sample_alpha – alpha argument, i.e. transparency, when plotting random sample curves.
uncertainty_band_alpha – alpha argument, i.e. transparency, when plotting a credible band.
max_likelihood_color – Color of the maximum likelihood curve.
random_sample_color – Color of the random sample curves.
bbox_inches – Setting for saving plots. Default is ‘tight’.
linewidth – Same as matplotlib linewidth
zorder – Same as matplotlib zorder
xy – For `ax.annotate’ x and y coordinates of the point to annotate.
xycoords – The coordinate system xy is given in. Default is ‘axes fraction’
horizontalalignment – Horizontal alignment of the annotation. Default is ‘right’
annotation_size – size argument of of ax.annotate.
fontsize_axes – Font size of the x and y labels.
fontsize_legend – Font size of the legend.
fontsize_figure – Font size of the figure. Relevant for multiband plots. Used on supxlabel and supylabel.
fontsize_ticks – Font size of the axis ticks.
hspace – Argument for subplots_adjust, sets horizontal spacing between panels.
wspace – Argument for subplots_adjust, sets horizontal spacing between panels.
plot_others – Whether to plot additional bands in the data plot, all in the same colors
random_models – Number of random draws to use to calculate credible bands or to plot.
uncertainty_mode – ‘random_models’: Plot random draws from the available parameter sets. ‘credible_intervals’: Plot a credible interval that is calculated based on the available parameter sets.
reference_mjd_date – Date to use as reference point for the x axis. Default is the first date in the data.
credible_interval_level – 0.9: Plot the 90% credible interval.
plot_max_likelihood – Plots the draw corresponding to the maximum likelihood. Default is ‘True’.
set_same_color_per_subplot – Sets the lightcurve to be the same color as the data per subplot. Default is ‘True’.
xlim_high_multiplier – Adjust the maximum xlim based on available x values.
xlim_low_multiplier – Adjust the minimum xlim based on available x values.
ylim_high_multiplier – Adjust the maximum ylim based on available x values.
ylim_low_multiplier – Adjust the minimum ylim based on available x values.
show_grid – Whether to show grid lines. Default is False.
grid_alpha – Transparency of grid lines. Default is 0.3.
grid_color – Color of grid lines. Default is ‘gray’.
grid_linestyle – Line style of grid lines. Default is ‘–‘.
grid_linewidth – Line width of grid lines. Default is 0.5.
save_format – Format for saving plots (e.g., ‘png’, ‘pdf’, ‘svg’, ‘eps’). Default is ‘png’.
transparent – Whether to save plots with transparent background. Default is False.
xscale – X-axis scale (‘linear’, ‘log’, ‘symlog’, ‘logit’). Default is None (auto-determined).
yscale – Y-axis scale (‘linear’, ‘log’, ‘symlog’, ‘logit’). Default is None (auto-determined).
title – Title for the plot. Default is None (no title).
title_fontsize – Font size for the title. Default is 20.
linestyle – Line style for model curves. Default is ‘-‘.
max_likelihood_linestyle – Line style for max likelihood curve. Default is ‘-‘.
random_sample_linestyle – Line style for random sample curves. Default is ‘-‘.
markerfillstyle – Fill style for markers (‘full’, ‘left’, ‘right’, ‘bottom’, ‘top’, ‘none’). Default is ‘full’.
markeredgecolor – Edge color for markers. Default is None (same as face color).
markeredgewidth – Edge width for markers. Default is 1.0.
legend_frameon – Whether to draw a frame around the legend. Default is True.
legend_shadow – Whether to draw a shadow behind the legend. Default is False.
legend_fancybox – Whether to use rounded corners for legend frame. Default is True.
legend_framealpha – Transparency of legend frame. Default is 0.8.
tick_direction – Direction of tick marks (‘in’, ‘out’, ‘inout’). Default is ‘in’.
tick_length – Length of tick marks. Default is None (matplotlib default).
tick_width – Width of tick marks. Default is None (matplotlib default).
show_spines – Whether to show plot spines (borders). Default is True.
spine_linewidth – Width of plot spines. Default is None (matplotlib default).
- Returns:
The axes.
- plot_multiband(figure: Figure = None, axes: Axes = None, filename: str = None, outdir: str = None, ncols: int = 2, save: bool = True, show: bool = True, nrows: int = None, figsize: tuple = None, filters: list = None, **kwargs: None) Axes
- Parameters:
figure – Figure can be given if defaults are not satisfying.
axes – Axes can be given if defaults are not satisfying.
filename – Name of the file to be plotted in.
outdir – The directory in which to save the file in.
save – Whether to save the plot. (Default value = True)
show – Whether to show the plot. (Default value = True)
ncols – Number of columns to use on the plot. Default is 2.
nrows – Number of rows to use on the plot. If None are given this will be inferred from ncols and the number of filters.
figsize – Size of the figure. A default based on ncols and nrows will be used if None is given.
filters – Which bands to plot. Will use default filters if None is given.
kwargs – Additional keyword arguments passed to the Plotter. All KwargsAccessorWithDefault attributes on redback.plotting.Plotter are accepted. Run
redback.plotting.get_plotter_kwargs_docs()to see all options and defaults.
- Returns:
The axes.
- plot_multiband_lightcurve(model: callable, filename: str = None, outdir: str = None, figure: Figure = None, axes: Axes = None, save: bool = True, show: bool = True, random_models: int = 100, posterior: DataFrame = None, model_kwargs: dict = None, **kwargs: object) Axes
- Parameters:
model – The model used to plot the lightcurve.
filename – The output filename. Otherwise, use default which starts with the name attribute and ends with *lightcurve.png.
figure – Figure can be given if defaults are not satisfying.
axes – Axes to plot in if given.
save – Whether to save the plot.
show – Whether to show the plot.
random_models – Number of random posterior samples plotted faintly. (Default value = 100)
posterior – Posterior distribution to which to draw samples from. Is optional but must be given.
outdir – Out directory in which to save the plot. Default is the current working directory.
model_kwargs – Additional keyword arguments to be passed into the model.
kwargs – Additional keyword arguments to pass in the Plotter methods.
Available in the online documentation under at redback.plotting.Plotter.
- Keyword Arguments:
capsize – Same as matplotlib capsize.
bands_to_plot – List of bands to plot in plot lightcurve and multiband lightcurve. Default is active bands.
legend_location – Same as matplotlib legend location.
legend_cols – Same as matplotlib legend columns.
color – Color of the data points.
band_colors – A dictionary with the colors of the bands.
band_labels – List with the names of the bands.
band_scaling – Dict with the scaling for each band. First entry should be {type: ‘+’ or ‘x’} for different types.
dpi – Same as matplotlib dpi.
elinewidth – same as matplotlib elinewidth
errorbar_fmt – ‘fmt’ argument of ax.errorbar.
model – str or callable, the model to plot.
ms – Same as matplotlib markersize.
axis_tick_params_pad – pad argument in calls to ax.tick_params when setting the axes.
max_likelihood_alpha – alpha argument, i.e. transparency, when plotting the max likelihood curve.
random_sample_alpha – alpha argument, i.e. transparency, when plotting random sample curves.
uncertainty_band_alpha – alpha argument, i.e. transparency, when plotting a credible band.
max_likelihood_color – Color of the maximum likelihood curve.
random_sample_color – Color of the random sample curves.
bbox_inches – Setting for saving plots. Default is ‘tight’.
linewidth – Same as matplotlib linewidth
zorder – Same as matplotlib zorder
xy – For `ax.annotate’ x and y coordinates of the point to annotate.
xycoords – The coordinate system xy is given in. Default is ‘axes fraction’
horizontalalignment – Horizontal alignment of the annotation. Default is ‘right’
annotation_size – size argument of of ax.annotate.
fontsize_axes – Font size of the x and y labels.
fontsize_legend – Font size of the legend.
fontsize_figure – Font size of the figure. Relevant for multiband plots. Used on supxlabel and supylabel.
fontsize_ticks – Font size of the axis ticks.
hspace – Argument for subplots_adjust, sets horizontal spacing between panels.
wspace – Argument for subplots_adjust, sets horizontal spacing between panels.
plot_others – Whether to plot additional bands in the data plot, all in the same colors
random_models – Number of random draws to use to calculate credible bands or to plot.
uncertainty_mode – ‘random_models’: Plot random draws from the available parameter sets. ‘credible_intervals’: Plot a credible interval that is calculated based on the available parameter sets.
reference_mjd_date – Date to use as reference point for the x axis. Default is the first date in the data.
credible_interval_level – 0.9: Plot the 90% credible interval.
plot_max_likelihood – Plots the draw corresponding to the maximum likelihood. Default is ‘True’.
set_same_color_per_subplot – Sets the lightcurve to be the same color as the data per subplot. Default is ‘True’.
xlim_high_multiplier – Adjust the maximum xlim based on available x values.
xlim_low_multiplier – Adjust the minimum xlim based on available x values.
ylim_high_multiplier – Adjust the maximum ylim based on available x values.
ylim_low_multiplier – Adjust the minimum ylim based on available x values.
show_grid – Whether to show grid lines. Default is False.
grid_alpha – Transparency of grid lines. Default is 0.3.
grid_color – Color of grid lines. Default is ‘gray’.
grid_linestyle – Line style of grid lines. Default is ‘–‘.
grid_linewidth – Line width of grid lines. Default is 0.5.
save_format – Format for saving plots (e.g., ‘png’, ‘pdf’, ‘svg’, ‘eps’). Default is ‘png’.
transparent – Whether to save plots with transparent background. Default is False.
xscale – X-axis scale (‘linear’, ‘log’, ‘symlog’, ‘logit’). Default is None (auto-determined).
yscale – Y-axis scale (‘linear’, ‘log’, ‘symlog’, ‘logit’). Default is None (auto-determined).
title – Title for the plot. Default is None (no title).
title_fontsize – Font size for the title. Default is 20.
linestyle – Line style for model curves. Default is ‘-‘.
max_likelihood_linestyle – Line style for max likelihood curve. Default is ‘-‘.
random_sample_linestyle – Line style for random sample curves. Default is ‘-‘.
markerfillstyle – Fill style for markers (‘full’, ‘left’, ‘right’, ‘bottom’, ‘top’, ‘none’). Default is ‘full’.
markeredgecolor – Edge color for markers. Default is None (same as face color).
markeredgewidth – Edge width for markers. Default is 1.0.
legend_frameon – Whether to draw a frame around the legend. Default is True.
legend_shadow – Whether to draw a shadow behind the legend. Default is False.
legend_fancybox – Whether to use rounded corners for legend frame. Default is True.
legend_framealpha – Transparency of legend frame. Default is 0.8.
tick_direction – Direction of tick marks (‘in’, ‘out’, ‘inout’). Default is ‘in’.
tick_length – Length of tick marks. Default is None (matplotlib default).
tick_width – Width of tick marks. Default is None (matplotlib default).
show_spines – Whether to show plot spines (borders). Default is True.
spine_linewidth – Width of plot spines. Default is None (matplotlib default).
- Returns:
The axes.
- plot_residual(model: callable, filename: str = None, outdir: str = None, axes: Axes = None, save: bool = True, show: bool = True, posterior: DataFrame = None, model_kwargs: dict = None, **kwargs: None) Axes
- Parameters:
model – The model used to plot the lightcurve.
filename – The output filename. Otherwise, use default which starts with the name attribute and ends with *lightcurve.png.
axes – Axes to plot in if given.
save – Whether to save the plot.
show – Whether to show the plot.
posterior – Posterior distribution to which to draw samples from. Is optional but must be given.
outdir – Out directory in which to save the plot. Default is the current working directory.
model_kwargs – Additional keyword arguments to be passed into the model.
kwargs – Additional keyword arguments to pass in the Plotter methods.
Available in the online documentation under at redback.plotting.Plotter.
- Keyword Arguments:
capsize – Same as matplotlib capsize.
bands_to_plot – List of bands to plot in plot lightcurve and multiband lightcurve. Default is active bands.
legend_location – Same as matplotlib legend location.
legend_cols – Same as matplotlib legend columns.
color – Color of the data points.
band_colors – A dictionary with the colors of the bands.
band_labels – List with the names of the bands.
band_scaling – Dict with the scaling for each band. First entry should be {type: ‘+’ or ‘x’} for different types.
dpi – Same as matplotlib dpi.
elinewidth – same as matplotlib elinewidth
errorbar_fmt – ‘fmt’ argument of ax.errorbar.
model – str or callable, the model to plot.
ms – Same as matplotlib markersize.
axis_tick_params_pad – pad argument in calls to ax.tick_params when setting the axes.
max_likelihood_alpha – alpha argument, i.e. transparency, when plotting the max likelihood curve.
random_sample_alpha – alpha argument, i.e. transparency, when plotting random sample curves.
uncertainty_band_alpha – alpha argument, i.e. transparency, when plotting a credible band.
max_likelihood_color – Color of the maximum likelihood curve.
random_sample_color – Color of the random sample curves.
bbox_inches – Setting for saving plots. Default is ‘tight’.
linewidth – Same as matplotlib linewidth
zorder – Same as matplotlib zorder
xy – For `ax.annotate’ x and y coordinates of the point to annotate.
xycoords – The coordinate system xy is given in. Default is ‘axes fraction’
horizontalalignment – Horizontal alignment of the annotation. Default is ‘right’
annotation_size – size argument of of ax.annotate.
fontsize_axes – Font size of the x and y labels.
fontsize_legend – Font size of the legend.
fontsize_figure – Font size of the figure. Relevant for multiband plots. Used on supxlabel and supylabel.
fontsize_ticks – Font size of the axis ticks.
hspace – Argument for subplots_adjust, sets horizontal spacing between panels.
wspace – Argument for subplots_adjust, sets horizontal spacing between panels.
plot_others – Whether to plot additional bands in the data plot, all in the same colors
random_models – Number of random draws to use to calculate credible bands or to plot.
uncertainty_mode – ‘random_models’: Plot random draws from the available parameter sets. ‘credible_intervals’: Plot a credible interval that is calculated based on the available parameter sets.
reference_mjd_date – Date to use as reference point for the x axis. Default is the first date in the data.
credible_interval_level – 0.9: Plot the 90% credible interval.
plot_max_likelihood – Plots the draw corresponding to the maximum likelihood. Default is ‘True’.
set_same_color_per_subplot – Sets the lightcurve to be the same color as the data per subplot. Default is ‘True’.
xlim_high_multiplier – Adjust the maximum xlim based on available x values.
xlim_low_multiplier – Adjust the minimum xlim based on available x values.
ylim_high_multiplier – Adjust the maximum ylim based on available x values.
ylim_low_multiplier – Adjust the minimum ylim based on available x values.
show_grid – Whether to show grid lines. Default is False.
grid_alpha – Transparency of grid lines. Default is 0.3.
grid_color – Color of grid lines. Default is ‘gray’.
grid_linestyle – Line style of grid lines. Default is ‘–‘.
grid_linewidth – Line width of grid lines. Default is 0.5.
save_format – Format for saving plots (e.g., ‘png’, ‘pdf’, ‘svg’, ‘eps’). Default is ‘png’.
transparent – Whether to save plots with transparent background. Default is False.
xscale – X-axis scale (‘linear’, ‘log’, ‘symlog’, ‘logit’). Default is None (auto-determined).
yscale – Y-axis scale (‘linear’, ‘log’, ‘symlog’, ‘logit’). Default is None (auto-determined).
title – Title for the plot. Default is None (no title).
title_fontsize – Font size for the title. Default is 20.
linestyle – Line style for model curves. Default is ‘-‘.
max_likelihood_linestyle – Line style for max likelihood curve. Default is ‘-‘.
random_sample_linestyle – Line style for random sample curves. Default is ‘-‘.
markerfillstyle – Fill style for markers (‘full’, ‘left’, ‘right’, ‘bottom’, ‘top’, ‘none’). Default is ‘full’.
markeredgecolor – Edge color for markers. Default is None (same as face color).
markeredgewidth – Edge width for markers. Default is 1.0.
legend_frameon – Whether to draw a frame around the legend. Default is True.
legend_shadow – Whether to draw a shadow behind the legend. Default is False.
legend_fancybox – Whether to use rounded corners for legend frame. Default is True.
legend_framealpha – Transparency of legend frame. Default is 0.8.
tick_direction – Direction of tick marks (‘in’, ‘out’, ‘inout’). Default is ‘in’.
tick_length – Length of tick marks. Default is None (matplotlib default).
tick_width – Width of tick marks. Default is None (matplotlib default).
show_spines – Whether to show plot spines (borders). Default is True.
spine_linewidth – Width of plot spines. Default is None (matplotlib default).
- Returns:
The axes.
- set_bands_and_frequency(bands: None | list | ndarray, frequency: None | list | ndarray)
Sets bands and frequencies at the same time to keep the logic consistent. If both are given use those values. If only frequencies are given, use them also as band names. If only bands are given, try to convert them to frequencies.
- Parameters:
bands (Union[None, list, np.ndarray]) – The bands, e.g. [‘g’, ‘i’].
frequency (Union[None, list, np.ndarray]) – The frequencies associated with the bands i.e., the effective frequency.
- property transient_dir: str
The transient directory given the name of the transient. :rtype: str
- Type:
return
- property unique_bands: ndarray
All bands that we get from the data, eliminating all duplicates. :rtype: np.ndarray
- Type:
return
- property unique_frequencies: ndarray
All frequencies that we get from the data, eliminating all duplicates. :rtype: np.ndarray
- Type:
return
- property upper_limit_sigma: float | ndarray
The sigma level of the upper limits (e.g. 3.0 for 3-sigma limits).
- property upper_limits: ndarray
True=upper limit, False=detection. All False if no upper limits.
- Type:
Boolean array
- validate_upper_limits() None
Check that upper limit data points have finite y-values.
Upper limits require a finite y-value (the limit value) for both plotting and likelihood computation. NaN y-values for upper limits are not usable because there is no position to draw the marker at, and the likelihood cannot evaluate the CDF without a numerical limit.
Logs a warning for each band with NaN upper limits.
- property x: ndarray
The time values given the active data mode. :rtype: np.ndarray
- Type:
return
- property x_err: ndarray
The time error values given the active data mode. :rtype: np.ndarray
- Type:
return
- property xlabel: str
xlabel used in plotting functions :rtype: str
- Type:
return
- property y: ndarray
The y values given the active data mode. :rtype: np.ndarray
- Type:
return
- property y_err: ndarray
The y error values given the active data mode. :rtype: np.ndarray
- Type:
return
- property ylabel: str
ylabel used in plotting functions :rtype: str
- Type:
return