casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MomentWindow.h
Go to the documentation of this file.
1 //# MomentWindow.h:
2 //# Copyright (C) 1997,1999,2000,2001,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: MomentCalculator.h 20299 2008-04-03 05:56:44Z gervandiepen $
27 
28 #ifndef IMAGEANALYSIS_MOMENTWINDOW_H
29 #define IMAGEANALYSIS_MOMENTWINDOW_H
30 
31 #include <casa/aips.h>
37 #include <casa/Arrays/Vector.h>
38 #include <casa/Logging/LogIO.h>
39 
40 namespace casa {
41 
42 template <class T> class MomentsBase;
43 
44 // <summary> Computes moments from a windowed profile </summary>
45 // <use visibility=export>
46 //
47 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
48 // </reviewed>
49 //
50 // <prerequisite>
51 // <li> <linkto class="MomentsBase">MomentsBase</linkto>
52 // <li> <linkto class="ImageMoments">ImageMoments</linkto>
53 // <li> <linkto class="MSMoments">MSMoments</linkto>
54 // <li> <linkto class="casacore::LatticeApply">casacore::LatticeApply</linkto>
55 // <li> <linkto class="MomentCalcBase">MomentCalcBase</linkto>
56 // <li> <linkto class="casacore::LineCollapser">casacore::LineCollapser</linkto>
57 // </prerequisite>
58 //
59 // <synopsis>
60 // This concrete class is derived from the abstract base class MomentCalcBase
61 // which provides an interface layer to the ImageMoments or MSMoments driver class.
62 // ImageMoments or MSMoments creates a MomentWindow object and passes it to the LatticeApply
63 // function lineMultiApply. This function iterates through a given lattice,
64 // and invokes the <src>multiProcess</src> member function of MomentWindow on each profile
65 // of pixels that it extracts from the input lattice. The <src>multiProcess</src> function
66 // returns a vector of moments which are inserted into the output lattices also
67 // supplied to the casacore::LatticeApply function.
68 //
69 // MomentWindow computes moments from a subset of the pixels selected from the
70 // input profile. This subset is a simple index range, or window. The window is
71 // selected, for each profile, that is thought to surround the spectral feature
72 // of interest. This window can be found from the primary lattice, or from an
73 // ancilliary lattice (ImageMoments or MSMoments offers a smoothed version of the primary
74 // lattice as the ancilliary lattice). The moments are always computed from
75 // primary lattice data.
76 //
77 // For each profile, the window can be found either interactively or automatically.
78 // There are two interactive methods. Either you just mark the window with the
79 // cursor, or you interactively fit a Gaussian to the profile and the +/- 3-sigma
80 // window is returned. There are two automatic methods. Either Bosma's converging
81 // mean algorithm is used, or an automatically fit Gaussian +/- 3-sigma window
82 // is returned.
83 //
84 // The constructor takes an MomentsBase object that is actually an ImageMoments or
85 // an MSMoments object; the one that is constructing
86 // the MomentWindow object of course. There is much control information embodied
87 // in the state of the ImageMoments or MSMoments object. This information is extracted by the
88 // MomentCalcBase class and passed on to MomentWindow for consumption.
89 //
90 // Note that the ancilliary lattice is only accessed if the pointer to it
91 // is non zero.
92 //
93 // See the <linkto class="MomentsBase">MomentsBase</linkto>,
94 // <linkto class="ImageMoments">ImageMoments</linkto>, and
95 // <linkto class="MSMoments">MSMoments</linkto>
96 // for discussion about the moments that are available for computation.
97 //
98 // </synopsis>
99 //
100 // <example>
101 // This example comes from ImageMoments. outPt is a pointer block holding
102 // pointers to the output lattices. The ancilliary masking lattice is
103 // just a smoothed version of the input lattice. os_P is a casacore::LogIO object.
104 //
105 // <srcBlock>
106 //
109 //
110 // MomentCalcBase<T>* pMomentCalculator = 0;
111 // if (clipMethod || smoothClipMethod) {
112 // pMomentCalculator = new MomentClip<T>(pSmoothedImage, *this, os_p, outPt.nelements());
113 // } else if (windowMethod) {
114 // pMomentCalculator = new MomentWindow<T>(pSmoothedImage, *this, os_p, outPt.nelements());
115 // } else if (fitMethod) {
116 // pMomentCalculator = new MomentFit<T>(*this, os_p, outPt.nelements());
117 // }
118 //
120 //
121 // casacore::LatticeApply<T>::lineMultiApply(outPt, *pInImage_p, *pMomentCalculator,
122 // momentAxis_p, pProgressMeter);
123 // delete pMomentCalculator;
124 //
125 // </srcBlock>
126 // </example>
127 //
128 // <motivation>
129 // </motivation>
130 //
131 // <note role=tip>
132 // Note that there are is assignment operator or copy constructor.
133 // Do not use the ones the system would generate either.
134 // </note>
135 //
136 // <todo asof="yyyy/mm/dd">
137 // </todo>
138 
139 
140 template <class T> class MomentWindow : public MomentCalcBase<T>
141 {
142 public:
146 
147 // Constructor. The pointer is to a lattice containing the masking
148 // lattice (created by ImageMoments or MSMoments). We also need the
149 // ImageMoments or MSMoments object which is calling us, its logger,
150 // and the number of output lattices it has created.
151  MomentWindow(shared_ptr<casacore::Lattice<T>> pAncilliaryLattice,
152  MomentsBase<T>& iMom,
153  casacore::LogIO& os,
154  const casacore::uInt nLatticeOut);
155 
156 // Destructor (does nothing).
157  ~MomentWindow();
158 
159 // This function is not implemented and throws an exception.
160  virtual void process(T& out,
161  casacore::Bool& outMask,
162  const casacore::Vector<T>& in,
163  const casacore::Vector<casacore::Bool>& inMask,
164  const casacore::IPosition& pos);
165 
166 // This function returns a vector of numbers from each input vector.
167 // the output vector contains the moments known to the ImageMoments
168 // or MSMoments object passed into the constructor.
169  virtual void multiProcess(casacore::Vector<T>& out,
171  const casacore::Vector<T>& in,
172  const casacore::Vector<casacore::Bool>& inMask,
173  const casacore::IPosition& pos);
174 
175 
176 private:
177 
178  shared_ptr<casacore::Lattice<T>> _ancilliaryLattice;
181 
188 
189 // Automatically determine the spectral window
192  const casacore::Vector<T>& x,
193  const casacore::Vector<T>& y,
195  const T peakSNR,
196  const T stdDeviation,
197  const casacore::Bool doFit) const;
198 
199  // Automatically determine the spectral window via Bosma's algorithm
203  const T stdDeviation
204  ) const;
205 
206 // Take the fitted Gaussian parameters and set an N-sigma window.
207 // If the window is too small return a Fail condition.
209  const T pos,
210  const T width,
211  const casacore::Int nPts,
212  const casacore::Int N) const;
213 
214 
215  //# Make members of parent class known.
216 protected:
219  //using MomentCalcBase<T>::convertF;
236 };
237 
238 }
239 
240 #ifndef CASACORE_NO_AUTO_TEMPLATES
241 #include <imageanalysis/ImageAnalysis/MomentWindow.tcc>
242 #endif
243 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
MIRIAD dataset casacore::MeasurementSet filler.
Definition: Importmiriad.h:132
virtual void multiProcess(casacore::Vector< T > &out, casacore::Vector< casacore::Bool > &outMask, const casacore::Vector< T > &in, const casacore::Vector< casacore::Bool > &inMask, const casacore::IPosition &pos)
This function returns a vector of numbers from each input vector.
casacore::Bool doFit_p
Definition: MomentWindow.h:186
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
This class is a base class for generating moments from an image or a spectral data.
T & stdDeviation(MomentsBase< T > &iMom) const
Return standard deviation of image from ImageMoments or MSMoments object.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
typename casacore::Vector< T >::const_iterator DataIterator
casacore::Bool doFit(const MomentsBase< T > &iMom) const
Return the casacore::Bool from the ImageMoments or MSMoments object saying whether we are going to fi...
Abstract base class for moment calculator classes.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::IPosition sliceShape_p
Definition: MomentWindow.h:187
shared_ptr< casacore::Lattice< T > > _ancilliaryLattice
Definition: MomentWindow.h:178
T & peakSNR(MomentsBase< T > &iMom) const
Return the peak SNR for determination of all noise spectra from the ImageMoments or MSMoments object...
~MomentWindow()
Destructor (does nothing).
casacore::LogIO os_p
Definition: MomentWindow.h:180
Computes moments from a windowed profile.
Definition: MomentWindow.h:140
MomentsBase< T > & iMom_p
Definition: MomentWindow.h:179
typename casacore::NumericTraits< T >::PrecisionType AccumType
Char PrecisionType
Higher precision type (Float-&gt;Double)
A templated, abstract base class for array-like objects.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const casacore::Vector< T > * pProfileSelect_p
Definition: MomentWindow.h:182
casacore::Vector< T > ancilliarySliceRef_p
Definition: MomentWindow.h:183
uInt N
Axis number.
Definition: ArrayAccessor.h:60
casacore::Bool setNSigmaWindow(casacore::Vector< casacore::Int > &window, const T pos, const T width, const casacore::Int nPts, const casacore::Int N) const
Take the fitted Gaussian parameters and set an N-sigma window.
casacore::Bool getAutoWindow(casacore::uInt &nFailed, casacore::Vector< casacore::Int > &window, const casacore::Vector< T > &x, const casacore::Vector< T > &y, const casacore::Vector< casacore::Bool > &mask, const T peakSNR, const T stdDeviation, const casacore::Bool doFit) const
Automatically determine the spectral window.
casacore::Bool _getBosmaWindow(casacore::Vector< casacore::Int > &window, const casacore::Vector< T > &y, const casacore::Vector< casacore::Bool > &mask, const T peakSNR, const T stdDeviation) const
Automatically determine the spectral window via Bosma&#39;s algorithm.
MomentWindow(shared_ptr< casacore::Lattice< T >> pAncilliaryLattice, MomentsBase< T > &iMom, casacore::LogIO &os, const casacore::uInt nLatticeOut)
Constructor.
unsigned int uInt
Definition: aipstype.h:51
casacore::Vector< T > selectedData_p
Definition: MomentWindow.h:184
virtual void process(T &out, casacore::Bool &outMask, const casacore::Vector< T > &in, const casacore::Vector< casacore::Bool > &inMask, const casacore::IPosition &pos)
This function is not implemented and throws an exception.