threeML.io.plotting package
Submodules
threeML.io.plotting.cmap_cycle module
- threeML.io.plotting.cmap_cycle.cmap_intervals(length=50, cmap='YlOrBr', start=None, stop=None)[source]
Return evenly spaced intervals of a given colormap cmap.
Colormaps listed in REVERSE_CMAP will be cycled in reverse order. Certain colormaps have pre-specified color ranges in CMAP_RANGE. These module variables ensure that colors cycle from light to dark and light colors are not too close to white.
- Parameters:
length – int the number of colors used before cycling back to first color. When
length is large (> ~10), it is difficult to distinguish between successive lines because successive colors are very similar. :param cmap: str name of a matplotlib colormap (see matplotlib.pyplot.cm)
threeML.io.plotting.data_residual_plot module
- class threeML.io.plotting.data_residual_plot.ResidualPlot(**kwargs)[source]
Bases:
object
- add_data(x, y, residuals, label, xerr=None, yerr=None, residual_yerr=None, show_data=True, **kwargs)[source]
Add the data for the this model
- Parameters:
x – energy of the data
y – value of the data
residuals – the residuals for the data
label – label of the data
xerr – the error in energy (or bin width)
yerr – the errorbars of the data
**kwargs –
any kwargs passed to plot
- Returns:
- add_model(x, y, label, **kwargs)[source]
Add a model and interpolate it across the energy span for the plotting.
- Parameters:
x – the evaluation energies
y – the model values
label – the label of the model
**kwargs –
any kwargs passed to plot
- Returns:
None
- add_model_step(xmin, xmax, xwidth, y, label, **kwargs)[source]
Add a model but use discontinuous steps for the plotting.
- Parameters:
xmin – the low end boundaries
xmax – the high end boundaries
xwidth – the width of the bins
y – the height of the bins
label – the label of the model
**kwargs –
any kwargs passed to plot
- Returns:
None
- property axes
- property data_axis: Axes
the top or data axis
- Type:
return
- property figure: Figure
the figure instance
- Type:
return
- finalize(xlabel='x', ylabel='y', xscale='log', yscale='log', show_legend=True, invert_y=False)[source]
- Parameters:
xlabel
ylabel
xscale
yscale
show_legend
- Returns:
- property ratio_residuals
- property residual_axis: Axes
the bottom or residual axis
- Type:
return
- property show_residuals: bool
threeML.io.plotting.get_style module
threeML.io.plotting.light_curve_plots module
- threeML.io.plotting.light_curve_plots.binned_light_curve_plot(time_bins, cnts, width, bkg=None, selection=None, bkg_selections=None)[source]
- Parameters:
time_bins – stacked array of time intervals
cnts – counts per bin
bkg – background of the light curve
width – with of the bins
selection – bin selection
bkg_selections
instrument
- Returns:
- threeML.io.plotting.light_curve_plots.channel_plot(ax, chan_min, chan_max, counts, **kwargs)[source]
- threeML.io.plotting.light_curve_plots.disjoint_patch_plot(ax: Axes, bin_min: array, bin_max: array, top: float, bottom: float, mask: array, **kwargs: dict) None [source]
plots patches that are disjoint given by the mask
- Parameters:
ax – matplotlib Axes to plot to
bin_min – bin starts
bin_max – bin stops
top – top y value to plot
bottom – bottom y value to plot
mask – mask of the bins
kwargs – matplotlib plot keywords
- Returns:
- threeML.io.plotting.light_curve_plots.plot_tte_lightcurve(tte_file: str, start: float = -10, stop: float = 50, dt: float = 1) Figure [source]
quick plot of a TTE light curve :param tte_file: GBM TTE file name :param start: start of the light curve :param stop: stop of the light curve :param dt: with of the bins
threeML.io.plotting.model_plot module
- class threeML.io.plotting.model_plot.SpectralContourPlot(n_total, xscale='log', yscale='log', show_legend=True, plot_kwargs=None, contour_kwargs=None, legend_kwargs=None, emin=None, emax=None, subplot=None)[source]
Bases:
object
- add_dimensionless_model(energy_range, best_fit, color, upper_error=None, lower_error=None, contour_color=None, label='model')[source]
- threeML.io.plotting.model_plot.plot_spectra(*analysis_results, **kwargs) Figure [source]
plotting routine for fitted point source spectra
- Parameters:
analysis_results – fitted JointLikelihood or BayesianAnalysis objects
sources_to_use – (optional) list of PointSource string names to plot from the analysis
energy_unit – (optional) astropy energy unit in string form (can also be frequency)
flux_unit – (optional) astropy flux unit in string form
confidence_level – (optional) confidence level to use (default: 0.68)
ene_min – (optional) minimum energy to plot
ene_max – (optional) maximum energy to plot
num_ene – (optional) number of energies to plot
use_components – (optional) True or False to plot the spectral components
components_to_use – (optional) list of string names of the components to plot: including ‘total’
will also plot the total spectrum :param sum_sources: (optional) some all the MLE and Bayesian sources :param show_contours: (optional) True or False to plot the contour region :param plot_style_kwargs: (optional) dictionary of MPL plot styling for the best fit curve :param contour_style_kwargs: (optional) dictionary of MPL plot styling for the contour regions :param fit_cmap: MPL color map to iterate over for plotting multiple analyses :param contour_cmap: MPL color map to iterate over for plotting contours for multiple analyses :param subplot: subplot to use :param xscale: ‘log’ or ‘linear’ :param yscale: ‘log’ or ‘linear’ :param include_extended: True or False, also plot extended source spectra. :return:
threeML.io.plotting.model_plot_2D module
threeML.io.plotting.post_process_data_plots module
- threeML.io.plotting.post_process_data_plots.display_photometry_model_magnitudes(analysis, data=(), **kwargs)[source]
Display the fitted model count spectrum of one or more Spectrum plugins
NOTE: all parameters passed as keyword arguments that are not in the list below, will be passed as keyword arguments to the plt.subplots() constructor. So for example, you can specify the size of the figure using figsize = (20,10)
- Parameters:
args – one or more instances of Spectrum plugin
min_rate – (optional) rebin to keep this minimum rate in each channel (if possible). If one number is
provided, the same minimum rate is used for each dataset, otherwise a list can be provided with the minimum rate for each dataset :param data_cmap: (str) (optional) the color map used to extract automatically the colors for the data :param model_cmap: (str) (optional) the color map used to extract automatically the colors for the models :param data_colors: (optional) a tuple or list with the color for each dataset :param model_colors: (optional) a tuple or list with the color for each folded model :param show_legend: (optional) if True (default), shows a legend :param step: (optional) if True (default), show the folded model as steps, if False, the folded model is plotted with linear interpolation between each bin :return: figure instance
- threeML.io.plotting.post_process_data_plots.display_spectrum_model_counts(analysis, data=(), **kwargs)[source]
Display the fitted model count spectrum of one or more Spectrum plugins
NOTE: all parameters passed as keyword arguments that are not in the list below, will be passed as keyword arguments to the plt.subplots() constructor. So for example, you can specify the size of the figure using figsize = (20,10)
- Parameters:
args – one or more instances of Spectrum plugin
min_rate – (optional) rebin to keep this minimum rate in each channel (if possible). If one number is
provided, the same minimum rate is used for each dataset, otherwise a list can be provided with the minimum rate for each dataset :param data_cmap: (str) (optional) the color map used to extract automatically the colors for the data :param model_cmap: (str) (optional) the color map used to extract automatically the colors for the models :param data_colors: (optional) a tuple or list with the color for each dataset :param model_colors: (optional) a tuple or list with the color for each folded model :param data_color: (optional) color for all datasets :param model_color: (optional) color for all folded models :param show_legend: (optional) if True (default), shows a legend :param step: (optional) if True (default), show the folded model as steps, if False, the folded model is plotted :param model_subplot: (optional) axe(s) to plot to for overplotting with linear interpolation between each bin :param data_per_plot: (optional) Can specify how many detectors should be plotted in one plot. If there are more detectors than this number it will split it up in several plots :param show_background: (optional) Also show the background :param source_only: (optional) Plot only source (total data - background) :param background_cmap: (str) (optional) the color map used to extract automatically the colors for the background :param background_colors: (optional) a tuple or list with the color for each background :param background_color: (optional) color for all backgrounds :return: figure instance