Visualisation#
Plotting helpers for GalCubeCraft results.
This module provides small, focused plotting utilities that operate on the
results list produced by generate_cubes().
Each public helper accepts the results container and an index selecting
which generated cube to visualise. The functions are intentionally lightweight
and return a Matplotlib (fig, ax) pair so callers (GUIs, scripts, tests)
can further customise or save figures.
Dependencies#
matplotlib (this module sets the
TkAggbackend by default)astrodendro (used to compute a crude mask for visual guides)
Notes
- These helpers call
_prepare_cube()to extract cube / metadata and to compute a simple dendrogram-based mask used for moment maps. The dendrogram parameters are deliberately conservative and may be tuned for different signal-to-noise regimes.
- These helpers call
- The plotting functions attempt to save to
figures/<shape>/when save=Trueis passed; save failures are intentionally ignored to keep UI flows robust.
- The plotting functions attempt to save to
- GalCubeCraft.visualise.moment0(data, idx, save=False, fname_save=None, inline=False)[source]#
Plot the zeroth moment (integrated intensity) of a spectral cube.
- Parameters:
data (sequence) – The
resultscontainer produced byGalCubeCraft.generate_cubes.idx (int) – Index selecting which cube to plot.
save (bool, optional) – If True, attempt to save the figure to
figures/<shape>/moment0.pdf.fname_save (str or None, optional) – Optional directory to save the figure. If None a path under the current working directory is chosen automatically.
- Returns:
fig, ax – Matplotlib figure and axes objects containing the rendered moment map.
- Return type:
(Figure, Axes)
- GalCubeCraft.visualise.moment1(data, idx, save=False, fname_save=None)[source]#
Plot the first moment (intensity-weighted velocity) of a spectral cube.
- Parameters:
data (sequence) – The
resultscontainer produced byGalCubeCraft.generate_cubes.idx (int) – Index selecting which cube to plot.
save (bool, optional) – If True, attempt to save the figure to
figures/<shape>/moment1.pdf.fname_save (str or None, optional) – Optional directory to save the figure. If None a path under the current working directory is chosen automatically.
- Returns:
fig, ax – Matplotlib figure and axes objects containing the rendered moment map.
- Return type:
(Figure, Axes)
- GalCubeCraft.visualise.slice_view(data, idx=0, channel=None, cmap='viridis', parent=None)[source]#
Show a per-channel slice viewer embedded in a Tk window.
This viewer embeds the Matplotlib figure into a Tk Toplevel and uses a ttk-styled slider to step through spectral channels. The viewer keeps the lower colour limit fixed at 0 and computes an upper limit per slice so contrast adapts to the currently displayed channel.
- Parameters:
data (sequence) – The
resultscontainer produced byGalCubeCraft.generate_cubes.idx (int, optional) – Index of the cube within
datato display (default 0).channel (int, optional) – Initial spectral channel index to show. If
None(the default) the viewer will open on the central spectral channel (int(n/2)).cmap (str, optional) – Matplotlib colormap to use for imshow.
parent (tkinter widget, optional) – If provided, the slice viewer will be a child Toplevel of this widget. Otherwise a new Toplevel (or root) is used.
- Returns:
fig, ax – The Matplotlib figure and axes used by the embedded viewer.
- Return type:
(Figure, Axes)
- GalCubeCraft.visualise.spectrum(data, idx, save=False, fname_save=None)[source]#
Plot the integrated spectrum (total flux vs velocity) for a cube.
- Parameters:
data (sequence) – The
resultscontainer produced byGalCubeCraft.generate_cubes.idx (int) – Index selecting which cube to plot.
save (bool, optional) – If True, save the figure as
spectrum.pdfunderfigures/<shape>/unlessfname_saveoverrides the path.fname_save (str or None, optional) – Optional directory to save the figure.
- Returns:
fig, ax – The Matplotlib figure and axes containing the spectrum.
- Return type:
(Figure, Axes)