casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpectralList.h
Go to the documentation of this file.
1 //# SpectralList.h: A set of SpectralElements
2 //# Copyright (C) 2001
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: SpectralList.h 20229 2008-01-29 15:19:06Z gervandiepen $
28 
29 #ifndef COMPONENTS_SPECTRALLIST_H
30 #define COMPONENTS_SPECTRALLIST_H
31 
32 //# Includes
33 #include <casa/aips.h>
34 #include <casa/Containers/Block.h>
35 
36 namespace casacore{
37 
38 class RecordInterface;
39 class String;
40 template <class T> class Vector;
41 }
42 
43 namespace casa { //# NAMESPACE CASA - BEGIN
44 
45 //# Forward Declarations
46 class SpectralElement;
47 
48 // <summary>
49 // A set of SpectralElements
50 // </summary>
51 
52 // <use visibility=export>
53 
54 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tSpectralFit" demos="">
55 // </reviewed>
56 
57 // <prerequisite>
58 // <li> <linkto class=SpectralElement>SpectralElement</linkto> class
59 // </prerequisite>
60 //
61 // <etymology>
62 // From spectral line and element list
63 // </etymology>
64 //
65 // <synopsis>
66 // The SpectralList class is a container for a set of spectral elements.
67 //
68 // The list can be used in the
69 // <linkto class=SpectralFit>SpectralFit</linkto> class and in the
70 // <linkto class=SpectralEstimate>SpectralEstimate</linkto> class.
71 //
72 // </synopsis>
73 //
74 // <example>
75 // </example>
76 //
77 // <motivation>
78 // To have a container for fitting of spectral profiles to an observed spectrum
79 // </motivation>
80 //
81 // <todo asof="2001/02/04">
82 // <li> add more profile types
83 // </todo>
84 
85 class SpectralList {
86  public:
87 
88  //# Constructors
89  // Default constructor creates an empty list
90  SpectralList();
91  // Construct a list with a maximum length of n (0: unlimited length)
92  explicit SpectralList(casacore::uInt nmax);
93  // Construct with an initial element
94  explicit SpectralList(const SpectralElement &in);
95  // Copy constructor (deep copy)
96  SpectralList(const SpectralList &other);
97 
98  //#Destructor
99  // Destructor
100  ~SpectralList();
101 
102  //# Operators
103  // Assignment (copy semantics)
104  SpectralList &operator=(const SpectralList &other);
105  // Evaluate the value of the sum of the elements at x
107  // Get element n
108  // <thrown>
109  // <li> casacore::AipsError if illegal n
110  // </thrown>
111  // <group>
112  const SpectralElement* operator[](const casacore::uInt n) const;
114  // </group>
115 
116  //# Member functions
117  // Get the number of elements in list
118  casacore::uInt nelements() const { return list_p.nelements(); };
119 
120  // Get the profile values for all elements in list. The evaluation
121  // is for the length of the given <src>prof</src>, assuming x values of
122  // 0,1,... if no x given.
123  // <group>
124  template <class MT>
125  void evaluate(casacore::Vector<MT> &y) const;
126  template <class MT>
127  void evaluate(casacore::Vector<MT> &y, const casacore::Vector<MT> &x) const;
128  // </group>
129 
130  // Calculate the residuals at the points x; by subtracting the model from y.
131  // x=0,1,2,.. if not given.
132  // <thrown>
133  // <li> casacore::AipsError if y and x have different lengths
134  // </thrown>
135  // <group>
136  template <class MT>
137  void residual(casacore::Vector<MT> &y) const;
138  template <class MT>
139  void residual(casacore::Vector<MT> &y, const casacore::Vector<MT> &x) const;
140  // </group>
141 
142  // Add elements to list (false if list has max length and full)
143  // <group>
145  casacore::Bool add(const SpectralList &in);
146  // </group>
147  // Insert in sort order in the list
148  // <group>
149  void insert(const SpectralElement &in);
150  void insert(const SpectralList &in);
151  // </group>
152  // Set an element in the list. Return false if more than one place beyond
153  // end of list; or if beyond max size.
154  casacore::Bool set(const SpectralElement &in, const casacore::uInt which);
155 
156  // Clear the list
157  void clear();
158 
159  // Set a maximum size of the list
160  void set(const casacore::uInt nmax);
161 
162  // casacore::Sort the list on the first parameter (i.e. peak value for Gaussian)
163  void sort();
164 
165  // Convert to and from a casacore::Record (see details in SpectralElement)
166  // <group>
169  //</group>
170 
171  private:
172  //#Data
173  // Max length allowed of list
175  // casacore::List of elements
177 
178  //# Member functions
179  // Compare two elements
180  casacore::Int compar(const SpectralElement &p1, const SpectralElement &p2) const;
181 
182 };
183 
184 //# Global functions
185 // <summary> Global functions </summary>
186 // <group name=Output>
187 // Output declaration
188 std::ostream &operator<<(std::ostream &os, const SpectralList &lst);
189 // </group>
190 
191 
192 } //# NAMESPACE CASA - END
193 
194 #ifndef CASACORE_NO_AUTO_TEMPLATES
195 #include <components/SpectralComponents/SpectralList2.tcc>
196 #endif //# CASACORE_NO_AUTO_TEMPLATES
197 #endif
~SpectralList()
Destructor.
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
std::vector< double > Vector
Definition: ds9context.h:24
ostream & operator<<(ostream &os, const PageHeaderCache &cache)
void insert(const SpectralElement &in)
Insert in sort order in the list.
casacore::Double operator()(const casacore::Double x) const
Evaluate the value of the sum of the elements at x.
casacore::Bool add(const SpectralElement &in)
Add elements to list (false if list has max length and full)
SpectralList()
Default constructor creates an empty list.
casacore::Bool set(const SpectralElement &in, const casacore::uInt which)
Set an element in the list.
casacore::Int compar(const SpectralElement &p1, const SpectralElement &p2) const
Compare two elements.
Describes (a set of related) spectral lines.
casacore::uInt nmax_p
Max length allowed of list.
Definition: SpectralList.h:174
double Double
Definition: aipstype.h:55
const SpectralElement * operator[](const casacore::uInt n) const
Get element n.
void sort()
casacore::Sort the list on the first parameter (i.e.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void residual(casacore::Vector< MT > &y) const
Calculate the residuals at the points x; by subtracting the model from y.
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
casacore::uInt nelements() const
Get the number of elements in list.
Definition: SpectralList.h:118
casacore::PtrBlock< SpectralElement * > list_p
casacore::List of elements
Definition: SpectralList.h:176
SpectralList & operator=(const SpectralList &other)
Assignment (copy semantics)
A set of SpectralElements.
Definition: SpectralList.h:85
casacore::Bool fromRecord(casacore::String &errMsg, const casacore::RecordInterface &container)
Convert to and from a casacore::Record (see details in SpectralElement)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Abstract base class for Record classes.
casacore::Bool toRecord(casacore::RecordInterface &container) const
void clear()
Clear the list.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42
void evaluate(casacore::Vector< MT > &y) const
Get the profile values for all elements in list.