source: trunk/external-alma/components/SpectralComponents/SpectralList.h@ 3146

Last change on this file since 3146 was 3106, checked in by Takeshi Nakazato, 8 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes/No

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...


Check-in asap modifications from Jim regarding casacore namespace conversion.

File size: 5.7 KB
Line 
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//# casacore::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 21229 2012-04-02 12:00:20Z 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
36namespace casacore {
37
38 class RecordInterface;
39 class String;
40 template <class T> class Vector;
41}
42
43namespace casa { //# NAMESPACE CASA - BEGIN
44
45//# Forward Declarations
46class 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
85class 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
106 casacore::Double operator()(const casacore::Double x) const;
107 // Get element n
108 // <thrown>
109 // <li> AipsError if illegal n
110 // </thrown>
111 // <group>
112 const SpectralElement* operator[](const casacore::uInt n) const;
113 SpectralElement* operator[](const casacore::uInt n);
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(Vector<MT> &y) const;
126 template <class MT>
127 void evaluate(Vector<MT> &y, const 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> AipsError if y and x have different lengths
134 // </thrown>
135 // <group>
136 template <class MT>
137 void residual(Vector<MT> &y) const;
138 template <class MT>
139 void residual(Vector<MT> &y, const Vector<MT> &x) const;
140 // </group>
141
142 // Add elements to list (False if list has max length and full)
143 // <group>
144 casacore::Bool add(const SpectralElement &in);
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 // Sort the list on the first parameter (i.e. peak value for Gaussian)
163 void sort();
164
165 // Convert to and from a Record (see details in SpectralElement)
166 // <group>
167 casacore::Bool fromRecord (casacore::String& errMsg, const casacore::RecordInterface& container);
168 casacore::Bool toRecord(casacore::RecordInterface& container) const;
169 //</group>
170
171 private:
172 //#Data
173 // Max length allowed of list
174 casacore::uInt nmax_p;
175 // List of elements
176 casacore::PtrBlock<SpectralElement *> list_p;
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
188std::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
Note: See TracBrowser for help on using the repository browser.