//# Spectral2Estimate.cc: Member templates for SpectralEstimate
//# 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
//# Charlottesville, VA 22903-2475 USA
//# $Id: Spectral2Estimate.tcc 19935 2007-02-27 05:07:40Z Malte.Marquarding $
#include <components/SpectralComponents/SpectralEstimate.h>
#include <casacore/casa/BasicMath/Math.h>
#include <casacore/casa/BasicSL/Constants.h>
#include <casacore/casa/Utilities/Assert.h>
#include <components/SpectralComponents/CompiledSpectralElement.h>
#include <components/SpectralComponents/GaussianSpectralElement.h>
#include <components/SpectralComponents/PolynomialSpectralElement.h>
namespace casa { //#Begin namespace casa
const SpectralList &SpectralEstimate::estimate(const casacore::Vector<MT> &prof,
casacore::Vector<MT> *der) {
if (prof.nelements() != lprof_p) {
delete [] deriv_p; deriv_p = 0; lprof_p = 0;
lprof_p = prof.nelements();
deriv_p = new casacore::Double[lprof_p];
// Check if signal in window
if (!window(prof)) return slist_p;
windowEnd_p = casacore::min(windowEnd_p+q_p , casacore::Int(lprof_p));
windowLow_p = casacore::max(windowLow_p-q_p , 0 );
// Get the second derivatives
for (casacore::uInt i=0; i<lprof_p; i++) (*der)[i] = deriv_p[i];
// Find the estimates (sorted)
// cout << slist_p << endl;