GaussianMultipletSpectralElement.h

Go to the documentation of this file.
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 //# $Id: SpectralElement.h 20652 2009-07-06 05:04:32Z Malte.Marquarding $
00028 
00029 #ifndef COMPONENTS_GAUSSIANMULTIPLETSPECTRALELEMENT_H
00030 #define COMPONENTS_GAUSSIANMULTIPLETSPECTRALELEMENT_H
00031 
00032 #include <casa/Arrays/Matrix.h>
00033 #include <components/SpectralComponents/CompiledSpectralElement.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037         class GaussianSpectralElement;
00038 
00039 // <summary>
00040 // Describes a multiplet of Gaussian shaped spectral lines
00041 // </summary>
00042 
00043 // <use visibility=export>
00044 
00045 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tSpectralFit" demos="">
00046 // </reviewed>
00047 
00048 // <prerequisite>
00049 //   <li> <linkto module=SpectralElement>SpectralElement</linkto> module
00050 //   <li> <linkto module=GaussianSpectralElement>CompiledSpectralElement</linkto> module
00051 //   <li> <linkto module=CompiledSpectralElement>CompiledSpectralElement</linkto> module
00052 // </prerequisite>
00053 //
00054 // <etymology>
00055 // From Gaussian and multiplet and spectral line and element
00056 // </etymology>
00057 //
00058 // <synopsis>
00059 // The GaussianMultipletSpectralElement class describes a multiplet
00060 // of Gaussian shaped spectral lines for describing spectral profile.
00061 //
00062 // Relationships between Gaussians in the multiplet must be specified.
00063 // Any combination of one or more of fixed relationships between line
00064 // center offsets, line amplitude ratios, and/or line width ratios can
00065 // be specified between a single reference line in the multiplet and
00066 // other (non-reference) lines in the multiplet. The constructor
00067 // takes a Vector of GaussianSpectralElements which describes the estimates
00068 // of the n Gaussians in the multiplet. These objects themselves are not
00069 // used in the fitting, but are used only to create the function that describes
00070 // the multiplet. The first element in this Vector represents the reference line
00071 // to which parameters of the other lines are constrained. In addition, the
00072 // constructor takes an n-1 x 3 Matrix<Double> describing the fixed relationships
00073 // between the reference line and the other lines in the multiplet. Each ith row
00074 // describes the fixed relationship(s) between the (i+1)th and the zeroth
00075 // (reference) Gaussian. The first element of each row describes the ratio of
00076 // amplitudes between the (i+1)th and reference Gaussian, the second element
00077 // describes the difference between the center locations of the (i+1)th and
00078 // reference Gaussian, and the third represents the ratio of the FWHM of the
00079 // (i+1)th and reference Gaussian. A value of 0 for any of these indicates there
00080 // is no fixed relationship for that parameter. At least one value must be non-zero
00081 // for each row and any combination of elements (including all of them) can be
00082 // non-zero for any row in this matrix. The values of parameters of non-reference
00083 // lines in the input vector that are constrained to the reference line are
00084 // implicitly ignored and set in the constructor according to the specified
00085 // constraint. If any of the parameters of the reference line are specified as
00086 // fixed, the corresponding parameters of any non-reference lines which have the
00087 // corresponding parameters constrained to the reference line are also implicitly
00088 // fixed. Fixing a parameter in a non-reference line that is constrained to the
00089 // corresponding parameter of the reference line that is not fixed will cause an
00090 // exception.
00091 // </synopsis>
00092 //
00093 // <example>
00094 // This is how to specify a doublet in which the only constraint is that the amplitudes
00095 // between the lines must be fixed, the first Gaussian must have an ampliute of 0.6 times
00096 // the zeroth (reference) Gaussian. Other than that, all other parameters can
00097 // vary during the fit:
00098 
00099 // GaussianSpectralElement reference(5, 25, 16);
00100 // // The amplitude value of first is ignored because of the relationship to the
00101 // // reference, but it still must be specified in the constructor and must be
00102 // // non-zero or an exception will be thrown.
00103 // GaussianSpectralElement first(1, 40, 17);
00104 // Vector<GaussianSpectralElement> pair(2);
00105 // pair[0] = reference;
00106 // pair[1] = first;
00107 // // initialize constraints matrix to have nothing constrained (all values 0)
00108 // Matrix<Double> fixedRel(1, 3, 0);
00109 // // Set the ratio of amplitudes between the first and reference (zeroth) line
00110 // // to be 0.6.
00111 // fixedRel[0][0] = 0.6
00112 // GaussianMultipletSpectralElement doublet(pair,"",fixedRel);
00113 // </example>
00114 //
00115 // <motivation>
00116 // To allow specifying constraints between different Gaussian spectral
00117 // lines for fitting, eg to support fitting of doublets.
00118 // </motivation>
00119 
00120 class GaussianMultipletSpectralElement: public CompiledSpectralElement {
00121 public:
00122 
00123         // Construct a Gaussian multiplet. The values of non-reference (non-zeroth)
00124         // estimates will be automatically adjusted if there is a fixed relationship
00125         // between a non-reference Gaussian parameter and the corresponding reference
00126         // Gaussian parameter.
00127         GaussianMultipletSpectralElement(
00128                 const vector<GaussianSpectralElement>& estimates,
00129                 const Matrix<Double>& fixedRelationships
00130         );
00131 
00132         // copy semantics
00133         GaussianMultipletSpectralElement(
00134                 const GaussianMultipletSpectralElement& other
00135         );
00136 
00137         ~GaussianMultipletSpectralElement();
00138 
00139         SpectralElement* clone() const;
00140 
00141         // copy semantics
00142         GaussianMultipletSpectralElement &operator=(
00143                 const GaussianMultipletSpectralElement& other
00144         );
00145 
00146         Bool operator==(
00147                 const GaussianMultipletSpectralElement& other
00148         ) const;
00149 
00150         // get the gaussians
00151         const vector<GaussianSpectralElement>& getGaussians() const;
00152 
00153         // get the constraints matrix
00154         const Matrix<Double>& getConstraints() const;
00155 
00156         //<group>
00157         // These methods must be public because the architecture of
00158         // the class hierarchy requires it and set() and setError()
00159         // must be accessible by fitters. However, it is strongly
00160         // recommended that other classes not call these methods for
00161         // object configuration but rather set them implicitly at
00162         // construction via the Vector<GaussianSpectralElement>
00163         // passed to the constructor.
00164         void set(const Vector<Double>& param);
00165 
00166         void setError(const Vector<Double> &err);
00167 
00168         void fix(const Vector<Bool>& fix);
00169         // </group>
00170         // Save to a record.
00171         Bool toRecord(RecordInterface& out) const;
00172 
00173 private:
00174         vector<GaussianSpectralElement> _gaussians;
00175         Matrix<Double> _constraints;
00176         Matrix<uInt> _paramIndices;
00177 };
00178 
00179 ostream &operator<<(ostream &os, const GaussianMultipletSpectralElement &elem);
00180 
00181 } //# NAMESPACE CASA - END
00182 
00183 #endif
00184 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1