00001 //# SpectralElement.h: Describes (a set of related) spectral lines 00002 //# Copyright (C) 2001,2003,2004 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 //# 00027 00028 #ifndef COMPONENTS_GAUSSIANSPECTRALELEMENT_H 00029 #define COMPONENTS_GAUSSIANSPECTRALELEMENT_H 00030 00031 #include <components/SpectralComponents/PCFSpectralElement.h> 00032 00033 namespace casa { 00034 00035 // <summary> 00036 // Describes a Gaussian spectral line 00037 // </summary> 00038 00039 // <use visibility=export> 00040 00041 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tSpectralFit" demos=""> 00042 // </reviewed> 00043 00044 // <prerequisite> 00045 // <li> <linkto module=SpectralElement>SpectralElement</linkto> module 00046 // </prerequisite> 00047 // 00048 // <etymology> 00049 // From Gaussian and spectral line and element 00050 // </etymology> 00051 // 00052 // <synopsis> 00053 // The GaussianSpectralElement class describes a Gaussian spectral line. 00054 00055 // </synopsis> 00056 // 00057 // <example> 00058 // </example> 00059 // 00060 // <motivation> 00061 // To have a container for data descrbing a Gaussian spectral profile for fitting to an observed spectrum 00062 // </motivation> 00063 00064 class GaussianSpectralElement : public PCFSpectralElement { 00065 00066 public: 00067 00068 // Default constructor creates a default Gaussian element with an amplitude 00069 // of 1; an integral <src>(sigma=2sqrt(ln2)/pi)</src> of 1; 00070 // a central frequency of zero. It's necessary for this to be public because 00071 // Arrays of this class require access to the default constructor. It should never 00072 // be used in code developers write though. 00073 GaussianSpectralElement(); 00074 00075 00076 //# Constants 00077 // Sigma to FWHM conversion factor 00078 static const Double SigmaToFWHM; 00079 00080 //# Constructors 00081 00082 // Construct with given type and values 00083 // <thrown> 00084 // <li> AipsError if sigma == 0.0 00085 // <li> AipsError if type not GAUSSIAN 00086 // </thrown> 00087 GaussianSpectralElement( 00088 const Double ampl, const Double center, 00089 const Double sigma 00090 ); 00091 00092 // Construct the given tp with the given param 00093 // <thrown> 00094 // <li> AipsError if incorrect number of parameters (e.g. not 3 for GAUSSIAN) 00095 // <li> AipsError if sigma == 0.0 00096 // </thrown> 00097 GaussianSpectralElement(const Vector<Double> ¶m); 00098 // Copy constructor (deep copy) 00099 // <thrown> 00100 // <li> AipsError if sigma == 0.0 00101 // </thrown> 00102 GaussianSpectralElement(const GaussianSpectralElement &other); 00103 00104 //#Destructor 00105 // Destructor 00106 ~GaussianSpectralElement(); 00107 00108 SpectralElement* clone() const; 00109 00110 // Assignment (copy semantics) 00111 // <thrown> 00112 // <li> AipsError if sigma == 0.0 00113 // </thrown> 00114 // GaussianSpectralElement& operator=(const GaussianSpectralElement &other); 00115 // Evaluate the value of the element at x 00116 //Double operator()(const Double x) const; 00117 00118 Double getSigma() const; 00119 Double getFWHM() const; 00120 00121 Double getSigmaErr() const; 00122 Double getFWHMErr() const; 00123 00124 00125 void setSigma(Double sigma); 00126 void setFWHM(Double fwhm); 00127 00128 void fixSigma(const Bool fix=True); 00129 00130 Bool fixedSigma() const; 00131 00132 Double getIntegral() const; 00133 00134 // Save to a record. For Gaussian elements, 00135 // the width is defined as a FWHM in the record interface. 00136 Bool toRecord(RecordInterface &out) const; 00137 00138 // Sigma to FWHM 00139 // Convert from sigma to FWHM and vice versa 00140 // <group> 00141 static Double sigmaFromFWHM (const Double fwhm); 00142 00143 static Double sigmaToFWHM (const Double sigma); 00144 // </group> 00145 00146 void set(const Vector<Double>& v); 00147 00148 private: 00149 // need to overrride SpectralElement::_set() because _param[2] is sigma 00150 // but the second param of the corresponding Gaussian1D function is the 00151 // FWHM :( 00152 void _set(const Vector<Double>& v); 00153 00154 }; 00155 00156 ostream &operator<<(ostream& os, const GaussianSpectralElement& elem); 00157 00158 00159 } //# NAMESPACE CASA - END 00160 00161 #endif