casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FitterEstimatesFileParser.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_FITTERESTIMATESFILEPARSER_H
28 #define IMAGEANALYSIS_FITTERESTIMATESFILEPARSER_H
29 
30 #include <casa/aips.h>
31 #include <casa/OS/RegularFile.h>
34 #include <memory>
35 
36 namespace casa { //# NAMESPACE CASA - BEGIN
37 
38 // <summary>
39 // Class for parsing a file which holds initial estimates for 2-D components. Used by imfit.
40 // </summary>
41 
42 // <use visibility=export>
43 
44 // <reviewed reviewer="" date="" tests="tFitterEstimatesFileParser" demos="">
45 // </reviewed>
46 
47 // <prerequisite>
48 // <li> <linkto class=RegularFilebufIO>casacore::FilebufIO</linkto> class
49 // </prerequisite>
50 
51 // <synopsis>
52 // Used for reading files containing initial estimates of models for 2-D fitting.
53 // The expected format is:
54 // <ol>
55 // <li>Lines with a "#" in column 1 are treated as comments and ignored.</li>
56 // <li> Each non-comment line is treated as a complete set of six comma-delimited
57 // parameters for specifying an estimate for a component. The values are
58 // Flux (quantity), x pixel position of peak (double), y pixel position of peak (double),
59 // FWHM major axis (quantity), FWHM minor axis (quantity), position angle (measured from
60 // north to east (quantity).</li>
61 // <li> Optionally, a component estimate line can have a seventh 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: "f" flux, "x" x position, "y" y position, "a" major axis,
65 // "b" minor axis, "p" position angle. So, eg, "apx" means hold the major axis,
66 // position angle, and x position constant during the fit. </li>
67 // </ol>
68 // If the specified file passed to the constructor does not exist, an exception is thrown.
69 // Parsing is done during object construction and an exception is thrown if the file
70 // does not have the expected format.
71 // </synopsis>
72 //
73 // <example>
74 // <srcblock>
75 // FitterEstimatesFilebFileReader reader("myEstimates.txt", myImage);
76 // ComponentList cl = reader.getEstimates();
77 // casacore::Vector<casacore::String> fixed = reader.getFixed();
78 // </srcblock>
79 // </example>
80 
82  public:
83 
84  FitterEstimatesFileParser() = delete;
85 
86  // Constructor
87  // <src>filename</src> Name of file containing estimates
88  // <src>image</src> Image for which the estimates apply
89  template <class T> explicit FitterEstimatesFileParser(
90  const casacore::String& filename,
91  const casacore::ImageInterface<T>& image
92  );
93 
95 
96  // Get the estimates specified in the file as a ComponentList object.
98 
99  // Get the fixed parameter masks specified in the file.
101 
102  // Get the contents of the file
104 
105  private:
108  std::unique_ptr<casacore::LogIO> _log;
112 
113  // parse the file
114  void _parseFile(const casacore::RegularFile& myFile);
115  template <class T> void _createComponentList(
116  const casacore::ImageInterface<T>& image
117  );
118 };
119 
120 }
121 
122 #ifndef AIPS_NO_TEMPLATE_SRC
123 #include <imageanalysis/IO/FitterEstimatesFileParser2.tcc>
124 #endif
125 
126 #endif
Class for parsing a file which holds initial estimates for 2-D components. Used by imfit...
casacore::Vector< casacore::Quantity > _paValues
casacore::Vector< casacore::String > getFixed() const
Get the fixed parameter masks specified in the file.
casacore::Vector< casacore::Double > _peakValues
void _parseFile(const casacore::RegularFile &myFile)
parse the file
casacore::String getContents() const
Get the contents of the file.
A base class for astronomical images.
ComponentList getEstimates() const
Get the estimates specified in the file as a ComponentList object.
Manipulate and get information about regular files.
Definition: RegularFile.h:91
casacore::Vector< casacore::Quantity > _minValues
std::unique_ptr< casacore::LogIO > _log
casacore::Vector< casacore::String > _fixedValues
casacore::Vector< casacore::Quantity > _majValues
casacore::Vector< casacore::Double > _yposValues
void _createComponentList(const casacore::ImageInterface< T > &image)
A class for manipulating groups of components.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Vector< casacore::Double > _xposValues