casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id$
27 
28 #ifndef LATTICES_LATTICEFIT_H
29 #define LATTICES_LATTICEFIT_H
30 
31 #include <casacore/casa/aips.h>
35 
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 // <summary>
40 // Fit every line of pixels parallel to any axis in a Lattice.
41 // </summary>
42 
43 // <reviewed reviewer="" date="" tests="" demos="">
44 
45 // <prerequisite>
46 // <li> <linkto class=LinearFit>LinearFit</linkto>
47 // <li> <linkto class=Lattice>Lattice</linkto>
48 // </prerequisite>
49 //
50 // <synopsis>
51 
52 // For every line in the lattice parallel to axis number <src>whichAxis</src>
53 // (often axis number 2, typically the frequency axis in a spectral line cube)
54 // independently fit the functions in fitter at the positions where
55 // <src>fitMask</src> is true.
56 // </synopsis>
57 //
58 // <example>
59 // Suppose one wanted to subtract a linear polynomial from every spectrum (3d
60 // axis) in an image. One could do this as follows:
61 // <srcBlock>
62 // Image<Float> myImage("myimage"); // Get the image
63 // uInt nchan = myImage.shape()(2); // 0 relative axis number
64 // // Set up the fitter
65 // Polynomial<AutoDiff<Float> > linear(1);
66 // LinearFitSVD<Float> fitter;
67 // fitter.setFunction(linear);
68 // Vector<Float> fittedParameters,
69 //
70 // // Set up a mask indicating what channels we want to fit over. We want
71 // // to fit over all channels.
72 // Vector<Bool> fitMask(nchan); fitMask = True;
73 //
74 // // Do the fit. True means subtract the fit from the model. In this case,
75 // // We overwrite the input with the output.
76 // fitProfiles (myImage, fittedParameters,fitter, myImage, 2, fitMask, True);
77 // </srcBlock>
78 // </example>
79 //
80 // <motivation>
81 // Baseline fitting/continuum subtraction are important functions. This
82 // function essentially implements the IMLIN algorithm.
83 // </motivation>
84 //
85 // <todo asof="1995/09/01">
86 // <li> Save the model parameters in an (optional) other lattice.
87 // <li> Use logging classes, rather than the raw GlishSysEventSource.
88 // <li> Allow per-pixel weights.
89 // <li> Allow non-linear as well as linear LSQ fits.
90 // </todo>
91 
92 // <linkfrom anchor="Baseline fitting" modules="Fitting"
93 // Related <here>fitting functions</here.
94 // </linkfrom>
95 
96 class LatticeFit {
97 
98 public:
99 
100 // Fit baseline to lattice. Presently the fit parameters, other than the last
101 // one(s) in fitter, are lost. If <src>returnResiduals</src> is True,
102 // return data-fit, otherwise return the fit. For baseline and continuum
103 // subtraction, returnResiduals would normally be True.
104  static uInt fitProfiles (Lattice<Float>& outImage,
105  Vector<Float>& fittedParameters,
106  LinearFit<Float>& fitter,
107  const Lattice<Float>& inImage,
108  uInt whichAxis,
109  const Vector<Bool>& fitMask,
110  Bool returnResiduals);
111 
112 // Fit baseline to MaskedLattice. Fit and residuals can be optionally
113 // written (leave pointers at zero to not write out these lattices)
114 // You can optionally specify a weights lattice (1.0 if not given).
115  static uInt fitProfiles (MaskedLattice<Float>* pOutFit,
116  MaskedLattice<Float>* pOutResid,
118  Lattice<Float>* pSigma,
119  LinearFit<Float>& fitter,
120  uInt axis, Bool showProgress=False);
121 };
122 
123 
124 } //# NAMESPACE CASACORE - END
125 
126 #endif
Fit every line of pixels parallel to any axis in a Lattice.
Definition: LatticeFit.h:96
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.
A templated, abstract base class for array-like objects with masks.
A templated, abstract base class for array-like objects.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool False
Definition: aipstype.h:44
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42