Loading...
Searching...
No Matches
casacore::LatticeFit Class Reference
lattices package (libcasa_lattices) » LatticeMath_module

More...

`#include <LatticeFit.h>`

## Static Public Member Functions

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.

## Detailed Description

Fit every line of pixels parallel to any axis in a Lattice.

### Prerequisite

- LinearFit
- Lattice

### Synopsis

For every line in the lattice parallel to axis number whichAxis (often axis number 2, typically the frequency axis in a spectral line cube) independently fit the functions in fitter at the positions where fitMask is true.

### Example

Suppose one wanted to subtract a linear polynomial from every spectrum (3d axis) in an image. One could do this as follows:

Image<Float> myImage("myimage"); // Get the image
uInt nchan = myImage.shape()(2); // 0 relative axis number
// Set up the fitter
Polynomial<AutoDiff<Float> > linear(1);
LinearFitSVD<Float> fitter;
fitter.setFunction(linear);
Vector<Float> fittedParameters,
// Set up a mask indicating what channels we want to fit over. We want
// to fit over all channels.
Vector<Bool> fitMask(nchan); fitMask = True;
// Do the fit. True means subtract the fit from the model. In this case,
// We overwrite the input with the output.
fitProfiles (myImage, fittedParameters,fitter, myImage, 2, fitMask, True);
casacore::GenericL2Fit::setFunction
void setFunction(const Function< U, U > &function)
Sets the function to be fitted.
Definition GenericL2Fit.h:238
casacore::LatticeFit::fitProfiles
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.
casacore::LinearFitSVD
Definition LinearFitSVD.h:71
casacore::Vector
Definition Vector.h:82
casacore::Polynomial
Polynomial()
Definition Polynomial.h:94
casacore::uInt
unsigned int uInt
Definition aipstype.h:49
casacore::True
const Bool True
Definition aipstype.h:41

### Motivation

Baseline fitting/continuum subtraction are important functions. This function essentially implements the IMLIN algorithm.

### To Do

- Save the model parameters in an (optional) other lattice.
- Use logging classes, rather than the raw GlishSysEventSource.
- Allow per-pixel weights.
- Allow non-linear as well as linear LSQ fits.

Definition at line 94 of file LatticeFit.h.

## Member Function Documentation

## fitProfiles() [1/2]

uInt casacore::LatticeFit::fitProfiles | ( | Lattice< Float > & | outImage,
|  | Vector< Float > & | fittedParameters,
|  | LinearFit< Float > & | fitter,
|  | const Lattice< Float > & | inImage,
|  | uInt | whichAxis,
|  | const Vector< Bool > & | fitMask,
|  | Bool | returnResiduals )

static

Fit baseline to lattice.

Presently the fit parameters, other than the last one(s) in fitter, are lost. If returnResiduals is True, return data-fit, otherwise return the fit. For baseline and continuum subtraction, returnResiduals would normally be True.

## fitProfiles() [2/2]

uInt casacore::LatticeFit::fitProfiles | ( | MaskedLattice< Float > * | pOutFit,
|  | MaskedLattice< Float > * | pOutResid,
|  | MaskedLattice< Float > & | in,
|  | Lattice< Float > * | pSigma,
|  | LinearFit< Float > & | fitter,
|  | uInt | axis,
|  | Bool | showProgress = False )

static

Fit baseline to MaskedLattice.

Fit and residuals can be optionally written (leave pointers at zero to not write out these lattices) You can optionally specify a weights lattice (1.0 if not given).

References casacore::False.

The documentation for this class was generated from the following file:

- lattices/LatticeMath/LatticeFit.h