FitterEstimatesFileParser.h

Go to the documentation of this file.
00001 //# RegularFileIO.h: Class for IO on a regular file
00002 //# Copyright (C) 1996,1997,1999,2002
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id:  $
00027 
00028 #ifndef CASA_FITTERESTIMATESFILEPARSER_H
00029 #define CASA_FITTERESTIMATESFILEPARSER_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <casa/OS/RegularFile.h>
00034 #include <components/ComponentModels/ComponentList.h>
00035 #include <images/Images/ImageInterface.h>
00036 #include <memory>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 // <summary> 
00041 // Class for parsing a file which holds initial estimates for 2-D components. Used by imfit.
00042 // </summary>
00043 
00044 // <use visibility=export>
00045 
00046 // <reviewed reviewer="" date="" tests="tFitterEstimatesFileParser" demos="">
00047 // </reviewed>
00048 
00049 // <prerequisite> 
00050 //    <li> <linkto class=RegularFilebufIO>FilebufIO</linkto> class
00051 // </prerequisite>
00052 
00053 // <synopsis> 
00054 // Used for reading files containing initial estimates of models for 2-D fitting.
00055 // The expected format is:
00056 // <ol>
00057 // <li>Lines with a "#" in column 1 are treated as comments and ignored.</li>
00058 // <li> Each non-comment line is treated as a complete set of six comma-delimited
00059 //      parameters for specifying an estimate for a component. The values are
00060 //      Flux (quantity), x pixel position of peak (double), y pixel position of peak (double),
00061 //      FWHM major axis (quantity), FWHM minor axis (quantity), position angle (measured from
00062 //      north to east (quantity).</li>
00063 // <li> Optionally, a component estimate line can have a seventh parameter which is
00064 //      a string specifying which of the parameters for that component should be held
00065 //      fixed during the fit. This string can include any combination of the following
00066 //      identifiers: "f" flux, "x" x position, "y" y position, "a" major axis,
00067 //      "b" minor axis, "p" position angle. So, eg, "apx" means hold the major axis,
00068 //      position angle, and x position constant during the fit. </li>
00069 // </ol>
00070 // If the specified file passed to the constructor does not exist, an exception is thrown.
00071 // Parsing is done during object construction and an exception is thrown if the file
00072 // does not have the expected format.
00073 // </synopsis>
00074 //
00075 // <example>
00076 // <srcblock>
00077 //   FitterEstimatesFilebFileReader reader("myEstimates.txt", myImage);
00078 //   ComponentList cl = reader.getEstimates();
00079 //   Vector<String> fixed = reader.getFixed();
00080 // </srcblock>
00081 // </example>
00082 
00083 class FitterEstimatesFileParser {
00084         public:
00085 
00086                 // Constructor
00087                 // <src>filename</src> Name of file containing estimates
00088                 // <src>image</src> Image for which the estimates apply
00089                 explicit FitterEstimatesFileParser(
00090                         const String& filename,
00091                         const ImageInterface<Float>& image
00092                 );
00093 
00094                 ~FitterEstimatesFileParser();
00095 
00096                 // Get the estimates specified in the file as a ComponentList object.
00097                 ComponentList getEstimates() const;
00098 
00099                 // Get the fixed parameter masks specified in the file.
00100                 Vector<String> getFixed() const;
00101 
00102                 // Get the contents of the file
00103                 String getContents() const;
00104 
00105         private:
00106                 ComponentList _componentList;
00107                 Vector<String> _fixedValues;
00108                 std::unique_ptr<LogIO> _log;
00109                 Vector<Double> _peakValues, _xposValues, _yposValues;
00110                 //Vector<Quantity> fluxValues, majValues, minValues, paValues;
00111                 Vector<Quantity> _majValues, _minValues, _paValues;
00112                 String _contents;
00113 
00114                 // default constructor cannot be called.
00115                 FitterEstimatesFileParser();
00116 
00117                 // parse the file
00118                 void _parseFile(const RegularFile& myFile);
00119                 void _createComponentList(const ImageInterface<Float>& image);
00120 };
00121 
00122 } //# NAMESPACE CASA - END
00123 
00124 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1