source: trunk/external-alma/components/SpectralComponents/GaussianMultipletSpectralElement.h@ 3006

Last change on this file since 3006 was 2980, checked in by Malte Marquarding, 10 years ago

Add a copy of casacore/components/SpectralComponents to external-alma directory to prepare for its removal from casacore-trunk. DOn;t activate in SConscript yet.

File size: 7.4 KB
Line 
1//# SpectralElement.h: Describes (a set of related) spectral lines
2//# Copyright (C) 2001,2003,2004
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: aips2-request@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25//#
26//#
27//# $Id: GaussianMultipletSpectralElement.h 21451 2014-06-10 07:48:08Z gervandiepen $
28
29#ifndef COMPONENTS_GAUSSIANMULTIPLETSPECTRALELEMENT_H
30#define COMPONENTS_GAUSSIANMULTIPLETSPECTRALELEMENT_H
31
32#include <casa/Arrays/Matrix.h>
33#include <components/SpectralComponents/CompiledSpectralElement.h>
34
35namespace casa { //# NAMESPACE CASA - BEGIN
36
37 class GaussianSpectralElement;
38
39// <summary>
40// Describes a multiplet of Gaussian shaped spectral lines
41// </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="" date="yyyy/mm/dd" tests="tSpectralFit" demos="">
46// </reviewed>
47
48// <prerequisite>
49// <li> <linkto class=SpectralElement>SpectralElement</linkto> module
50// <li> <linkto class=GaussianSpectralElement>GaussianSpectralElement</linkto> module
51// <li> <linkto class=CompiledSpectralElement>CompiledSpectralElement</linkto> module
52// </prerequisite>
53//
54// <etymology>
55// From Gaussian and multiplet and spectral line and element
56// </etymology>
57//
58// <synopsis>
59// The GaussianMultipletSpectralElement class describes a multiplet
60// of Gaussian shaped spectral lines for describing spectral profile.
61//
62// Relationships between Gaussians in the multiplet must be specified.
63// Any combination of one or more of fixed relationships between line
64// center offsets, line amplitude ratios, and/or line width ratios can
65// be specified between a single reference line in the multiplet and
66// other (non-reference) lines in the multiplet. The constructor
67// takes a Vector of GaussianSpectralElements which describes the estimates
68// of the n Gaussians in the multiplet. These objects themselves are not
69// used in the fitting, but are used only to create the function that describes
70// the multiplet. The first element in this Vector represents the reference line
71// to which parameters of the other lines are constrained. In addition, the
72// constructor takes an n-1 x 3 Matrix<Double> describing the fixed relationships
73// between the reference line and the other lines in the multiplet. Each ith row
74// describes the fixed relationship(s) between the (i+1)th and the zeroth
75// (reference) Gaussian. The first element of each row describes the ratio of
76// amplitudes between the (i+1)th and reference Gaussian, the second element
77// describes the difference between the center locations of the (i+1)th and
78// reference Gaussian, and the third represents the ratio of the FWHM of the
79// (i+1)th and reference Gaussian. A value of 0 for any of these indicates there
80// is no fixed relationship for that parameter. At least one value must be non-zero
81// for each row and any combination of elements (including all of them) can be
82// non-zero for any row in this matrix. The values of parameters of non-reference
83// lines in the input vector that are constrained to the reference line are
84// implicitly ignored and set in the constructor according to the specified
85// constraint. If any of the parameters of the reference line are specified as
86// fixed, the corresponding parameters of any non-reference lines which have the
87// corresponding parameters constrained to the reference line are also implicitly
88// fixed. Fixing a parameter in a non-reference line that is constrained to the
89// corresponding parameter of the reference line that is not fixed will cause an
90// exception.
91// </synopsis>
92//
93// <example>
94// This is how to specify a doublet in which the only constraint is that the amplitudes
95// between the lines must be fixed, the first Gaussian must have an ampliute of 0.6 times
96// the zeroth (reference) Gaussian. Other than that, all other parameters can
97// vary during the fit:
98
99// GaussianSpectralElement reference(5, 25, 16);
100// // The amplitude value of first is ignored because of the relationship to the
101// // reference, but it still must be specified in the constructor and must be
102// // non-zero or an exception will be thrown.
103// GaussianSpectralElement first(1, 40, 17);
104// Vector<GaussianSpectralElement> pair(2);
105// pair[0] = reference;
106// pair[1] = first;
107// // initialize constraints matrix to have nothing constrained (all values 0)
108// Matrix<Double> fixedRel(1, 3, 0);
109// // Set the ratio of amplitudes between the first and reference (zeroth) line
110// // to be 0.6.
111// fixedRel[0][0] = 0.6
112// GaussianMultipletSpectralElement doublet(pair,"",fixedRel);
113// </example>
114//
115// <motivation>
116// To allow specifying constraints between different Gaussian spectral
117// lines for fitting, eg to support fitting of doublets.
118// </motivation>
119
120class GaussianMultipletSpectralElement: public CompiledSpectralElement {
121public:
122
123 // Construct a Gaussian multiplet. The values of non-reference (non-zeroth)
124 // estimates will be automatically adjusted if there is a fixed relationship
125 // between a non-reference Gaussian parameter and the corresponding reference
126 // Gaussian parameter.
127 GaussianMultipletSpectralElement(
128 const vector<GaussianSpectralElement>& estimates,
129 const Matrix<Double>& fixedRelationships
130 );
131
132 // copy semantics
133 GaussianMultipletSpectralElement(
134 const GaussianMultipletSpectralElement& other
135 );
136
137 ~GaussianMultipletSpectralElement();
138
139 SpectralElement* clone() const;
140
141 // copy semantics
142 GaussianMultipletSpectralElement &operator=(
143 const GaussianMultipletSpectralElement& other
144 );
145
146 Bool operator==(
147 const GaussianMultipletSpectralElement& other
148 ) const;
149
150 // get the gaussians
151 const vector<GaussianSpectralElement>& getGaussians() const;
152
153 // get the constraints matrix
154 const Matrix<Double>& getConstraints() const;
155
156 //<group>
157 // These methods must be public because the architecture of
158 // the class hierarchy requires it and set() and setError()
159 // must be accessible by fitters. However, it is strongly
160 // recommended that other classes not call these methods for
161 // object configuration but rather set them implicitly at
162 // construction via the Vector<GaussianSpectralElement>
163 // passed to the constructor.
164 void set(const Vector<Double>& param);
165
166 void setError(const Vector<Double> &err);
167
168 void fix(const Vector<Bool>& fix);
169 // </group>
170 // Save to a record.
171 Bool toRecord(RecordInterface& out) const;
172
173private:
174 vector<GaussianSpectralElement> _gaussians;
175 Matrix<Double> _constraints;
176 Matrix<uInt> _paramIndices;
177};
178
179ostream &operator<<(ostream &os, const GaussianMultipletSpectralElement &elem);
180
181} //# NAMESPACE CASA - END
182
183#endif
184
Note: See TracBrowser for help on using the repository browser.