specutil — Module for low-level manipulation of spectral line data.

This module defines methods used in processing spectral line data.

admit.util.specutil.contsub(id, spectra, segmentfinder, segargs, algorithm, **keyval)[source]

Do continuum subtraction with specific arguments. Used by LineID_AT and LineSegment_AT

: int
Task id of the AT calling this method
: list
List of spectra to run continuum subtraction on
: str
The segment finder to use (i.e. ADMIT, ASAP, etc.)
: dict
Dictionary containing the arguments for the segmentfinder
: str
The continuum finding algorithm to use (i.e. PolyFit, SplineFit, SVD_Vander, etc.)
: dict
Dictionary containing the arguments for the continuum finding algorithm
admit.util.specutil.findsegments(spectra, method, minchan, maxgap, numsigma, iterate, noise=None)[source]

Call Segmentfinder with specific options. Used by LineID_AT and LineSegment_AT


spectra : list

list of input spectra

: string

segment finding method

: int

maximum channel gap between segments

: float

level cutoff for finding segments, measured in number of 1 sigma rms noise

iterate : boolean

: float

noise level to use. Default: None, noise is calculated


list of [(separation,cutoff,noise,mean)] tuples as returned by SegmentFinder.find(), indexed to input spectra

admit.util.specutil.getinfo(segment, spec)[source]

Method to get basic information about a spectral line that was only detected by segment detection. Calculates the peak intensity, the sigma of the peak, and the very rough FWHM of the line.


segment : list

List of two points (the start and end of the segement)

spec : a single admit.util.Spectrum or list of admit.util.Spectrum.

If a list, the Spectrum with the highest peak (or lowest in case of absorption spectrum) will be used.


Tuple containing the peak intensity, sigma, and FHWM in km/s of the


admit.util.specutil.getspectrum(bdp, vlsr=0.0, smooth=(), recalc=False, segment={'numsigma': 2.0, 'minchan': 5, 'maxgap': 3, 'nomean': True, 'iterate': True, 'method': 'ADMIT'})[source]

Method to convert an input BDP into a list based spectrum. The spectrum will be smoothed if requested by the input parameters.


bdp : BDP

The input BDP, currently either a CubeSpectrum or CubeStats only.

vlsr : float

The velocity of the source. Default: 0.0

smooth : tuple

If smoothing is to be done...

recalc : bool

True if the noise is to be recalculted from smoothed spectra Default: False


A series of numpy arrays describing the spectrum.

(freq, chans, spectrum)

admit.util.specutil.linedatafromsegments(freq, chan, segments, specs, statspec=None)[source]

Common method used by LineSegment_AT and LineID_AT to construct LineData from an input list of segments.


freq : array like

The global frequency axis of the input segments

: array like

The global channel axis of the input segments

segments: array like

The input segments, as returned from e.g. mergesegments

: Spectrum

Array of spectra or single spectrum

: Spectrum

Optional Cubestats spectrum


List of LineData objects constructed from input segments

admit.util.specutil.mergefreq(globalfreq, globalchan, freq, chan)[source]

Method to merge the frequency and channel axes from input spectra into a single global set.


globalfreq : array like

The global set of frequencies, may be empty if first time

globalchan : array like

The global set of channels, may be empty if first time

freq : array like

The frequency axis to add to the global set

chan : array like

The channel axis to add to the global set


(globalfreq, globalchan) as numpy array tuple

@todo return it as same type as came in?

admit.util.specutil.mergestats(s1, s2, noise)[source]

Method to merge two stats “spectra” into one. Specifically it is intended to merge the min and max columns from CubeStats by taking the maximum of max and abs(min). Giving sensitivity to any absorption lines.


s1 : numpy array

The “max” array from CubeStats

s2 : nump array

The “min” array from CubeStats

noise : numpy array

The channel based rms noise


numpy array containing the merged spectra