casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProfileFitterEstimatesFileParser.h
Go to the documentation of this file.
1 //# Copyright (C) 1996,1997,1999,2002
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 //# $Id: $
26 
27 #ifndef IMAGEANALYSIS_PROFILEFITTERESTIMATESFILEPARSER_H
28 #define IMAGEANALYSIS_PROFILEFITTERESTIMATESFILEPARSER_H
29 
30 //# Includes
31 #include <casa/aips.h>
32 #include <casa/OS/RegularFile.h>
35 #include <memory>
36 
37 namespace casa { //# NAMESPACE CASA - BEGIN
38 
39 // <summary>
40 // Class for parsing a file which holds initial estimates for 1-D components. Used by ImageProfileFitter.
41 // </summary>
42 
43 // <use visibility=export>
44 
45 // <reviewed reviewer="" date="" tests="tProfileFitterEstimatesFileParser" demos="">
46 // </reviewed>
47 
48 // <prerequisite>
49 // <li> <linkto class=RegularFilebufIO>casacore::FilebufIO</linkto> class
50 // </prerequisite>
51 
52 // <synopsis>
53 // Used for reading files containing initial estimates of models for 1-D fitting.
54 // The expected format is:
55 // <ol>
56 // <li>Lines with a "#" in column 1 are treated as comments and ignored.</li>
57 // <li> Each non-comment line is treated as a complete set of three comma-delimited
58 // parameters for specifying an estimate for a gaussian component. The values are
59 // peak in image units (double), pixel position of center (double),
60 // and FWHM in pixels (double)</li>
61 // <li> Optionally, a gaussian component estimate line can have a fourth parameter which is
62 // a string specifying which of the parameters for that component should be held
63 // fixed during the fit. This string can include any combination of the following
64 // identifiers: "p" peak, "c" center position, "f" FWHM. So, eg, "cp" means hold the center
65 // and peak constant during the fit. </li>
66 // </ol>
67 // If the specified file passed to the constructor does not exist, an exception is thrown.
68 // Parsing is done during object construction and an exception is thrown if the file
69 // does not have the expected format.
70 // </synopsis>
71 //
72 // <example>
73 // <srcblock>
74 // ProfileFitterEstimatesFilebFileReader reader("myEstimates.txt", myImage);
75 // SpectralList sl = reader.getEstimates();
76 // vector<casacore::String> fixed = reader.getFixed();
77 // </srcblock>
78 // </example>
79 
81  public:
82 
83  // Constructor
84  // <src>filename</src> Name of file containing estimates
85  // <src>image</src> Image for which the estimates apply
87  const casacore::String& filename
88  );
89 
91 
92  // Get the estimates specified in the file as a ComponentList object.
93  SpectralList getEstimates() const;
94 
95  // Get the fixed parameter masks specified in the file.
96  std::vector<casacore::String> getFixed() const;
97 
98  // Get the contents of the file
100 
101  private:
102  const static casacore::String _class;
104  std::vector<casacore::String> _fixedValues;
106  std::vector<casacore::Double> _peakValues, _centerValues, _fwhmValues;
108 
109  // parse the file
110  void _parseFile(const casacore::RegularFile& myFile);
111  void _createSpectralList();
112 };
113 
114 } //# NAMESPACE CASA - END
115 
116 #endif
Class for parsing a file which holds initial estimates for 1-D components. Used by ImageProfileFitter...
std::vector< casacore::String > getFixed() const
Get the fixed parameter masks specified in the file.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
Manipulate and get information about regular files.
Definition: RegularFile.h:91
A set of SpectralElements.
Definition: SpectralList.h:85
casacore::String getContents() const
Get the contents of the file.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void _parseFile(const casacore::RegularFile &myFile)
parse the file
SpectralList getEstimates() const
Get the estimates specified in the file as a ComponentList object.
ProfileFitterEstimatesFileParser(const casacore::String &filename)
Constructor filename Name of file containing estimates image Image for which the estimates apply...