MapLines.tools.plot_tools

Plotting utilities for visualizing spectral fits and model components.

MapLines.tools.plot_tools

Visualization and diagnostic plotting utilities for MapLines.

This module contains the plotting routines used to inspect and present the outputs of the MapLines spectral fitting workflow. The functions implemented here are designed to work with both one-dimensional spectra and two-dimensional parameter maps extracted from integral-field or imaging spectroscopy products.

The module provides tools for:

  • plotting grids of spatial maps derived from fitted data products

  • overlaying apertures, circular regions, and pseudo-slit extractions

  • visualizing spectra extracted along user-defined paths or apertures

  • displaying velocity-structure diagnostics and simple kinematic models

  • building and visualizing BPT, WHAN, and WHAD classification maps

  • generating diagnostic plots for spectral fits and posterior samples

These routines rely heavily on FITS headers and WCS information to place apertures and paths consistently on sky-projected maps. They also use supporting routines from MapLines.tools.tools for extracting regions, spectra, and parameter maps, and can use posterior samples from the MCMC module for fit visualization.

Notes

The plotting functions in this module are primarily intended for interactive analysis, diagnostic inspection, and the production of publication-quality figures. In most cases they save figures directly to PDF files.

See also

MapLines.tools.tools

Data extraction utilities used by many plotting routines.

MapLines.tools.line_fit

Spectral fitting driver that generates many of the products shown by these plotting functions.

MapLines.tools.mcmc

Posterior-sampling utilities used for visualizing uncertainties.

MapLines.tools.plot_tools.plot_maps_grid(datalist, hdr, fig_path='', tit='', lab='[10^{-16}erg/s/cm^2/arcsec^2]', labelst=['Vaule1', 'Value2', 'Value3'], alpha=0.6, fontsizest=20, colorst='black', fontsize=20, basefigname='maps_NAME', sumc=False, scale=0, sb=False, fwcs=False, logs=False, zerofil=False, valz=None, cont=False, maxmin=[], vt='', name='Name', indx=0, indx2=None, cmt=None, scalef=1.0, facs=1, av=[0.15, 0.2, 0.12, 0.03], pro1=[0, 0, 0], pro2=[0, 1, 2], orientation=None, location=None, ticks=None, labels=None)[source]

Plot a grid of 2D maps or slices extracted from 3D cubes.

This routine arranges multiple maps in a custom multi-panel layout and draws a shared color scale. It supports direct plotting of 2D arrays or extraction of 2D slices from 3D cubes, optional surface-brightness normalization, logarithmic scaling, WCS-aware axes, and panel labels.

Parameters:
  • datalist (list of ndarray) – List of maps or cubes to display. If an element is 3D, the function uses indx to select a slice or, if sumc=True, integrates along the spectral axis.

  • hdr (astropy.io.fits.Header) – FITS header used to derive the pixel scale and, optionally, the WCS.

  • fig_path (str, optional) – Output directory for the generated PDF.

  • tit (str, optional) – Quantity name used in the color-bar label.

  • lab (str, optional) – Physical units displayed in the color-bar label.

  • labelst (list of str, optional) – Text labels placed on each panel.

  • alpha (float, optional) – Transparency used by the map display.

  • fontsizest (int, optional) – Font size for panel labels.

  • colorst (str, optional) – Color used for panel labels.

  • fontsize (int, optional) – Font size for the color-bar label.

  • basefigname (str, optional) – Output base file name. The token NAME is replaced by name.

  • sumc (bool, optional) – If True and the inputs are 3D cubes, sum along the spectral axis.

  • scale (float, optional) – Display scale passed to the internal map-plotting helper.

  • sb (bool, optional) – If True, divide the maps by pixel area to display surface brightness.

  • fwcs (bool, optional) – If True, draw axes in WCS coordinates.

  • logs (bool, optional) – If True, plot the logarithm of the maps.

  • zerofil (bool, optional) – If True, replace zero-valued or low-valued pixels with NaN.

  • valz (float, optional) – Threshold used when zerofil=True.

  • cont (bool, optional) – Forwarded to the internal plotting helper for contour handling.

  • maxmin (list, optional) – Two-element list with explicit [vmin, vmax] values.

  • vt (str, optional) – Reserved text parameter.

  • name (str, optional) – Object identifier used in the output file name.

  • indx (int, optional) – Index of the plane to extract from 3D cubes.

  • indx2 (int, optional) – Secondary index used to divide one slice by another.

  • cmt (matplotlib colormap, optional) – Colormap used for the images.

  • scalef (float, optional) – Global multiplicative scaling factor.

  • facs (float, optional) – Global figure-size scaling factor.

  • av (list of float, optional) – Margins used to construct the custom panel layout.

  • pro1 (list of int, optional) – Panel positions in the custom grid.

  • pro2 (list of int, optional) – Panel positions in the custom grid.

  • orientation ({'vertical', 'horizontal'}, optional) – Color-bar orientation.

  • location (str, optional) – Color-bar location.

  • ticks (list, optional) – Explicit color-bar tick positions.

  • labels (list, optional) – Explicit color-bar tick labels.

Return type:

None

Notes

This function writes the figure directly to a PDF file and then displays it. The internal map rendering is delegated to get_plot_map.

MapLines.tools.plot_tools.plot_mapapertures(titf, vals_map, nlins=['$[NII]$', '$H_{\\alpha}$', '$[NII]$'], titp='Velocity~ shift', lab='[km\\ s^{-1}]', cont=False, alpha=0.5, lamds=[6549.859, 6564.632, 6585.278], path='', nzeros=False, hdu=0, wcs=None, file0='J102700+174900_Gas.fits.gz', reg_dir='', reg_aper='apertu.reg', dtex=0, dtey=0, rad=1.5, cosmetic=False, reg_name='paths_J1027_C.reg', zt=0, facs=1, lA1=6520.0, lA2=6610.0, dxR=0.25, savef=True, pro1=[0, 1, 2], nx=2, ny=4, pro2=[0, 0, 0], av=[0.1, 0.03, 0.09, 0.03], sigT=2, loc=3, facx=0.8, facy=-1, tpt=1, obt=['C', 'D', 'E', 'G', 'J', 'L'], y_min=0, y_max=1, x_min=0, x_max=1, txt_size=18, ylabel='y-value', xlabel='x-value', dxl=0.2, dyl=0.9, color=['blue', 'green', 'red'], lin=['-', '--', ':'], dir='./')[source]

Plot a parameter map together with circular apertures and extracted spectra.

This routine combines a 2D map with aperture or path overlays and a set of spectra extracted along user-defined segment nodes. It is useful for visually connecting spatial locations in a map with the corresponding extracted one-dimensional spectra.

Parameters:
  • titf (str) – Output figure name.

  • vals_map (tuple) – Tuple of the form (map, vmax, vmin) for the main image panel.

  • nlins (list of str, optional) – Labels used for the vertical line markers in the extracted spectra.

  • titp (str, optional) – Title of the map quantity.

  • lab (str, optional) – Units of the map quantity.

  • cont (bool, optional) – Forwarded to the internal plotting helper.

  • alpha (float, optional) – Transparency of the map.

  • lamds (list of float, optional) – Reference wavelengths used to draw vertical markers in the spectra.

  • path (str, optional) – Directory of the input cube.

  • nzeros (bool, optional) – If True, negative values may be converted to NaN during extraction.

  • hdu (int, optional) – FITS HDU index used for extraction.

  • wcs (astropy.wcs.WCS, optional) – WCS object. If not provided, it is built from the cube header.

  • file0 (str, optional) – Input cube file used for the extraction.

  • reg_dir (str, optional) – Directory containing DS9 region files.

  • reg_aper (str, optional) – Region file used for plotting apertures.

  • dtex (float, optional) – Text offsets for aperture labels.

  • dtey (float, optional) – Text offsets for aperture labels.

  • rad (float, optional) – Radius of the plotted extraction circles in arcseconds.

  • cosmetic (bool, optional) – If True, smooth the extracted spectra for display.

  • reg_name (str, optional) – DS9 segment file used to define the extracted path.

  • zt (float, optional) – Redshift used to shift spectra to the rest frame.

  • facs (float, optional) – Global figure-size scaling factor.

  • lA1 (float, optional) – Rest-frame wavelength interval shown in the extracted spectra.

  • lA2 (float, optional) – Rest-frame wavelength interval shown in the extracted spectra.

  • dxR (float, optional) – Horizontal offset used in the figure layout.

  • savef (bool, optional) – If True, save the figure as a PDF.

  • dir (str, optional) – Output directory.

Return type:

None

Notes

This routine depends on tools.extract_segment1d and on the helper function plot_circle to annotate extraction nodes on the map.

MapLines.tools.plot_tools.plot_velana2x(titf, vals_map1, vals_map2, dyt=0.95, pltlabel='$Velocity\\ shift\\ [km\\ s^{-1}]$', unitplots=['[km\\ s^{-1}]', '[km\\ s^{-1}]'], labplots=['Velocity shift Blue', 'Velocity shift Red'], path='', DA=None, model='helic', alpha=1.0, fitmod=False, file0='J102700+174900_Gas.fits.gz', file1='J102700+174900_Gas.fits.gz', nlinsA=['$[NII]$', '$H_{\\alpha}$', '$[NII]$'], lamdsA=[6549.859, 6564.632, 6585.278], nlinsB=['$[NII]$', '$H_{\\alpha}$', '$[NII]$'], lamdsB=[6549.859, 6564.632, 6585.278], hdu=0, reg_dir='', reg_aper='apertu.reg', reg_name='paths_J1027_C.reg', zt=0, facs=1, lA1=6520.0, lA2=6610, lB1=6520.0, lB2=6610.0, dxR=0.25, savef=True, pro1=[0, 1, 2], nx=2, ny=4, pro2=[0, 0, 0], av=[0.1, 0.03, 0.09, 0.03], sigT=2, loc=3, facx=0.8, facy=-1, tpt=1, obt=['C', 'D', 'E', 'G', 'J', 'L'], y_min=0, y_max=1, x_min=0, x_max=1, txt_size=18, ylabel='y-value', xlabel='x-value', dxl=0.2, dyl=0.9, color=['blue', 'green', 'red'], lin=['-', '--', ':'], dir='./')[source]

Compare two velocity maps and their extracted pseudo-slit spectra.

This function builds a composite figure with two velocity maps, extraction paths, the corresponding pseudo-slit spectra, and radial velocity profiles extracted along the same DS9-defined paths.

Parameters:
  • titf (str) – Output figure name.

  • vals_map1 (tuple) – Tuples of the form (map, vmax, vmin) for the two maps.

  • vals_map2 (tuple) – Tuples of the form (map, vmax, vmin) for the two maps.

  • dyt (float, optional) – Vertical scaling factor used in the figure layout.

  • pltlabel (str, optional) – Y-axis label for the extracted velocity curves.

  • unitplots (list of str, optional) – Units of the two displayed maps.

  • labplots (list of str, optional) – Titles of the two map panels.

  • path (str, optional) – Directory containing the cube files.

  • DA (float, optional) – Angular-diameter-distance scaling to convert arcseconds into kpc.

  • model ({'helic', 'sin', 'vmax'}, optional) – Functional form used when fitmod=True.

  • alpha (float, optional) – Transparency of the maps.

  • fitmod (bool, optional) – If True, fit a simple kinematic model to the extracted velocity curve.

  • file0 (str, optional) – Input cubes used for the blue and red spectral ranges.

  • file1 (str, optional) – Input cubes used for the blue and red spectral ranges.

  • reg_dir (str, optional) – DS9 region files used for paths and apertures.

  • reg_aper (str, optional) – DS9 region files used for paths and apertures.

  • reg_name (str, optional) – DS9 region files used for paths and apertures.

  • zt (float, optional) – Redshift used to shift the spectral axis to the rest frame.

  • lA1 (float, optional) – Wavelength windows used for the two pseudo-slit extractions.

  • lA2 (float, optional) – Wavelength windows used for the two pseudo-slit extractions.

  • lB1 (float, optional) – Wavelength windows used for the two pseudo-slit extractions.

  • lB2 (float, optional) – Wavelength windows used for the two pseudo-slit extractions.

  • savef (bool, optional) – If True, save the figure as a PDF.

  • dir (str, optional) – Output directory.

Return type:

None

Notes

The routine uses tools.extract_segment and tools.extract_segment_val to obtain spatially resolved spectra and velocity profiles.

MapLines.tools.plot_tools.plot_velana(titf, vals_map, path='', DA=None, model='helic', alpha=1.0, fitmod=False, file0='J102700+174900_Gas.fits.gz', nlins=['$[NII]$', '$H_{\\alpha}$', '$[NII]$'], lamds=[6549.859, 6564.632, 6585.278], hdu=0, reg_dir='', reg_aper='apertu.reg', reg_name='paths_J1027_C.reg', zt=0, facs=1, lA1=6520.0, lA2=6610.0, dxR=0.25, savef=True, pro1=[0, 1, 2], nx=2, ny=4, pro2=[0, 0, 0], av=[0.1, 0.03, 0.09, 0.03], sigT=2, loc=3, facx=0.8, facy=-1, tpt=1, obt=['C', 'D', 'E', 'G', 'J', 'L'], y_min=0, y_max=1, x_min=0, x_max=1, txt_size=18, ylabel='y-value', xlabel='x-value', dxl=0.2, dyl=0.9, color=['blue', 'green', 'red'], lin=['-', '--', ':'], dir='./')[source]

Plot a velocity map together with pseudo-slit spectra and radial profiles.

This function generates a multi-panel diagnostic figure showing a single velocity map, the extraction path, a set of pseudo-slit spectra along the path, and the corresponding extracted velocity profiles.

Parameters:
  • titf (str) – Output figure name.

  • vals_map (tuple) – Tuple (map, vmax, vmin) for the velocity map.

  • path (str, optional) – Directory containing the input cube.

  • DA (float, optional) – Conversion factor from arcseconds to kpc.

  • model ({'helic', 'sin', 'vmax'}, optional) – Functional form used when fitmod=True.

  • alpha (float, optional) – Transparency of the displayed map.

  • fitmod (bool, optional) – If True, fit a simple analytic model to the extracted velocity profile.

  • file0 (str, optional) – Input cube file.

  • reg_dir (str, optional) – DS9 region files used for extraction paths and aperture overlays.

  • reg_aper (str, optional) – DS9 region files used for extraction paths and aperture overlays.

  • reg_name (str, optional) – DS9 region files used for extraction paths and aperture overlays.

  • zt (float, optional) – Redshift applied to the wavelength axis.

  • lA1 (float, optional) – Wavelength window used to build the pseudo-slit spectra.

  • lA2 (float, optional) – Wavelength window used to build the pseudo-slit spectra.

  • savef (bool, optional) – If True, save the result to PDF.

  • dir (str, optional) – Output directory.

Return type:

None

MapLines.tools.plot_tools.helic_func(r, alpha, beta, gama, theta)[source]

Evaluate a helical-like velocity profile.

Parameters:
  • r (array-like) – Radial coordinate.

  • alpha (float) – Overall amplitude parameter.

  • beta (float) – Oscillation or winding coefficient.

  • gama (float) – Phase term.

  • theta (float) – Systemic offset.

Returns:

Model velocity profile.

Return type:

ndarray

MapLines.tools.plot_tools.sin_func(r, alpha, beta, gama, theta)[source]

Evaluate a sinusoidal velocity profile.

Parameters:
  • r (array-like) – Radial coordinate.

  • alpha (float) – Oscillation amplitude.

  • beta (float) – Radial scale parameter.

  • gama (float) – Phase offset.

  • theta (float) – Additive velocity offset.

Returns:

Model velocity profile.

Return type:

ndarray

MapLines.tools.plot_tools.plot_bpt_map(file, name='', alpha=1, orientation=None, hd=0, ewsing=1, max_typ=5, location=None, savef=False, fig_path='', fwcs=False, scale=0, facp=0.8, tit='BPT', cont=False, path='', indEwHa=769, indOIII=76, indNII=123, indHa=124, indHb=63, ret=1, agn=5, sf=3, inte=2, comp=4)[source]

Build and plot a BPT classification map from a fitted parameter cube.

This routine reads line-flux and equivalent-width maps from a FITS cube, computes the standard BPT diagnostic ratios, classifies each pixel, and displays the resulting classification map using a discrete colormap.

Parameters:
  • file (str) – Input FITS file containing the parameter cube.

  • name (str, optional) – Object identifier used in the output file name.

  • alpha (float, optional) – Map transparency.

  • orientation (str, optional) – Color-bar orientation.

  • hd (int, optional) – FITS HDU index.

  • ewsing (float, optional) – Multiplicative scaling applied to the Halpha equivalent width.

  • max_typ (int, optional) – Maximum class label shown by the colormap.

  • location (str, optional) – Color-bar location.

  • savef (bool, optional) – If True, save the figure as a PDF.

  • fig_path (str, optional) – Output directory.

  • fwcs (bool, optional) – If True, plot in WCS coordinates.

  • scale (float, optional) – Display scale passed to the internal plotting helper.

  • tit (str, optional) – Plot title.

  • cont (bool, optional) – Forwarded to the internal plotting helper.

  • path (str, optional) – Directory containing the FITS file.

  • indEwHa (int, optional) – Indices of the required parameter maps in the FITS cube.

  • indOIII (int, optional) – Indices of the required parameter maps in the FITS cube.

  • indNII (int, optional) – Indices of the required parameter maps in the FITS cube.

  • indHa (int, optional) – Indices of the required parameter maps in the FITS cube.

  • indHb (int, optional) – Indices of the required parameter maps in the FITS cube.

  • ret (int, optional) – Numeric class labels used by the BPT map.

  • agn (int, optional) – Numeric class labels used by the BPT map.

  • sf (int, optional) – Numeric class labels used by the BPT map.

  • inte (int, optional) – Numeric class labels used by the BPT map.

  • comp (int, optional) – Numeric class labels used by the BPT map.

Return type:

None

Notes

The classification itself is performed by tools.bpt.

MapLines.tools.plot_tools.plot_bpt_map2(fileR, fileB, name='', zt=0, alpha=1, tight=True, maskB=None, fontsize=18, maskR=None, orientation=None, hd=0, ewsing=1, max_typ=5, location=None, savef=False, fig_path='', fwcs=False, scale=0, facp=0.8, tit='BPT', cont=False, path='', indcB=769, indcR=769, indOIII=76, indNII=123, indHa=124, indHb=63, ret=1, agn=5, sf=3, inte=2, comp=4)[source]

Build and plot a BPT classification map from separate red and blue products.

This version of the BPT plotter reads the required emission-line maps from two different fitted files, typically corresponding to different spectral windows, combines them into the classical BPT ratios, and plots the resulting classification map.

Parameters:
  • fileR (str) – Input fitted files for the red and blue spectral ranges.

  • fileB (str) – Input fitted files for the red and blue spectral ranges.

  • name (str, optional) – Object identifier used in the output file name.

  • zt (float, optional) – Redshift correction applied when deriving line maps.

  • alpha (float, optional) – Map transparency.

  • tight (bool, optional) – If True, call plt.tight_layout() when saving.

  • maskB (ndarray, optional) – Boolean masks applied to the blue and red products.

  • maskR (ndarray, optional) – Boolean masks applied to the blue and red products.

  • fontsize (int, optional) – Color-bar font size.

  • orientation (str, optional) – Color-bar orientation.

  • savef (bool, optional) – If True, save the figure.

  • fig_path (str, optional) – Output directory.

  • fwcs (bool, optional) – If True, plot in WCS coordinates.

  • indcB (int, optional) – Map indices used to recover the required line and continuum products.

  • indcR (int, optional) – Map indices used to recover the required line and continuum products.

  • indOIII (int, optional) – Map indices used to recover the required line and continuum products.

  • indNII (int, optional) – Map indices used to recover the required line and continuum products.

  • indHa (int, optional) – Map indices used to recover the required line and continuum products.

  • indHb (int, optional) – Map indices used to recover the required line and continuum products.

  • ret (int, optional) – Numeric class labels.

  • agn (int, optional) – Numeric class labels.

  • sf (int, optional) – Numeric class labels.

  • inte (int, optional) – Numeric class labels.

  • comp (int, optional) – Numeric class labels.

Return type:

None

MapLines.tools.plot_tools.plot_whan_map2(fileR, name='', zt=0, alpha=1, tight=True, fontsize=18, maskR=None, orientation=None, hd=0, ewsing=1, max_typ=5, location=None, savef=False, fig_path='', fwcs=False, scale=0, facp=0.8, tit='WHaN', cont=False, path='', indcR=769, indNII=123, indHa=124, ret=1, agn=5, sf=3, wagn=4)[source]

Build and plot a WHAN classification map from fitted red-side products.

This routine derives Halpha equivalent width and [NII]/Halpha ratio maps from a fitted product and displays the resulting WHAN classes.

Parameters:
  • fileR (str) – Input fitted file for the red spectral range.

  • name (str, optional) – Object identifier used in the output file name.

  • zt (float, optional) – Redshift correction used when deriving line maps.

  • alpha (float, optional) – Map transparency.

  • tight (bool, optional) – If True, call plt.tight_layout() when saving.

  • fontsize (int, optional) – Color-bar font size.

  • maskR (ndarray, optional) – Boolean mask applied to the red product.

  • orientation (str, optional) – Color-bar orientation.

  • savef (bool, optional) – If True, save the figure as a PDF.

  • fig_path (str, optional) – Output directory.

  • fwcs (bool, optional) – If True, plot in WCS coordinates.

  • path (str, optional) – Directory containing the input file.

  • indcR (int, optional) – Indices used to recover the continuum and line products.

  • indNII (int, optional) – Indices used to recover the continuum and line products.

  • indHa (int, optional) – Indices used to recover the continuum and line products.

  • ret (int, optional) – Numeric class labels used by the WHAN map.

  • agn (int, optional) – Numeric class labels used by the WHAN map.

  • sf (int, optional) – Numeric class labels used by the WHAN map.

  • wagn (int, optional) – Numeric class labels used by the WHAN map.

Return type:

None

MapLines.tools.plot_tools.plot_whad_map2(fileR, name='', zt=0, alpha=1, tight=True, fontsize=18, maskR=None, orientation=None, hd=0, ewsing=1, max_typ=5, location=None, savef=False, fig_path='', fwcs=False, scale=0, facp=0.8, tit='WHaD', cont=False, path='', indcR=769, indHa=124, ret=1, agn=5, sf=3, wagn=4, unk=2)[source]

Build and plot a WHAD classification map.

This routine derives Halpha equivalent width and velocity-dispersion maps from a fitted red-side product, converts them to logarithmic space, classifies each spaxel using the WHAD diagnostic, and plots the result.

Parameters:
  • fileR (str) – Input fitted red-side file.

  • name (str, optional) – Object identifier used in the output file name.

  • zt (float, optional) – Redshift correction used when deriving line maps.

  • alpha (float, optional) – Map transparency.

  • tight (bool, optional) – If True, call plt.tight_layout() when saving.

  • fontsize (int, optional) – Color-bar font size.

  • maskR (ndarray, optional) – Boolean mask applied to the red product.

  • orientation (str, optional) – Color-bar orientation.

  • savef (bool, optional) – If True, save the result as a PDF.

  • fig_path (str, optional) – Output directory.

  • fwcs (bool, optional) – If True, plot in WCS coordinates.

  • path (str, optional) – Directory containing the input file.

  • indcR (int, optional) – Indices of the continuum and Halpha products.

  • indHa (int, optional) – Indices of the continuum and Halpha products.

  • ret (int, optional) – Numeric class labels used by the WHAD map.

  • agn (int, optional) – Numeric class labels used by the WHAD map.

  • sf (int, optional) – Numeric class labels used by the WHAD map.

  • wagn (int, optional) – Numeric class labels used by the WHAD map.

  • unk (int, optional) – Numeric class labels used by the WHAD map.

Return type:

None

MapLines.tools.plot_tools.plot_single_map(file, valmax, valmin, name='', scale=0, sb=False, fwcs=False, logs=False, zerofil=False, valz=None, scalef=1.0, basefigname='Ha_vel_map_NAME', sumc=False, path='', hd=0, indx=0, indx2=None, tit='', lab='', facp=0.8, facx=6.5, facy=7.6, cont=False, alpha=1, orientation=None, location=None, savef=False, fig_path='')[source]

Plot a single map or cube slice from a FITS product.

This routine reads a FITS file, extracts a 2D map or a slice from a 3D cube, optionally applies normalization or logarithmic scaling, and plots the result using the internal map-display helper.

Parameters:
  • file (str) – Input FITS file.

  • valmax (float) – Maximum and minimum values used for the display scale.

  • valmin (float) – Maximum and minimum values used for the display scale.

  • name (str, optional) – Object identifier used in the output file name.

  • scale (float, optional) – Display scale passed to the internal plotting helper.

  • sb (bool, optional) – If True, divide by pixel area to obtain surface brightness.

  • fwcs (bool, optional) – If True, plot the image in WCS coordinates.

  • logs (bool, optional) – If True, display the logarithm of the map.

  • zerofil (bool, optional) – If True, replace zero or low-valued pixels with NaN.

  • valz (float, optional) – Threshold used when zerofil=True.

  • scalef (float, optional) – Multiplicative scaling applied to the data.

  • basefigname (str, optional) – Output base file name. NAME is replaced by name.

  • sumc (bool, optional) – If True and the input is a cube, integrate along the spectral axis.

  • path (str, optional) – Directory containing the FITS file.

  • hd (int, optional) – FITS HDU index.

  • indx (int, optional) – Index of the plane extracted from a 3D cube.

  • indx2 (int, optional) – Secondary index used to form a ratio map.

  • tit (str, optional) – Display title.

  • lab (str, optional) – Physical units shown on the color bar.

  • savef (bool, optional) – If True, save the figure as a PDF.

  • fig_path (str, optional) – Output directory.

Return type:

None

MapLines.tools.plot_tools.get_plot_map(plt, flux, vmax, vmin, pix=0.2, scale=0, ticks=None, fontsize=18, labels=None, cmt=None, norm=None, cbarp=True, fwcs=False, objsys='J2000', tit='flux', lab='[10^{-16}erg/s/cm^2/arcsec^2]', cont=False, alpha=1, orientation=None, location=None)[source]

Internal helper used to display a 2D map with consistent styling.

This function handles the low-level display of a 2D image, including colormap selection, normalization, optional contours, coordinate labeling, pixel-to-arcsecond scaling, and color-bar creation.

Parameters:
  • plt (matplotlib.pyplot) – Pyplot interface used for plotting.

  • flux (ndarray) – 2D map to display.

  • vmax (float) – Display limits.

  • vmin (float) – Display limits.

  • pix (float, optional) – Pixel scale in arcseconds.

  • scale (float, optional) – Additional display scaling control.

  • ticks (list, optional) – Color-bar tick positions.

  • fontsize (int, optional) – Font size used in labels and the color bar.

  • labels (list, optional) – Custom tick labels for the color bar.

  • cmt (matplotlib colormap, optional) – Colormap used to display the image.

  • norm (matplotlib.colors.Normalize, optional) – Explicit normalization object.

  • cbarp (bool, optional) – If True, draw a color bar.

  • fwcs (bool, optional) – If True, assume the plot is being drawn in WCS coordinates.

  • objsys (str, optional) – Name of the coordinate system.

  • tit (str, optional) – Quantity name used in labels.

  • lab (str, optional) – Physical units shown on the color bar.

  • cont (bool, optional) – If True, overlay contours.

  • orientation (str, optional) – Color-bar orientation.

  • location (str, optional) – Color-bar location.

  • alpha (float, optional) – Image transparency.

Returns:

Handle to the displayed image.

Return type:

matplotlib.image.AxesImage

Notes

This is the common rendering backend used by most map-plotting routines in MapLines.tools.plot_tools.

MapLines.tools.plot_tools.get_plot(flux, savef=True, pix=0.2, name='Residual', tit='flux', outs=[], title=None, cbtr=True, bpte=False, maxmin=[], ewp=False)[source]

Plot a 2D map with optional aperture overlays and color bar.

This function displays a two-dimensional map using Matplotlib and can optionally overlay rectangular apertures or regions defined through the outs parameter. It supports both logarithmic scaling for intensity-like maps and linear scaling for diagnostic-classification maps such as BPT-like products.

Parameters:
  • flux (ndarray) – Two-dimensional map to be displayed.

  • savef (bool, optional) – If True, save the figure to a PDF file named name + '_map.pdf'. If False, display the figure interactively.

  • pix (float, optional) – Pixel scale in arcseconds per pixel. This is used to define the spatial extent of the displayed image axes.

  • name (str, optional) – Base name of the output figure when savef=True.

  • tit (str, optional) – Quantity name shown in the color-bar label.

  • outs (list, optional) – Optional list containing aperture or region coordinates and labels. When provided, rectangular outlines and text labels are overplotted on the image.

  • title (str, optional) – Figure title.

  • cbtr (bool, optional) – If True, draw a color bar.

  • bpte (bool, optional) – If True, use linear image scaling appropriate for classification maps. If False, use logarithmic scaling appropriate for flux-like quantities.

  • maxmin (list, optional) – Two-element list defining the minimum and maximum display values [vmin, vmax]. If not given, internal defaults are used.

  • ewp (bool, optional) – If True, the color-bar label is displayed without the default flux surface-brightness units.

Return type:

None

Notes

By default, the input map is divided by pix**2 when bpte=False so that it is displayed as a surface-brightness-like quantity. The plotting extent is centered on the map and expressed in arcseconds.

The optional outs structure is interpreted as a collection of rectangular regions with labels. These are drawn directly on top of the displayed image and are useful for highlighting apertures or selected spatial zones.

MapLines.tools.plot_tools.plot_apertures(ax, hdr, plt, nx, ny, dpix, reg_dir='./', reg_file='test.reg')[source]

Overlay DS9 circular apertures on an existing map axis.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis where the apertures will be drawn.

  • hdr (astropy.io.fits.Header) – FITS header containing WCS information.

  • plt (matplotlib.pyplot) – Matplotlib pyplot handle used for text annotations.

  • nx (int) – Map dimensions.

  • ny (int) – Map dimensions.

  • dpix (float) – Pixel scale in arcseconds.

  • reg_dir (str, optional) – Directory containing the DS9 region file.

  • reg_file (str, optional) – Name of the DS9 aperture file.

Return type:

None

Notes

The aperture definitions are read through tools.get_apertures and plotted as circular outlines with labels.

MapLines.tools.plot_tools.plot_circle(ax, xpos, ypos, nx, ny, dpix, rad=2, color='black', name='1', dtex=0, dtey=0)[source]

Draw a labeled circular marker on a map.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis where the circle will be drawn.

  • xpos (float) – Pixel coordinates of the circle center.

  • ypos (float) – Pixel coordinates of the circle center.

  • nx (int) – Map dimensions.

  • ny (int) – Map dimensions.

  • dpix (float) – Pixel scale in arcseconds.

  • rad (float, optional) – Circle radius in arcseconds.

  • color (str, optional) – Circle and label color.

  • name (str, optional) – Text label placed next to the circle.

  • dtex (float, optional) – Positional offsets for the text label.

  • dtey (float, optional) – Positional offsets for the text label.

Return type:

None

MapLines.tools.plot_tools.plot_outputfits(wave_i, fluxt, fluxtE, model, modsI, n_lines, waves0, fac0, facN0, velfac0, velfacN0, fwhfac0, fwhfacN0, names0, vals, valsL, samples, errp=True, fontsize=14, scl='-16', colors=['blue', 'red', 'purple', 'brown', 'pink'], name_out='name', dir_out='', res_norm=True, labplot=True, dataFe=None, lorentz=False, skew=False, outflow=False, powlaw=False, feii=False)[source]

Plot the result of a spectral-line fit and save a diagnostic figure.

This routine generates the standard fit-diagnostic plot used by MapLines after fitting a spectrum. It shows the observed spectrum, uncertainties, best-fit model, individual components, and optionally posterior diagnostics derived from the MCMC samples.

Parameters:
  • wave_i (ndarray) – Wavelength array of the fitted spectral region.

  • fluxt (ndarray) – Observed flux vector.

  • fluxtE (ndarray) – Flux uncertainty vector.

  • model (ndarray) – Best-fit total model spectrum.

  • modsI (list of ndarray) – Individual spectral components returned by the model.

  • n_lines (int) – Number of fitted emission lines.

  • waves0 (list) – Rest wavelengths of the fitted transitions.

  • fac0 (list) – Amplitude-scaling factors and linked-component names.

  • facN0 (list) – Amplitude-scaling factors and linked-component names.

  • velfac0 (list) – Velocity-scaling factors and linked-component names.

  • velfacN0 (list) – Velocity-scaling factors and linked-component names.

  • fwhfac0 (list) – Width-scaling factors and linked-component names.

  • fwhfacN0 (list) – Width-scaling factors and linked-component names.

  • names0 (list) – Names of the model components.

  • vals (list) – Internal parameter names.

  • valsL (list) – Human-readable parameter labels.

  • samples (ndarray) – Posterior MCMC samples.

  • errp (bool, optional) – If True, show error information in the plot.

  • fontsize (int, optional) – Base font size.

  • scl (str, optional) – Label used for flux scaling.

  • colors (list of str, optional) – Colors used for the component curves.

  • name_out (str, optional) – Output base name.

  • dir_out (str, optional) – Output directory.

  • res_norm (bool, optional) – If True, display normalized residuals.

  • labplot (bool, optional) – If True, annotate the panel with labels.

  • dataFe (ndarray, optional) – FeII template data when used in the model.

  • lorentz (bool, optional) – Flags describing the model family.

  • skew (bool, optional) – Flags describing the model family.

  • outflow (bool, optional) – Flags describing the model family.

  • powlaw (bool, optional) – Flags describing the model family.

  • feii (bool, optional) – Flags describing the model family.

Return type:

None

Notes

This is the main plotting routine called by the fitting functions in MapLines.tools.line_fit after an MCMC fit is completed.