casa
$Rev:20696$
|
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 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 // <summary> 00040 // Class for parsing a file which holds initial estimates for 2-D components. Used by imfit. 00041 // </summary> 00042 00043 // <use visibility=export> 00044 00045 // <reviewed reviewer="" date="" tests="tFitterEstimatesFileParser" 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 2-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 six comma-delimited 00058 // parameters for specifying an estimate for a component. The values are 00059 // Flux (quantity), x pixel position of peak (double), y pixel position of peak (double), 00060 // FWHM major axis (quantity), FWHM minor axis (quantity), position angle (measured from 00061 // north to east (quantity).</li> 00062 // <li> Optionally, a component estimate line can have a seventh parameter which is 00063 // a string specifying which of the parameters for that component should be held 00064 // fixed during the fit. This string can include any combination of the following 00065 // identifiers: "f" flux, "x" x position, "y" y position, "a" major axis, 00066 // "b" minor axis, "p" position angle. So, eg, "apx" means hold the major axis, 00067 // position angle, and x position constant during the fit. </li> 00068 // </ol> 00069 // If the specified file passed to the constructor does not exist, an exception is thrown. 00070 // Parsing is done during object construction and an exception is thrown if the file 00071 // does not have the expected format. 00072 // </synopsis> 00073 // 00074 // <example> 00075 // <srcblock> 00076 // FitterEstimatesFilebFileReader reader("myEstimates.txt", myImage); 00077 // ComponentList cl = reader.getEstimates(); 00078 // Vector<String> fixed = reader.getFixed(); 00079 // </srcblock> 00080 // </example> 00081 00082 class FitterEstimatesFileParser { 00083 public: 00084 00085 // Constructor 00086 // <src>filename</src> Name of file containing estimates 00087 // <src>image</src> Image for which the estimates apply 00088 explicit FitterEstimatesFileParser( 00089 const String& filename, 00090 const ImageInterface<Float>& image 00091 ); 00092 00093 ~FitterEstimatesFileParser(); 00094 00095 // Get the estimates specified in the file as a ComponentList object. 00096 ComponentList getEstimates() const; 00097 00098 // Get the fixed parameter masks specified in the file. 00099 Vector<String> getFixed() const; 00100 00101 // Get the contents of the file 00102 String getContents() const; 00103 00104 private: 00105 ComponentList _componentList; 00106 Vector<String> _fixedValues; 00107 std::auto_ptr<LogIO> _log; 00108 Vector<Double> _peakValues, _xposValues, _yposValues; 00109 //Vector<Quantity> fluxValues, majValues, minValues, paValues; 00110 Vector<Quantity> _majValues, _minValues, _paValues; 00111 String _contents; 00112 00113 // default constructor cannot be called. 00114 FitterEstimatesFileParser(); 00115 00116 // parse the file 00117 void _parseFile(const RegularFile& myFile); 00118 void _createComponentList(const ImageInterface<Float>& image); 00119 }; 00120 00121 } //# NAMESPACE CASA - END 00122 00123 #endif