GenerateSpectrum_AT — Generates synthetic test spectra.

This module defines the GenerateSpectrum_AT class.

class admit.at.GenerateSpectrum_AT.GenerateSpectrum_AT(**keyval)[source]

Define a synthetic CubeSpectrum for testing.

This task is only intended to generate synthetic spectra with noise, and to efficiently test LineID with a CubeSpectrum_BDP input. You can add continuum as well, and add any number of gaussian’s, or even optionally read in an ASCII spectrum, and add noise and gaussians to this. Multiple spectra can be in the CubeSpectrum_BDP.

When noise is added, spectra have a fixed RMS = 1.0, i.e. spectra are assumed to be in dimensionless S/N units.

Keywords
file: string
Name of an ASCII file that contains a spectrum, optional. The first column must be frequency and the second column must be the intensity. If you just want to read a spectrum and not add noise, set seed=-1. Default: blank.
nchan: int
Number of output channels per spectrum. Ignored when file= given. Default: 1000.
nspectra: int
Number of output spectra. More than one are meant for different random realizations of the input conditions (either from file= and/or from lines= via seed=), but they are all written to the same BDP. Default: 1.
seed: int
Seed for random number generator. 0 is a special value that uses a random realization per call, e.g. time of the day. Use any other positive value to seed with a repeatable random sequence. -1 is a special value to disable the random number generator noise (for example if an input spectrum should not be polluted with random noise). Default: 0.
contin: float
Continuum level level added to the noise spectra. You can only add a continuum level when noise is added as well, i.e. when seed >= 0. Default: 0.0.
freq: float
The central frequency of the band in GHz. Default: 115.2712018.
delta: float
The size of each channel in MHz. Default: 0.5.
lines: list of tuples

Parameters for each Gaussian line. Intensity (SNR), center frequency in GHz, FHWM in km/s. Examples:

[(15.0, 110.201, 22.0)]

Produce a single Gaussian centered at 110.201 GHz that is 15.0 sigma tall with a FWHM of 22.0 km/s.

[(12.0, 109.98, 15.3), (6.0, 110.0, 15.0)]

Produce two Gaussians, one centered at 109.98 GHz with a peak of 12.0 sigma and FWHM of 15.3 kms, and a second centered at 110.0 GHz with an intensity of 6.0 sigma and FWHM of 15.0 km/s.

Default: [].

transitions: list

List of any transitions to be included in the spectrum. Each entry should be a list containing the molecule name, frequency range (in GHz), intensity(SNR), FWHM in km/s and offset in km/s. Any tranitions from the given molecule(s) and frequency range will be included. Example of entry:

[(“13COv=0”, [110.15, 110.25], 6.0, 30.0, 5.0),
(“CH3CNv=0”, [110.2, 110.5], 4.5, 10.0, 0.0)]

This will produce a single 13CO line with a peak intensity of 6 sigma, FWHM of 30.0 km/s and centered at a offset velocity of 5.0 km/s; and a set of 6 of CH3CN lines (with hyperfine components), with the highest line strength transition peaking at 4.5 sigma, and the rest proportionally weaker based on line strength, all with a FWHM of 10.0 km/s and no offset. Molecules can be given multiple times for the purpose of having multiple velocity components. Default: [].

hanning: bool
If True then do a final (1/4,1/2,1/4) hanning smooth over 3 channels. Default: False.
Input BDPs
None

Output BDPs

CubeSpectrum_BDP: count: 1
Spectrum through the cube. Stored as a single multi-plane table if nspectra > 1. Output BDP name takes from the input Image by replacing the extension with “csp”. See also CubeSpectrum_BDP — Data cube spectra..
Parameters:

keyval : dictionary, optional

Keyword values.

Attributes

_version (string) Version string.

Methods

addinput(item[, slot]) Add a BDP input to an AT.
addinputbdp(item[, slot, insert]) Add a BDP to the _bdp_in list.
addoutput(item[, slot]) Add a BDP output product to an AT.
addoutputbdp(item[, slot, insert]) Add a BDP to the _bdp_out list.
baseDir([path]) Get/set project base directory.
bestMatch(at1, at2) Determines the better match of two tasks to the current one.
checkfiles() Check if the files from all the BDP_out’s in an AT exist.
checktype(item) Check the type of an object to see if it is a BDP.
clearinput() Clear the input BDP list.
clearoutput([delete]) Clear the output BDP list.
copy() Creates an independent duplicate of the task.
delete() Method to delete the AT and underlying BDPs.
delinput(slot) Delete a specific BDP in the _bdp_in list.
deloutput(slot) Delete a specific BDP in the _bdp_out list.
dir([filename]) Absolute directory reference of the ADMIT project.
dryrun() Method to do a dry run of the AT, generally just checks input values for errors.
enabled([state]) Returns current task enabled setting, with optional reset.
execute([args]) Executes the task.
freeAlias(aliases[, alias]) Deletes alias reservation, if present.
get(attrib) Method to get the given attributes value
getProject() Retrieves project ID associated with the task.
getVersion() Return the version string.
getdtd(fl) Method to write out the dtd data.
geteffectivelevel() Method to get the effective logging level of the logging subsystem
getkey(key) Retrieval value for a key.
getloggername() Method to get the name of the logger for this AT instance
getlogginglevel() Method to get the current logging level of the AT
haskey(key) Query if a key exists for an AT.
html(inheader) Method to represent the current AT in HTML format.
id([strip]) Returns task ID number.
isAutoAlias([withEmpty, compat]) Whether the task alias appears to be auto-generated.
isequal(at) Method to determine if two ATs are the same.
isstale() Returns whether the AT is out of date.
len2() Returns the length of _bdp_in and _bdp_out in a tuple.
link() Increments the task link count.
markChanged() Mark an AT that it’s state was changed, so it would need to be rerun.
markUpToDate() Resets _stale to indicate that the AT does not need to be run.
merge(at[, aliases]) Merges attributes from another task.
mkdir(dirname) Make a directory in the ADMIT hierarchy.
mkext(filename, ext[, alias]) Return a new filename with a new extension with optional ADMIT alias.
newId(tid) Assigns the task a new ID number.
reset(a) Performs an in-place shallow copy.
run() Runs the task.
running([state]) Returns current task execution flag, with optional reset.
save() Save (write) any BDPs connected to this AT.
set(item, val) Method to set protected attributes, rather than direct access
setAlias(aliases[, alias, auto]) Sets and registers the task alias, guaranteed unique among registered aliases.
setProject(pid) Adds a project ID to task ID.
set_bdp_in([bdpin]) Validate the _valid_bdp_in list and digest it into the appropriate attributes.
set_bdp_out([bout]) Validate the _valid_bdp_out list and digest it into the appropriate attributes.
seteffectivelevel(level) Method to set the effective logging level of the logging subsystem
setkey([name, value, isinit]) Set keyword value.
setloggername(name) Method to set the name of the logger for this AT instance
setlogginglevel(level) Method to set the logging level
show() Return the AT type.
statusicons() return some html icons representing the enabled/stale status of this task
summary() Returns the summary dictionary from the AT, for merging into the ADMIT Summary object.
unlink() Decrements the task link count.
userdata() Returns the user dictionary from the AT, for merging into the ADMIT userdata object.
validateinput([describe]) Method to validate the _bdp_in’s against a dictionary of expected types.
validatekeys() Method to error check all input keys.
write(node) Method to write the AT to disk.
run()[source]

Runs the task.

Parameters:None
Returns:None
summary()[source]

Returns the summary dictionary from the AT, for merging into the ADMIT Summary object.

GenerateSpectrum_AT adds the following to ADMIT summary:

Key type Description
spectra list the spectral plots
Parameters:

None

Returns:

dict

Dictionary of SummaryEntry

admit.at.GenerateSpectrum_AT.getspec(file, xcol=0, ycol=1)[source]

read a spectrum/table from column 1,2

returns: (freq,spec)