Visualize spectrum outputs¶
API reference¶
-
doatools.plotting.plot_spectrum.plot_spectrum_1d(sp, grid, ax, estimates=None, ground_truth=None, use_log_scale=False, discrete=False)[source]¶ Plots a 1D spectrum or multiple 1D spectra.
Parameters: - sp –
Can be one of the following:
- An
ndarrayrepresenting the spectrum. Usually this is the output of a spectrum-based estimator. This function will draw a single spectrum. - A
listortupleofndarrayof the same shape. This function will draw multiple spectra in the same plot without labels. - A dictionary that maps labels to numpy arrays of the same shape. This function will draw multiple spectra in the same plot with labels.
- An
- grid (SearchGrid) – The search grid used to generate the spectrum/spectra. Its shape must match that of the spectrum/spectra.
- ax (Axes) – The matplotlib axes that will be used for plotting.
- estimates (SourcePlacement) – Estimated source
locations. Will be plotted if supplied. Default value is
None. - ground_truth (SourcePlacement) – True source
locations. Will be plotted if supplied. Default value is
None. - use_log_scale (bool) – Sets whether the spectrum should be plotted in
logarithmic scale. Default value is
False. - discrete (bool) – Sets whether the spectrum should be visualized using
stem plots instead of line plots. Default value is
False.
Returns: A list of plot containers with the following structure:
[sp1, sp2, ..., spN, est, truth], wheresp1,sp2, …,spNare the plot containers of the spectra,estis the plot container of the estimates, andtruthis the plot container of the ground truth.Return type: - sp –
-
doatools.plotting.plot_spectrum.plot_spectrum_2d(sp, grid, ax, estimates=None, ground_truth=None, use_log_scale=False, swap_axes=False, color_map='jet')[source]¶ Plots a 2D spectrum.
Parameters: - sp (ndarray) – A 2D ndarray representing the spectrum.
- grid (SearchGrid) – The search grid used to
generate the spectrum. Its shape must match the shape of
sp. - ax (Axes) – The matplotlib axes that will be used for plotting.
- estimates (SourcePlacement) – Estimated source
locations. Will be plotted if supplied. Default value is
None. - ground_truth (SourcePlacement) – True source
locations. Will be plotted if supplied. Default value is
None. - use_log_scale (bool) – Sets whether the spectrum should be plotted in
logarithmic scale. Default value is
False. - swap_axes (bool) – Set to
Trueto swap the x and y axis when plotting. Default value isFalse. - color_map – Specifies the color map. Default value is
'jet'.
Returns: A list of plot containers with the following structure:
[sp, est, truth], wheresp1is the plot containers of the spectrum,estis the plot container of the estimates, andtruthis the plot container of the ground truth.Return type:
-
doatools.plotting.plot_spectrum.plot_spectrum(sp, grid, ax=None, figsize=None, estimates=None, ground_truth=None, use_log_scale=False, **kwargs)[source]¶ Plots the given spectrum/spectra.
Provides a convenient way to plot the given spectrum/spectra. Automatically selects the plot function based on input grid’s number of dimensions.
Parameters: - sp – Compatible spectrum (or spectra collection) input.
- grid (SearchGrid) – The search grid used to
generate the spectrum/spectra. Its shape must match that of the
spectrum/spectra supplied in
sp. - ax (Axes) – The matplotlib axes used for plotting. If
not specified, a new figure will be created and shown. Default value
is
None. - figsize (tuple) – If
axisNone, specifies the new figure’s size. - estimates (SourcePlacement) – Estimated source
locations. Will be plotted if supplied. Default value is
None. - ground_truth (SourcePlacement) – True source
locations. Will be plotted if supplied. Default value is
None. - use_log_scale (bool) – Sets whether the spectrum should be plotted in
logarithmic scale. Default value is
False. - **kwargs – Other compatible options depending on the number of dimensions
of the input grid. See
plot_spectrum_1d()andplot_spectrum_2d()for more details.
Returns: A tuple consists of the following elements:
- ax (
Axes): The axes object containing the plot. - containers (
list): A list of plot containers. Seeplot_spectrum_1d()andplot_spectrum_2d()for more details.
Return type: