HexMapsAnalysis Functions

The HexMapsAnalysis class (in analysis/hexmaps_analysis.py) provides a set of methods for loading and working with HexMaps .ecsv databases. Instantiate it with the path to an output file:

import sys
sys.path.append("analysis/")
from hexmaps_analysis import HexMapsAnalysis

db = HexMapsAnalysis("output/ngc5194_hexmaps_27p0as_2025_01_01.ecsv")

The underlying Astropy table is available at db.struct, and the list of spectral lines at db.lines.


Coordinate Extraction

db.get_coordinates(center=None)

Return the RA and Dec coordinates of all sightlines.

If center is provided, coordinates are returned as offsets in arcseconds relative to that position.

Parameters:

center (str or None) – Reference coordinate string, e.g. "13:29:52.7 47:11:43". If None, returns absolute decimal degree coordinates.

Returns:

ra, dec — two 1D arrays (degrees or arcsec offsets).

Return type:

numpy.ndarray


Quicklook Plots

db.quickplot_map(line, s=50, cmap=None, ax=None)

Scatter plot of the moment-0 (integrated intensity) map for line.

Parameters:
  • line (str) – Line name as it appears in the database, e.g. "12CO21".

  • s (int) – Marker size. Adjust if hexagons overlap or leave gaps.

  • cmap (str or None) – Matplotlib colormap. Default: "RdYlBu_r".

  • ax – Existing Axes to plot into. If None, a new figure is created.

Returns:

2D scatter plot of integrated intensities.

db.quickplot_spectrum(line, idx=None, ax=None)

Plot the spectrum at a single sightline.

Parameters:
  • line (str) – Line name, e.g. "12CO21".

  • idx (int or None) – Sightline index. If None, the brightest sightline is used.

  • ax – Existing Axes to plot into.

db.quickplot_shuffled_spectrum(line, idx=None, ax=None)

Plot the velocity-shuffled spectrum at a single sightline.

Parameters:
  • line (str) – Line name.

  • idx (int or None) – Sightline index. Defaults to the brightest sightline.

  • ax – Existing Axes to plot into.

db.quickplot_radial_profile(line, ax=None)

Plot the azimuthally averaged moment-0 radial profile.

Parameters:
  • line (str) – Line name.

  • ax – Existing Axes to plot into.


Data Extraction

db.get_mom0(line)

Return the moment-0 array for line.

Parameters:

line (str) – Line name.

Returns:

1D array of integrated intensities.

Return type:

numpy.ndarray

db.get_ratio(line1, line2, sn=5.0)

Compute the line ratio line1 / line2, masking sightlines below the S/N threshold in either line.

Parameters:
  • line1 (str) – Numerator line name.

  • line2 (str) – Denominator line name.

  • sn (float) – S/N threshold for sigma clipping.

Returns:

Dictionary with key "ratio" containing the 1D ratio array.

Return type:

dict

db.get_2D_database(fname=None, save=False)

Return a copy of the table with all SPEC_* columns removed, suitable for compact storage or sharing.

Parameters:
  • fname (str or None) – Output filename. Defaults to <source>_hexmaps_2D.ecsv.

  • save (bool) – If True, write the table to fname.

Returns:

Astropy Table with spectral columns removed.

Return type:

astropy.table.Table


Provenance Recovery

db.get_config(save_to=None)

Return the full content of the config.txt that was used to produce this database, as a plain-text string.

The config is embedded in the .ecsv metadata at run time, making the database fully self-documenting.

Parameters:

save_to (str or None) – If given, write the config content to this file path.

Returns:

The original config.txt content.

Return type:

str

Example:

print(db.get_config())
db.get_config(save_to="recovered_config.txt")
db.list_input_headers()

List the labels of all raw FITS headers embedded in this database.

Labels correspond to the table column keys: e.g. "12CO21" for SPEC_12CO21, "SPIRE250" for MAP_SPIRE250, "OVERLAY" for the overlay cube.

Returns:

Sorted list of label strings.

Return type:

list of str

Example:

db.list_input_headers()
# ['12CO10', '12CO21', 'OVERLAY', 'SPIRE250']
db.get_input_header(label)

Return the raw FITS header of the input file identified by label, exactly as it was on disk before any pipeline processing.

Parameters:

label (str) – Label as returned by list_input_headers(), e.g. "12CO21", "OVERLAY", "SPIRE250". The full metadata key ("input_header_12CO21") is also accepted.

Returns:

The original FITS header.

Return type:

astropy.io.fits.Header

Raises:

KeyError – If label is not found. The error message lists all available labels.

Example:

hdr = db.get_input_header("12CO21")
print(f"Native beam: {hdr['BMAJ'] * 3600:.1f} arcsec")
print(repr(hdr))    # print all header cards