redback.transient.afterglow.LGRB
- class redback.transient.afterglow.LGRB(name: str, data_mode: str = 'flux', time: Optional[ndarray] = None, time_err: Optional[ndarray] = None, time_mjd: Optional[ndarray] = None, time_mjd_err: Optional[ndarray] = None, time_rest_frame: Optional[ndarray] = None, time_rest_frame_err: Optional[ndarray] = None, Lum50: Optional[ndarray] = None, Lum50_err: Optional[ndarray] = None, flux: Optional[ndarray] = None, flux_err: Optional[ndarray] = None, flux_density: Optional[ndarray] = None, flux_density_err: Optional[ndarray] = None, magnitude: Optional[ndarray] = None, magnitude_err: Optional[ndarray] = None, redshift: float = nan, photon_index: float = nan, frequency: Optional[ndarray] = None, bands: Optional[ndarray] = None, system: Optional[ndarray] = None, active_bands: Union[ndarray, str] = 'all', use_phase_model: bool = False, optical_data: bool = False, **kwargs: None)[source]
Bases:
Afterglow
- __init__(name: str, data_mode: str = 'flux', time: Optional[ndarray] = None, time_err: Optional[ndarray] = None, time_mjd: Optional[ndarray] = None, time_mjd_err: Optional[ndarray] = None, time_rest_frame: Optional[ndarray] = None, time_rest_frame_err: Optional[ndarray] = None, Lum50: Optional[ndarray] = None, Lum50_err: Optional[ndarray] = None, flux: Optional[ndarray] = None, flux_err: Optional[ndarray] = None, flux_density: Optional[ndarray] = None, flux_density_err: Optional[ndarray] = None, magnitude: Optional[ndarray] = None, magnitude_err: Optional[ndarray] = None, redshift: float = nan, photon_index: float = nan, frequency: Optional[ndarray] = None, bands: Optional[ndarray] = None, system: Optional[ndarray] = None, active_bands: Union[ndarray, str] = 'all', use_phase_model: bool = False, optical_data: bool = False, **kwargs: None) None
This is a general constructor for the Afterglow 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) – Telephone number of GRB, e.g., ‘GRB140903A’ or ‘140903A’ are valid inputs
data_mode (str, optional) – Data mode. Must be one from Afterglow.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) – Redshift value. Will be read from the metadata table if not given.
photon_index (float) – Photon index value. Will be read from the metadata table if not given.
use_phase_model (bool) – Whether we are using a phase model.
optical_data (bool, optional) – Whether we are fitting optical data, useful for plotting.
frequency (np.ndarray, optional) – Array of band frequencies in photometry data.
system (np.ndarray, optional) – System values.
bands (np.ndarray, optional) – Band values.
active_bands (Union[list, np.ndarray]) – List or array of active bands to be used in the analysis. Use all available bands if ‘all’ is given.
kwargs (None, optional) –
Additional classes that can be customised to fulfil the truncation on flux to luminosity conversion: FluxToLuminosityConverter: Conversion class to convert fluxes to luminosities.
If not given use FluxToLuminosityConverter in this module.
Truncator: Truncation class that truncates the data. If not given use Truncator in this module.
- __call__(**kwargs)
Call self as a function.
Methods
__init__
(name[, data_mode, time, time_err, ...])This is a general constructor for the Afterglow class.
Converts flux to luminosity using the analytical method.
from_lasair_data
(name[, data_mode, ...])Constructor method to built object from LASAIR data.
from_simulated_optical_data
(name[, ...])Constructor method to built object from SimulatedOpticalTransient.
from_swift_grb
(name[, data_mode, truncate, ...])- param name:
Telephone number of SGRB, e.g., 'GRB140903A' or '140903A' are valid inputs
get_colors
(filters)- param filters:
Array of list of filters to use in the plot.
Used to filter flux density, photometry or integrated flux data, so we only use data that is using the active bands.
load_and_truncate_data
([truncate, ...])Read data of SGRB from given path and GRB telephone number.
load_data
(name[, data_mode])Loads and returns data from a csv file
load_data_generic
(processed_file_path[, ...])Loads data from specified directory and file, and returns it as a tuple.
Converts flux to luminosity using the numerical method.
plot_data
([axes, filename, outdir, save, ...])Plots the Transient data and returns Axes.
plot_lightcurve
(model[, filename, outdir, ...])- param model:
The model used to plot the lightcurve.
plot_multiband
([figure, axes, filename, ...])- param figure:
Figure can be given if defaults are not satisfying.
plot_multiband_lightcurve
(model[, filename, ...])- param model:
The model used to plot the lightcurve.
plot_residual
(model[, filename, outdir, ...])- param model:
The model used to plot the lightcurve.
set_bands_and_frequency
(bands, frequency)Sets bands and frequencies at the same time to keep the logic consistent.
truncate
([truncate_method])Truncate the data using the specified method.
Attributes
DATA_MODES
List of active bands used.
bands
The currently active data mode (one in Transient.DATA_MODES) :rtype: str
Default list of filters to use.
Relative path to the event 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
Indices that map between bands in the data and the unique bands we obtain.
All bands that we get from the data, eliminating all duplicates.
All frequencies that we get from the data, eliminating all duplicates.
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
- analytical_flux_to_luminosity() None
Converts flux to luminosity using the analytical method.
- 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 event_table: str
Relative path to the event 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: Optional[list]
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
- property frequency: ndarray
Used band frequencies :rtype: np.ndarray
- Type:
return
- classmethod from_lasair_data(name: str, data_mode: str = 'magnitude', active_bands: Union[ndarray, str] = 'all', use_phase_model: bool = False) 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.
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: Union[ndarray, str] = 'all', use_phase_model: bool = False) 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.
use_phase_model (bool, optional) – Whether to use a phase model.
- Returns:
A class instance.
- Return type:
- classmethod from_swift_grb(name: str, data_mode: str = 'flux', truncate: bool = True, truncate_method: str = 'prompt_time_error', **kwargs) Afterglow
- Parameters:
name (str) – Telephone number of SGRB, e.g., ‘GRB140903A’ or ‘140903A’ are valid inputs
data_mode (str, optional) – Data mode. Must be one from Afterglow.DATA_MODES. (Default value = ‘flux’)
truncate (bool) – Whether to truncate the data. (Default value = True)
truncate_method (str) – Must be from Truncator.TRUNCATE_METHODS. (Default value = ‘prompt_time_error’)
kwargs (dict) – Additional keywords to pass into Afterglow.__init__
- Returns:
The Afterglow object.
- Return type:
- static get_colors(filters: Union[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
- property list_of_band_indices: list
Indices that map between bands in the data and the unique bands we obtain. :rtype: list
- Type:
return
- load_and_truncate_data(truncate: bool = True, truncate_method: str = 'prompt_time_error', data_mode: str = 'flux') None
Read data of SGRB from given path and GRB telephone number. Truncate the data to get rid of all but the last prompt emission point make a cut based on the size of the temporal error; ie if t_error < 1s, the data point is part of the prompt emission
- Parameters:
truncate (bool) – Whether to truncate the data.
truncate_method (str) – Must be from Truncator.TRUNCATE_METHODS. (Default value = ‘prompt_time_error’)
data_mode (str, optional) – Data mode. Must be one from Afterglow.DATA_MODES. (Default value = ‘flux’)
- static load_data(name: str, data_mode: Optional[str] = None) tuple
Loads and returns data from a csv file
- Parameters:
name (str) – Telephone number of SGRB, e.g., ‘GRB140903A’ or ‘140903A’ are valid inputs
data_mode (str, optional) – Data mode. Must be one from Afterglow.DATA_MODES. (Default value = None)
- Returns:
A tuple with x, x_err, y, y_err data
- 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
- numerical_flux_to_luminosity(counts_to_flux_absorbed: float, counts_to_flux_unabsorbed: float) None
Converts flux to luminosity using the numerical method.
- Parameters:
counts_to_flux_absorbed (float) – Absorbed counts to flux ratio - a conversion of the count rate to flux.
counts_to_flux_unabsorbed (float:) – Unabsorbed counts to flux ratio - a conversion of the count rate to flux.
- plot_data(axes: Optional[Axes] = None, filename: Optional[str] = None, outdir: Optional[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 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.
- Returns:
The axes with the plot.
- plot_lightcurve(model: callable, filename: Optional[str] = None, outdir: Optional[str] = None, axes: Optional[Axes] = None, save: bool = True, show: bool = True, random_models: int = 100, posterior: Optional[DataFrame] = None, model_kwargs: Optional[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.
:param save:Whether to save the plot. :param show: Whether to show the plot. :param random_models: Number of random posterior samples plotted faintly. (Default value = 100) :param posterior: Posterior distribution to which to draw samples from. Is optional but must be given. :param outdir: Out directory in which to save the plot. Default is the current working directory. :param model_kwargs: Additional keyword arguments to be passed into the model. :param 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.
- Returns:
The axes.
- plot_multiband(figure: Optional[Figure] = None, axes: Optional[Axes] = None, filename: Optional[str] = None, outdir: Optional[str] = None, ncols: int = 2, save: bool = True, show: bool = True, nrows: Optional[int] = None, figsize: Optional[tuple] = None, filters: Optional[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 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.
- Returns:
The axes.
- plot_multiband_lightcurve(model: callable, filename: Optional[str] = None, outdir: Optional[str] = None, figure: Optional[Figure] = None, axes: Optional[Axes] = None, save: bool = True, show: bool = True, random_models: int = 100, posterior: Optional[DataFrame] = None, model_kwargs: Optional[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.
:param save:Whether to save the plot. :param show: Whether to show the plot. :param random_models: Number of random posterior samples plotted faintly. (Default value = 100) :param posterior: Posterior distribution to which to draw samples from. Is optional but must be given. :param outdir: Out directory in which to save the plot. Default is the current working directory. :param model_kwargs: Additional keyword arguments to be passed into the model. :param 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.
- Returns:
The axes.
- plot_residual(model: callable, filename: Optional[str] = None, outdir: Optional[str] = None, axes: Optional[Axes] = None, save: bool = True, show: bool = True, posterior: Optional[DataFrame] = None, model_kwargs: Optional[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.
:param save:Whether to save the plot. :param show: Whether to show the plot. :param posterior: Posterior distribution to which to draw samples from. Is optional but must be given. :param outdir: Out directory in which to save the plot. Default is the current working directory. :param model_kwargs: Additional keyword arguments to be passed into the model. :param 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.
- Returns:
The axes.
- set_bands_and_frequency(bands: Union[None, list, ndarray], frequency: Union[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.
- truncate(truncate_method: str = 'prompt_time_error') None
Truncate the data using the specified method. See redback.transient.afterglow.Truncator for documentation of the truncation methods.
- Parameters:
truncate_method (str) – Must be from Truncator.TRUNCATE_METHODS. (Default value = ‘prompt_time_error’)
- 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 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