SpectrumIngest — Converts non-ADMIT spectral data to ADMIT format.¶
This module defines the SpectrumIngest class.
-
class
admit.util.SpectrumIngest.
SpectrumIngest
[source]¶ This class is used to convert foreign data (either files or arrays) into a CubeSpectrum_BDP suitable for use as an input to LineID_AT. If files are used then then the columns containing the frequency and the intensity must be given (channel numbers are optional). Any number of files can be given, but all spectra must have the same length as they are assumed to come from the same data source. Blank lines and lines starting with a comment ‘#’ will be skipped, additionally any line with too few columns will be skipped. If arrays are used an input then both the frequency and intensity must be specified (the channel numbers are optional). Both lists and numpy arrays are accepted as inputs. Multidimmensional arrays are supported with the following parameters:
- A single frequency list can be given to cover all input spectra, otherwise the shape of the frequency array must match that of the spectra
- A single channel list can be given to cover all input spectra, otherwise the shape of the channel array must match that of the spectra
- All spectra must have the same length
If a channel array is not specified then one will be constructed with the following parameters:
- The channel numbers will start at 0 (casa convention)
- The first entry in the spectrum will be considered the first channel, regardless of whether the frequency array increases or decreases.
The convert method will return a single CubeSpectrum_BDP instance holding all input spectra along with an image of each.
Parameters: None Attributes
chan (array) An array holding the channel numbers for the data, multidimmensional arrays are supported. Default: None. chancol (int) The column of the input file(s) that corresponds to the channel listing. Column numbers are 1 based. Default: -1. freq (array) An array holding the frequencies for the data, multidimmensional arrays are supported. Default: None. freqcol (int) The column of the input file(s) that corresponds to the frequency listing. Column numbers are 1 based. Default: -1. spec (array) An array holding the intesities of the data, multidimmensional arrays are supported. Default: None. speccol (int) The column of the input file(s) that corresponds to the intensity listing. Column numbers are 1 based. Default: -1. file (list or str) A single file name or a list of file names to be read in for spectra. Default: None. seperator (str) The column separator for reading in the data files. Default: None (any whitespace). length (int) Internal tracking of the length of the spectra. Methods
convert
([chan, freq, velocity, spec, file, ...])Method to convert input data (either files or arrays) into a CubeSpectrum_BDP. getfile
(file)Method to read in a file and convert it to a Spectrum. -
convert
(chan=None, freq=None, velocity=None, spec=None, file=None, separator=None, restfreq=None, vlsr=None)[source]¶ Method to convert input data (either files or arrays) into a CubeSpectrum_BDP. If files are used then then the columns containing the frequency and the intensity must be given (channel numbers are optional). Any number of files can be given, but all spectra must have the same length as they are assumed to come from the same data source. Blank lines and lines starting with a comment ‘#’ will be skipped, additionally any line with too few columns will be skipped. If arrays are used an input then both the frequency and intensity must be specified (the channel numbers are optional). Both lists and numpy arrays are accepted as inputs. Multidimmensional arrays are supported with the following parameters:
- A single frequency list can be given to cover all input spectra, otherwise the shape of the frequency array must match that of the spectra
- A single channel list can be given to cover all input spectra, otherwise the shape of the channel array must match that of the spectra
- All spectra must have the same length
If a channel array is not specified then one will be constructed with the following parameters:
- The channel numbers will start at 0 (casa convention)
- The first entry in the spectrum will be considered the first channel, regardless of whether the frequency array increases or decreases.
Additionally, if there is velocity axis, but no frequency axis, a frequency axis can be constructed by specifying a rest frequency (restfreq), and vlsr.
The convert method will return a single CubeSpectrum_BDP instance holding all input spectra along with an image of each.
Parameters: chan : array or int
An array holding the channel numbers for the data, multidimmensional arrays are supported. If an integer is specified then it is the number of the column in the file which contains the channel numbers, column numbers are 1 based. Default: None
freq : array
An array holding the frequencies for the data, multidimmensional arrays are supported. If an integer is specified then it is the number of the column in the file which contains the frequencies, column numbers are 1 based. Default: None
velocity : array
An array holding the velocity for the data, multidimmensional arrays are supported. If an integer is specified then it is the number of the column in the file which contains the velcoties, column numbers are 1 based. If this parameter is specified then restfreq and vlsr must also be specified. Default: None
spec : array
An array holding the intesities of the data, multidimmensional arrays are supported. If an integer is specified then it is the number of the column in the file which contains the intensities, column numbers are 1 based. Default: None
file : list or str
A single file name or a list of file names to be read in for spectra. Default: None
separator : str
The column separator for reading in the data files. Default: None (any whitespace)
restfreq : float
The rest frequency to use to convert the spectra from velocity to frequency units. The rest frequency is in GHz. Default: None (no conversion done)
vlsr : float
The reference velocity for converting a velocity axis to frequency. The units are km/s. If this is not set then it is assumed that the vlsr is 0.0. Default: None
Returns: CubeSpectrum_BDP instance containing all of the inpur spectra.