casacore
Loading...
Searching...
No Matches
LatticeFit.h
Go to the documentation of this file.
1//# LatticeFit.h: Fit every line of pixels parallel to any axis in a Lattice.
2//# Copyright (C) 1994,1995,1999,2000,2002
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef LATTICES_LATTICEFIT_H
27#define LATTICES_LATTICEFIT_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/lattices/Lattices/Lattice.h>
31#include <casacore/lattices/Lattices/MaskedLattice.h>
32#include <casacore/scimath/Fitting/LinearFit.h>
33
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37// <summary>
38// Fit every line of pixels parallel to any axis in a Lattice.
39// </summary>
40
41// <reviewed reviewer="" date="" tests="" demos="">
42
43// <prerequisite>
44// <li> <linkto class=LinearFit>LinearFit</linkto>
45// <li> <linkto class=Lattice>Lattice</linkto>
46// </prerequisite>
47//
48// <synopsis>
49
50// For every line in the lattice parallel to axis number <src>whichAxis</src>
51// (often axis number 2, typically the frequency axis in a spectral line cube)
52// independently fit the functions in fitter at the positions where
53// <src>fitMask</src> is true.
54// </synopsis>
55//
56// <example>
57// Suppose one wanted to subtract a linear polynomial from every spectrum (3d
58// axis) in an image. One could do this as follows:
59// <srcBlock>
60// Image<Float> myImage("myimage"); // Get the image
61// uInt nchan = myImage.shape()(2); // 0 relative axis number
62// // Set up the fitter
63// Polynomial<AutoDiff<Float> > linear(1);
64// LinearFitSVD<Float> fitter;
65// fitter.setFunction(linear);
66// Vector<Float> fittedParameters,
67//
68// // Set up a mask indicating what channels we want to fit over. We want
69// // to fit over all channels.
70// Vector<Bool> fitMask(nchan); fitMask = True;
71//
72// // Do the fit. True means subtract the fit from the model. In this case,
73// // We overwrite the input with the output.
74// fitProfiles (myImage, fittedParameters,fitter, myImage, 2, fitMask, True);
75// </srcBlock>
76// </example>
77//
78// <motivation>
79// Baseline fitting/continuum subtraction are important functions. This
80// function essentially implements the IMLIN algorithm.
81// </motivation>
82//
83// <todo asof="1995/09/01">
84// <li> Save the model parameters in an (optional) other lattice.
85// <li> Use logging classes, rather than the raw GlishSysEventSource.
86// <li> Allow per-pixel weights.
87// <li> Allow non-linear as well as linear LSQ fits.
88// </todo>
89
90// <linkfrom anchor="Baseline fitting" modules="Fitting"
91// Related <here>fitting functions</here.
92// </linkfrom>
93
95
96public:
97
98// Fit baseline to lattice. Presently the fit parameters, other than the last
99// one(s) in fitter, are lost. If <src>returnResiduals</src> is True,
100// return data-fit, otherwise return the fit. For baseline and continuum
101// subtraction, returnResiduals would normally be True.
102 static uInt fitProfiles (Lattice<Float>& outImage,
103 Vector<Float>& fittedParameters,
104 LinearFit<Float>& fitter,
105 const Lattice<Float>& inImage,
106 uInt whichAxis,
107 const Vector<Bool>& fitMask,
108 Bool returnResiduals);
109
110// Fit baseline to MaskedLattice. Fit and residuals can be optionally
111// written (leave pointers at zero to not write out these lattices)
112// You can optionally specify a weights lattice (1.0 if not given).
114 MaskedLattice<Float>* pOutResid,
116 Lattice<Float>* pSigma,
117 LinearFit<Float>& fitter,
118 uInt axis, Bool showProgress=False);
119};
120
121
122} //# NAMESPACE CASACORE - END
123
124#endif
static uInt fitProfiles(Lattice< Float > &outImage, Vector< Float > &fittedParameters, LinearFit< Float > &fitter, const Lattice< Float > &inImage, uInt whichAxis, const Vector< Bool > &fitMask, Bool returnResiduals)
Fit baseline to lattice.
static uInt fitProfiles(MaskedLattice< Float > *pOutFit, MaskedLattice< Float > *pOutResid, MaskedLattice< Float > &in, Lattice< Float > *pSigma, LinearFit< Float > &fitter, uInt axis, Bool showProgress=False)
Fit baseline to MaskedLattice.
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40