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