SpectralElement.h

Classes

SpectralElement -- Describes (a set of related) spectral lines (full description)
Global Functions -- Global functions (full description)

class SpectralElement : public RecordTransformable

Types

enum Types

GAUSSIAN
A gaussian profile
POLYNOMIAL
A polynomial baseline
COMPILED
Any compiled string functional
N_Types

Interface

Public Members
SpectralElement()
SpectralElement(SpectralElement::Types tp, const Double ampl, const Double center, const Double sigma)
explicit SpectralElement(const uInt n)
explicit SpectralElement(const String &str, const String<Double> &param)
SpectralElement(SpectralElement::Types tp, const Vector<Double> &param)
SpectralElement(const SpectralElement &other)
~SpectralElement()
SpectralElement &operator=(const SpectralElement &other)
Double operator()(const Double x) const
Double operator[](const uInt n) const
static const String *const allTypes(Int &nall, const SpectralElement::Types *&typ)
static const String &fromType(SpectralElement::Types tp)
static Bool toType(SpectralElement::Types &tp, const String &typName)
SpectralElement::Types getType() const
Double getAmpl() const
Double getCenter() const
Double getSigma() const
Double getFWHM() const
void get(Vector<Double> &param) const
Double getAmplErr() const
Double getCenterErr() const
Double getSigmaErr() const
Double getFWHMErr() const
void getError(Vector<Double> &err) const
uInt getDegree() const
const String &getCompiled() const
uInt getOrder() const
template <class MT> void set(SpectralElement::MT tp, const Types<MT> &param)
template <class MT> void set(const MT<MT> &param)
void setError(const Vector<Double> &err)
void setAmpl(Double ampl)
void setCenter(Double center)
void setSigma(Double sigma)
void setFWHM(Double fwhm)
void setDegree(uInt n)
void setCompiled(const String &str)
void fixAmpl(const Bool fix=True)
void fixCenter(const Bool fix=True)
void fixSigma(const Bool fix=True)
void fixFWHM(const Bool fix=True)
void fix(const Vector<Bool> &fix)
Bool fixedAmpl() const
Bool fixedCenter() const
Bool fixedSigma() const
Bool fixedFWHM() const
const Vector<Bool> &fixed() const
static SpectralElement* fromRecord(const RecordInterface &container)
virtual Bool fromRecord(String &error, const RecordInterface &in)
virtual Bool fromString(String &error, const String &in)
virtual Bool toRecord(String &error, RecordInterface &out) const
virtual const String &ident() const
Private Members
void checkGauss() const
void checkPoly() const
void checkCompiled() const
void check()
static Double sigmaToFWHM (const Double sigma)
static Double sigmaFromFWHM (const Double fwhm)

Description

Review Status

Date Reviewed:
yyyy/mm/dd
Programs:
Tests:

Prerequisite

Etymology

From spectral line and element

Synopsis

The SpectralElement class is a container for a spectral line descriptor. It can contain a single line (like a Gaussian profile), or a set of related lines (like a doublet or so).

The element can be used in the SpectralFit class and in the SpectralEstimate class.

The default type is a Gaussian, defined as:

	AMPL.exp[ -(x-CENTER)<sup>2</sup>/2 SIGMA<sup>2</sup>]

Example

Motivation

To have a container for fitting of spectral profiles to an observed spectrum

To Do

Member Description

enum Types

Types of spectral lines known

SpectralElement()

Default constructor creates a default Gaussian element with an amplitude of 1; an integral (sigma=2sqrt(ln2)/pi) of 1; a central frequency of zero.

SpectralElement(SpectralElement::Types tp, const Double ampl, const Double center, const Double sigma)

Construct with given type and values

Thrown Exceptions

explicit SpectralElement(const uInt n)

Construct an n-degree polynomial

explicit SpectralElement(const String &str, const String<Double> &param)

Construct a compiled string

SpectralElement(SpectralElement::Types tp, const Vector<Double> &param)

Construct the given tp with the given param

Thrown Exceptions

SpectralElement(const SpectralElement &other)

Copy constructor (deep copy)

Thrown Exceptions

~SpectralElement()

Destructor

SpectralElement &operator=(const SpectralElement &other)

Assignment (copy semantics)

Thrown Exceptions

Double operator()(const Double x) const

Evaluate the value of the element at x

Double operator[](const uInt n) const

Get parameter n

Thrown Exceptions

static const String *const allTypes(Int &nall, const SpectralElement::Types *&typ)

Get all the types available as String and codes, and number available

static const String &fromType(SpectralElement::Types tp)

Get a string from the type

static Bool toType(SpectralElement::Types &tp, const String &typName)

Get a type from a (non-case sensitive; minimum match) String

SpectralElement::Types getType() const

Get the data for this element

Thrown Exceptions

Get type of this element

Double getAmpl() const

Get the data for this element

Thrown Exceptions

Get amplitude

Double getCenter() const

Get the data for this element

Thrown Exceptions

Get center value

Double getSigma() const
Double getFWHM() const

Get the data for this element

Thrown Exceptions

Get the width

Double getAmplErr() const

Get the data for this element

Thrown Exceptions

Get amplitude error estimate

Double getCenterErr() const

Get the data for this element

Thrown Exceptions

Get center value error estimate

Double getSigmaErr() const
Double getFWHMErr() const

Get the data for this element

Thrown Exceptions

Get the width error estimate

uInt getDegree() const

Get the data for this element

Thrown Exceptions

Get the degree of e.g. polynomial

const String &getCompiled() const

Get the data for this element

Thrown Exceptions

Get the string of a compiled functional

void get(Vector<Double> &param) const
void getError(Vector<Double> &err) const

Get the data for this element

Thrown Exceptions

uInt getOrder() const

Get the order (i.e. the number of parameters)

template <class MT> void set(SpectralElement::MT tp, const Types<MT> &param)

Set data for element

Set all data

Thrown Exceptions

Reset a complete element

template <class MT> void set(const MT<MT> &param)

Set data for element

Set all data

Thrown Exceptions

void setAmpl(Double ampl)

Set data for element

Set amplitude

Thrown Exceptions

void setCenter(Double center)

Set data for element

Set center

Thrown Exceptions

void setError(const Vector<Double> &err)

Set data for element

void setSigma(Double sigma)
void setFWHM(Double fwhm)

Set width

Thrown Exceptions

void setDegree(uInt n)

Set degree

Thrown Exceptions

void setCompiled(const String &str)

Set a new compiled string

Thrown Exceptions

void fix(const Vector<Bool> &fix)

Set fixed parameters (True) or unset them (False)

Thrown Exceptions

Fix/unfix all in one go

void fixAmpl(const Bool fix=True)
void fixCenter(const Bool fix=True)
void fixSigma(const Bool fix=True)
void fixFWHM(const Bool fix=True)

Set fixed parameters (True) or unset them (False)

Thrown Exceptions

Bool fixedAmpl() const
Bool fixedCenter() const
Bool fixedSigma() const
Bool fixedFWHM() const
const Vector<Bool> &fixed() const

Get the fix state[s]

Thrown Exceptions

static SpectralElement* fromRecord(const RecordInterface &container)

Construct from record. Must hold fields "type" (String) and "parameters" (Vector). For type=GAUSSIAN, parameters holds amplitude, center and sigma. For type=POLYNOMIAL, parameters(0) holds the degree.

virtual Bool fromRecord(String &error, const RecordInterface &in)
virtual Bool fromString(String &error, const String &in)

Create a SpectralElement from a record. An error message is generated, and False returned if an invalid record is given. A valid record will return True. A valid record contains the following fields (any additional fields are ignored):

A SpectralElement can be created from a string. In that case the string will only indicate the type of element (like gaussian), and will create a default element of that given type. Error messages are postfixed to error.

virtual Bool toRecord(String &error, RecordInterface &out) const

Save to a record. The return will be False and an error message generated only if the SpectralElement is illegal (could not happen) Error messages are postfixed to error. For Gaussian elements, the width is defined as a FWHM in the record interface.

virtual const String &ident() const

Get the identification of a record

void checkGauss() const

Check if GAUSSIAN type

Thrown Exceptions

void checkPoly() const

Check if POLYNOMIAL type

Thrown Exceptions

void checkCompiled() const

Check if COMPILED type

Thrown Exceptions

void check()

Check if sigma non-equal to zero and positive if a GAUSSIAN; if COMPILED check for correct string

Thrown Exceptions

static Double sigmaToFWHM (const Double sigma)
static Double sigmaFromFWHM (const Double fwhm)

Sigma to FWHM Convert from sigma to FWHM and vice versa


Global functions (source)

Interface

ostream &operator<<(ostream &os, const SpectralElement &elem)

Description

Member Description

ostream &operator<<(ostream &os, const SpectralElement &elem)

Output declaration