casacore
Loading...
Searching...
No Matches
Lorentzian1DParam.h
Go to the documentation of this file.
1// # Lorentzian1DParam.h: Parameter handling for one-dimensional Lorentzian class
2// # Copyright (C) 2001,2002,2005
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: casa-feedback@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#ifndef SCIMATH_LORENTZIAN1DPARAM_H
27#define SCIMATH_LORENTZIAN1DPARAM_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/BasicSL/String.h>
32#include <casacore/scimath/Functionals/Function1D.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward declarations
37
38// <summary> Parameter handling for one dimensional Lorentzian class.</summary>
39
40// <use visibility=local>
41
42// <reviewed reviewer="tcornwel" date="1996/02/22" tests="tLorentzian1D"
43// demos="">
44// </reviewed>
45
46// <prerequisite>
47// <li> <linkto class="FunctionParam">FunctionParam</linkto> class
48// <li> <linkto class="Function1D">Function1D</linkto> class
49// </prerequisite>
50
51// <etymology>
52// A 1-dimensional Lorentzian's parameters.
53// </etymology>
54
55// <synopsis>
56// A <src>Lorentzian1D</src> is described by a height, center, and width.
57// The parameters (height, center and width) may be changed at run time.
58//
59// The width of the Lorentzian (for the constructors or the <src>setWidth
60// </src> function) is always specified in terms of the full width at half
61// maximum (FWHM). It is always positive and attempts to set a non-positive
62// width will throw an assertion when in debug mode.
63//
64// The peak height of the Lorentzian can be specified at construction time or
65// by using the <src> setHeight </src> function. Alternatively the <src>
66// setFlux </src> function can be used to implicitly set the peak height by
67// specifying the integrated area under the Lorentzian. The height (or flux)
68// can be positive, negative or zero, as this class makes no assumptions on
69// what quantity the height represents.
70//
71// <note role=tip> Changing the width of the Lorentzian will not affect
72// its peak height but will change its flux. So you should always set the
73// width before setting the flux. </note>
74//
75// The parameter interface (see
76// <linkto class="FunctionParam">FunctionParam</linkto> class),
77// is used to provide an interface to the
78// <linkto module="Fitting">Fitting</linkto> classes.
79//
80// There are 3 parameters that are used to describe the Lorentzian:
81// <ol>
82// <li> The height of the Lorentzian. This is identical to the value
83// returned using the <src>height()</src> member function.
84// <li> The center of the Lorentzian in the x direction. This is identical to
85// the value returned using the <src>center()</src> member function.
86// <li> The width (FWHM) of the Lorentzian. To aid convergence of
87// the non-linear fitting routines this parameter is allowed to be
88// negative. This does not affect the shape of the Lorentzian as the
89// square of the width is used when evaluating the function.
90// </ol>
91//
92// An enumeration for the <src>HEIGHT</src>, <src>WIDTH</src> and
93// <src>CENTER</src> parameter index is provided, enabling the setting
94// and reading of parameters with the <src>[]</src> operator. The
95// <src>mask()</src> methods can be used to check and set the parameter masks.
96//
97// This class is in general used implicitly by the <src>Lorentzian1D</src>
98// class only.
99// </synopsis>
100
101// <example>
102// <srcblock>
103// Lorentzian1D<Double> gf(5.0, 25.0, 7);
104// gf(25); // = 5.0
105// gf.setHeight(1.0);
106// gf[WIDTH](2.0);
107// gf[CENTER](0.0);
108// gf(1); // = 0.5*height = 0.5
109// </srcblock>
110// </example>
111
112// <templating arg=T>
113// <li> T should have standard numerical operators and exp() function. Current
114// implementation only tested for real types (and their AutoDiffs).
115// </templating>
116
117// <thrown>
118// <li> Assertion in debug mode if attempt is made to set a negative width
119// <li> AipsError if incorrect parameter number specified.
120// </thrown>
121
122// <todo asof="2001/08/19">
123// <li> Lorentzians that know about their DFT's could be required eventually.
124// </todo>
125
126template <class T>
127class Lorentzian1DParam : public Function1D<T> {
128 public:
129 // # Enumerations
130 enum { HEIGHT = 0, CENTER, WIDTH };
131
132 // # Constructors
133 // Constructs the one dimensional Lorentzians. Defaults:
134 // height=1, center=0, width(FWHM)=1.
135 // <note role=warning> Could not use default arguments
136 // that worked both with gcc and IRIX and all templates</note>
137 // <group>
139 explicit Lorentzian1DParam(const T &height);
140 Lorentzian1DParam(const T &height, const T &center);
141 Lorentzian1DParam(const T &height, const T &center, const T &width);
142 // </group>
143
144 // Copy constructor (deep copy)
145 // <group>
147 template <class W>
149 : Function1D<T>(other), fwhm2int(T(1.0) / T(2.0)) {}
150 // </group>
151 // Copy assignment (deep copy)
153
154 // Destructor
156
157 // # Operators
158
159 // # Member functions
160 // Give name of function
161 virtual const String &name() const {
162 static String x("lorentzian1d");
163 return x;
164 };
165
166 // Get or set the peak height of the Lorentzian
167 // <group>
168 T height() const { return param_p[HEIGHT]; };
169 void setHeight(const T &height) { param_p[HEIGHT] = height; };
170 // </group>
171
172 // Get or set the analytical integrated area underneath the Lorentzian.
173 // Use these functions as an alternative to the height functions.
174 // <group>
175 T flux() const;
176 void setFlux(const T &flux);
177 // </group>
178
179 // Get or set the center ordinate of the Lorentzian
180 // <group>
181 T center() const { return param_p[CENTER]; };
182 void setCenter(const T &cnter) { param_p[CENTER] = cnter; };
183 // </group>
184
185 // Get or set the FWHM of the Lorentzian.
186 // <group>
187 T width() const { return param_p[WIDTH]; };
188 void setWidth(const T &width) { param_p[WIDTH] = width; };
189 // </group>
190
191 protected:
192 // Constant to scale halfwidth at 1/e to FWHM
194
195 // # Make members of parent classes known.
196 protected:
197 using Function1D<T>::param_p;
198
199 public:
201};
202
203} // namespace casacore
204
205#ifndef CASACORE_NO_AUTO_TEMPLATES
206#include "Lorentzian1DParam.tcc"
207#endif // # CASACORE_NO_AUTO_TEMPLATES
208#endif
Function1D()
Constructors.
Definition Function1D.h:81
FunctionParam< T > param_p
Definition Function.h:337
T center() const
Get or set the center ordinate of the Lorentzian.
void setWidth(const T &width)
T width() const
Get or set the FWHM of the Lorentzian.
void setCenter(const T &cnter)
Lorentzian1DParam(const T &height, const T &center, const T &width)
Lorentzian1DParam(const Lorentzian1DParam< W > &other)
void setHeight(const T &height)
Lorentzian1DParam()
Constructs the one dimensional Lorentzians.
Lorentzian1DParam< T > & operator=(const Lorentzian1DParam< T > &other)
Copy assignment (deep copy).
Lorentzian1DParam(const T &height)
Lorentzian1DParam(const Lorentzian1DParam< T > &other)
Copy constructor (deep copy).
T flux() const
Get or set the analytical integrated area underneath the Lorentzian.
virtual const String & name() const
Give name of function.
T fwhm2int
Constant to scale halfwidth at 1/e to FWHM.
void setFlux(const T &flux)
Lorentzian1DParam(const T &height, const T &center)
T height() const
Get or set the peak height of the Lorentzian.
virtual ~Lorentzian1DParam()
Destructor.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28