//# SpectralEstimate.h: Get an initial estimate for spectral lines //# Copyright (C) 2001,2002,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: SpectralEstimate.h 21229 2012-04-02 12:00:20Z gervandiepen $ #ifndef COMPONENTS_SPECTRALESTIMATE_H #define COMPONENTS_SPECTRALESTIMATE_H #include #include #include namespace casa { //# NAMESPACE CASA - BEGIN //# Forward Declarations class GaussianSpectralElement; template class Vector; // // Get an initial estimate for spectral lines // // // // // //
  • SpectralFit class // // // // From spectral line and estimate // // // // The SpectralEstimate class obtains an initial guess for spectral // components. The current implementation uses the entire // profile as signal region, or can set a window to be searched around // the highest peak automatically. A window can also be set manually. // The second derivative of // the profile in the signal region is calculated by fitting // a second degree polynomal. The smoothing parameter Q // determines the number of points used for this (=2*Q+1). // The gaussians can then be estimated as described by // Schwarz, 1968, Bull.Astr.Inst.Netherlands, Volume 19, 405. // // The elements guessed can be used in the // SpectralFit class. // // The default type found is a Gaussian, defined as: // // AMPL.exp[ -(x-CENTER)2/2 SIGMA2] // // // The parameter estimates are returned in units of zero-based // pixel indices. // // // // // // // To have an automatic method to find spectral lines // // // //
  • find a way to get to absorption lines as well //
  • add more estimation options // class SpectralEstimate { public: //# Constants // Default maximum number of components to be found static const uInt MAXPAR = 200; //# Enumerations //# Friends //# Constructors // Default constructor creates a default estimator (default max number // of components to be found is 200) with the given maximum number // of components that will be found. A value of zero will indicate // an unlimited number. explicit SpectralEstimate(const uInt maxpar=MAXPAR); // Create an estimator with the given maximum number of possible // elements. A value of zero will indicate an unlimited number. // Construct with a given rms in profiles, a cutoff for amplitudes // found, and a minimum width. Cutoff and minsigma default to 0.0, maximum // size of list produced to 200. explicit SpectralEstimate(const Double rms, const Double cutoff=0.0, const Double minsigma=0.0, const uInt maxpar=MAXPAR); // Copy constructor (deep copy) SpectralEstimate(const SpectralEstimate &other); //#Destructor // Destructor ~SpectralEstimate(); //# Operators // Assignment (copy semantics) SpectralEstimate &operator=(const SpectralEstimate &other); //# Member functions // Generate the estimates for a profile and return the // list found. The first function returns component parameters // in units of pixel indices. The second function calls the first // and then converts to the specified abcissa space (the supplied // vector must be monotonic); if the pixel-based center is out of range // of the supplied abcissa vector the conversion is done via extrapolation. // The der pointer is meant for debugging, and can return // the derivative profile. The second function throws an AipsError // if the vectors are not the same length. // template const SpectralList& estimate(const Vector& ordinate, Vector *der = 0); template const SpectralList& estimate(const Vector& abcissa, const Vector& ordinate); // // Return the list found. const SpectralList &list() const {return slist_p; }; // Set estimation parameters // // Set the profile's estimated rms (forced to abs(rms)) void setRMS(const Double rms=0.0); // Set the amplitude cutoff for valid estimate (forced to max(0,cutoff)) void setCutoff(const Double cutoff=0.0); // Set the minimum width allowed (forced to max(0,minsigma)) void setMinSigma(const Double minsigma=0.0); // Set the number of points consider at each side of test point (i.e. a // width of 2q+1 is taken). Default internally is 2; max(1,q) taken. void setQ(const uInt q=2); // Set a region [lo,hi] over which to estimate. Lo and hi are given as // zero-based vector indices. void setRegion(const Int lo, const Int hi); // Do you want to look in an automatically determined window with signal? // Default is False, meaning the full (possibly regioned) profile. void setWindowing(const Bool win=False); // Set the maximum number of estimates to find (forced to >=1; 200 default) void setMaxN(const uInt maxpar=MAXPAR); // private: //#Data // Use window search Bool useWindow_p; // rms estimate in profile Double rms_p; // Source cutoff amplitude Double cutoff_p; // Window low and end value // Int windowLow_p; Int windowEnd_p; // // Region low and high value // Int regionLow_p; Int regionEnd_p; // // Smoothing parameter. I.e. 2q+1 points are taken Int q_p; // Internal cashing of calculated values based on q // Double a_p; Double b_p; // // The minimum Gaussian width Double sigmin_p; // The second derivatives Double *deriv_p; // The list of components SpectralList slist_p; // The length of the current profile being estimated uInt lprof_p; //# Member functions // Get the window or the total spectrum template uInt window(const Vector &prof); // Get the second derivatives template void findc2(const Vector &prof); // Find the Gaussians template void findga(const Vector &prof); // Convert the parameters of the components in the list from // pixel-based indices to the given abcissa-vector space. template GaussianSpectralElement convertElement (const Vector& abcissa, const GaussianSpectralElement& el) const; }; } //# NAMESPACE CASA - END #ifndef CASACORE_NO_AUTO_TEMPLATES #include #endif //# CASACORE_NO_AUTO_TEMPLATES #endif