//# SpectralElement.h: Describes (a set of related) spectral lines //# Copyright (C) 2001,2003,2004 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# //# $Id: SpectralElement.h 21465 2014-06-19 05:56:56Z gervandiepen $ #ifndef COMPONENTS_SPECTRALELEMENT_H #define COMPONENTS_SPECTRALELEMENT_H #include #include #include #include using namespace casacore; namespace casa { //# NAMESPACE CASA - BEGIN template class Function; // // Describes (a set of related) spectral lines // // // // // //
  • Functionals module // // // // From spectral line and element // // // // The SpectralElement class is the abstract base class for classes // describing spectral components (Gaussian, Polynonomial, etc). // // The element can be used in the // SpectralFit class and in the // SpectralEstimate class. // // // // // // // // To have a container for fitting of spectral profiles to an observed spectrum // // // //
  • add more profile types // class SpectralElement { public: //# Enumerations // Supported spectral components enum Types { // A gaussian profile GAUSSIAN, // A polynomial baseline POLYNOMIAL, // Any compiled string functional COMPILED, // Gaussian multiplet GMULTIPLET, // Lorentzian LORENTZIAN, // power log polynomial POWERLOGPOLY, // log transformed polynomial LOGTRANSPOLY, N_Types }; virtual ~SpectralElement(); virtual SpectralElement* clone() const = 0; // Evaluate the value of the element at x virtual casacore::Double operator()(const casacore::Double x) const; casacore::Bool operator==(const SpectralElement& other) const; // Get parameter n // //
  • AipsError if illegal n // virtual casacore::Double operator[](const uInt n) const; // Get all the types available as casacore::String and codes, and number available static const casacore::String* allTypes(Int &nall, const SpectralElement::Types *&typ); // Get a string from the type static const casacore::String &fromType(SpectralElement::Types tp); // Get a type from a (non-case sensitive; minimum match) casacore::String static casacore::Bool toType(SpectralElement::Types &tp, const casacore::String &typName); // Get type of this element SpectralElement::Types getType() const { return _type; } // Get all parameters void get(casacore::Vector& params) const; casacore::Vector get() const; // Get error estimates of parameters void getError(casacore::Vector &err) const; casacore::Vector getError() const; // Get the order (i.e. the number of parameters) uInt getOrder() const { return _params.size(); }; // Set the error fields virtual void setError(const casacore::Vector &err); // Set fixed parameters (True) or unset them (False) // //
  • AipsError if incorrect number of parameters (e.g. not 3 for GAUSSIAN) // // Fix/unfix all in one go virtual void fix(const casacore::Vector& fix); // Get the fix state[s] const casacore::Vector &fixed() const; // Save to a record. virtual casacore::Bool toRecord(RecordInterface& out) const; // set parameters virtual void set(const casacore::Vector& params); protected: SpectralElement() {} SpectralElement(Types type, const casacore::Vector& parms=casacore::Vector(0)); SpectralElement(const SpectralElement& other); SpectralElement &operator=(const SpectralElement& other); void _set(const casacore::Vector& params); void _setType(const Types type); void _setFunction(const SHARED_PTR >& f); virtual SHARED_PTR > _getFunction() const { return _function; } private: //#Data // type of element Types _type; // The parameters of the function. I.e. the polynomial coefficients; // amplitude, center and sigma of a Gaussian. casacore::Vector _params; // The errors of the parameters casacore::Vector _errors; // The indication if the parameter has to be fixed (True) or solved (False). // Solved is the default. casacore::Vector _fixed; SHARED_PTR > _function; }; ostream &operator<<(ostream& os, const SpectralElement& elem); casacore::Bool near(const SpectralElement& s1, const SpectralElement& s2, const casacore::Double tol); casacore::Bool nearAbs(const SpectralElement& s1, const SpectralElement& s2, const casacore::Double tol); } //# NAMESPACE CASA - END #endif