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

id
: int
Task id of the AT calling this method
spectra
: list
List of spectra to run continuum subtraction on
segmentfinder
: str
The segment finder to use (i.e. ADMIT, ASAP, etc.)
segargs
: dict
Dictionary containing the arguments for the segmentfinder
algorithm
: str
The continuum finding algorithm to use (i.e. PolyFit, SplineFit, SVD_Vander, etc.)
keyval
: 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

Parameters:

spectra : list

list of input spectra

method
: string

segment finding method

maxgap
: int

maximum channel gap between segments

numsigma
: float

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

iterate : boolean

noise
: float

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

Returns:

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.

Parameters:

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.

Returns:

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

line

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.

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

Returns:

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.

Parameters:

freq : array like

The global frequency axis of the input segments

chan
: array like

The global channel axis of the input segments

segments: array like

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

specs
: Spectrum

Array of spectra or single spectrum

statspec
: Spectrum

Optional Cubestats spectrum

Returns:

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.

Parameters:

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

Returns:

(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.

Parameters:

s1 : numpy array

The “max” array from CubeStats

s2 : nump array

The “min” array from CubeStats

noise : numpy array

The channel based rms noise

Returns:

numpy array containing the merged spectra