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". IfNone, 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:
- Returns:
2D scatter plot of integrated intensities.
- db.quickplot_spectrum(line, idx=None, ax=None)
Plot the spectrum at a single sightline.
- db.quickplot_shuffled_spectrum(line, idx=None, ax=None)
Plot the velocity-shuffled spectrum at a single sightline.
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.
- 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.
Provenance Recovery
- db.get_config(save_to=None)
Return the full content of the
config.txtthat was used to produce this database, as a plain-text string.The config is embedded in the
.ecsvmetadata 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.txtcontent.- Return type:
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"forSPEC_12CO21,"SPIRE250"forMAP_SPIRE250,"OVERLAY"for the overlay cube.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