casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageProfileFitterResults.h
Go to the documentation of this file.
1 //# tSubImage.cc: Test program for class SubImage
2 //# Copyright (C) 1998,1999,2000,2001,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This program is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU General Public License as published by the Free
7 //# Software Foundation; either version 2 of the License, or (at your option)
8 //# any later version.
9 //#
10 //# This program 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 General Public License for
13 //# more details.
14 //#
15 //# You should have received a copy of the GNU General Public License along
16 //# with this program; if not, write to the Free Software Foundation, Inc.,
17 //# 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 
27 
28 #ifndef IMAGEANALYSIS_IMAGEPROFILEFITTERRESULTS_H
29 #define IMAGEANALYSIS_IMAGEPROFILEFITTERRESULTS_H
30 
34 
35 #include <casa/namespace.h>
36 
37 namespace casa {
38 
39 class LogFile;
40 class ProfileFitResults;
41 
43  // <summary>
44  // </summary>
45 
46  // <reviewed reviewer="" date="" tests="" demos="">
47  // </reviewed>
48 
49  // <prerequisite>
50  // </prerequisite>
51 
52  // <etymology>
53  // </etymology>
54 
55  // <synopsis>
56  // This class is the encapsulated IO portion of ImageProfileFitter. It is meant to be
57  // used only by that class. It is seperate from ImageProfileFitter for maintenence
58  // and compile convenience.
59  // </synopsis>
60 
61  // <example>
62  // <srcblock>
63  // </srcblock>
64  // </example>
65 
66 public:
68  const std::shared_ptr<casacore::LogIO> log, const casacore::CoordinateSystem& csysIm,
69  const casacore::Array<std::shared_ptr<ProfileFitResults> >* const &fitters,
70  const SpectralList& nonPolyEstimates,
71  const std::shared_ptr<const casacore::SubImage<casacore::Float> > subImage, casacore::Int fitAxis, casacore::Int polyOrder,
72  casacore::uInt nGaussSinglets, casacore::uInt nGaussMultiplets, casacore::uInt nLorentzSinglets,
73  casacore::uInt nPLPCoeffs, casacore::uInt nLTPCoeffs, casacore::Bool logResults, casacore::Bool multiFit,
74  const std::shared_ptr<LogFile> logfile, const casacore::String& xUnit,
75  const casacore::String& summaryHeader
76  );
77 
79 
80  // create all the products. Should be run after the object has been entirely configured
81  void createResults();
82 
83  // get the result Record
85 
86  inline casacore::String getClass() const { return _class; };
87 
88  // stream results to logger? This can be a lot of output.
89  inline void setLogResults(const casacore::Bool logResults) { _logResults = logResults; }
90 
91  // <group>
92  // gaussian amplitude image name
93  inline void setAmpName(const casacore::String& s) { _ampName = s; }
94  // gaussian amplitude error image name
95  inline void setAmpErrName(const casacore::String& s) { _ampErrName = s; }
96  // gaussian center image name
97  inline void setCenterName(const casacore::String& s) { _centerName = s; }
98  // gaussian center error image name
99  inline void setCenterErrName(const casacore::String& s) { _centerErrName = s; }
100  // gaussian fwhm image name
101  inline void setFWHMName(const casacore::String& s) { _fwhmName = s; }
102  // gaussian fwhm error image name
103  inline void setFWHMErrName(const casacore::String& s) { _fwhmErrName = s; }
104  // gaussian integral image name
105  inline void setIntegralName(const casacore::String& s) { _integralName = s; }
106  // gaussian integral error image name
107  inline void setIntegralErrName(const casacore::String& s) { _integralErrName = s; }
108  // </group>
109 
110  // set the name of the power logarithmic polynomial image.
111  inline void setPLPName(const casacore::String& s) { _plpName = s; }
112 
113  // set the name of the power logarithmic polynomial image.
114  inline void setPLPErrName(const casacore::String& s) { _plpErrName = s; }
115 
116  // set the name of the power logarithmic polynomial image.
117  inline void setLTPName(const casacore::String& s) { _ltpName = s; }
118 
119  // set the name of the power logarithmic polynomial image.
120  inline void setLTPErrName(const casacore::String& s) { _ltpErrName = s; }
121 
122 
123  //inline void setOutputSigmaImage(const casacore::String& s) { _sigmaName = s; }
124  // </group>
125 
126 
129  const static casacore::String _VALID;
130 
132  // Returns the center, in pixels of the indexth fit.
133  const casacore::Vector<casacore::Double> getPixelCenter( uint index ) const;
134  //Converts a pixel value into a world value either in velocity, wavelength, or
135  //frequency units.
137  double pixelVal, const casacore::IPosition& imPos, const casacore::String& units,
138  bool velocity, bool wavelength
139  ) const;
140 
142 
143  std::vector<String> logSummary(
144  casacore::uInt nProfiles, casacore::uInt nAttempted, casacore::uInt nSucceeded,
145  casacore::uInt nConverged, casacore::uInt nValid
146  );
147 
148  void writeImages(casacore::Bool someConverged) const;
149 
150 private:
151  enum gaussSols {
154  };
155 
156  enum spxSols {
158  };
159 
160  enum axisType {
162  };
163 
164  const static casacore::String _class;
169  _ltpName, _ltpErrName, /*_sigmaName, */ _summaryHeader;
174  // subimage contains the region of the original image
175  // on which the fit is performed.
176  const std::shared_ptr<const casacore::SubImage<casacore::Float> > _subImage;
178  std::vector<axisType> _axisTypes;
182  std::shared_ptr<LogFile> _logfile;
183  std::shared_ptr<casacore::LogIO> _log;
187 
188  void _setResults();
189 
190  void _resultsToLog();
191 
192  casacore::String _getTag(const casacore::uInt i) const;
193 
194  std::unique_ptr<std::vector<vector<casacore::Array<casacore::Double> > > > _createPCFArrays() const;
195 
197  const casacore::Double value, const casacore::Double error,
198  const casacore::String& unit, casacore::Bool isFixed
199  ) const;
200 
202  const PCFSpectralElement *const &pcf, const casacore::CoordinateSystem& csys,
203  const casacore::Vector<casacore::Double>& world, const casacore::IPosition& imPos, casacore::Bool showTypeString=true,
204  const casacore::String& indent=""
205  ) const;
206 
210  const casacore::IPosition& imPos
211  ) const;
212 
214 
216  const PolynomialSpectralElement& poly, const casacore::CoordinateSystem& csys,
218  ) const;
219 
222  ) const;
223 
226  ) const;
227 
228  void _marshalFitResults(
232  casacore::Array<casacore::Int>& nCompArr, std::unique_ptr<std::vector<vector<casacore::Array<casacore::Double> > > >& pcfArrays,
233  std::vector<casacore::Array<casacore::Double> >& plpArrayss, std::vector<casacore::Array<casacore::Double> >& ltpArrays, casacore::Bool returnDirection,
234  casacore::Array<casacore::String>& directionInfo /*, casacore::Array<casacore::Bool>& mask */
235  );
236 
237  static void _makeSolutionImages(
239  const casacore::Array<casacore::Double>& values, const casacore::String& unit,
241  );
242 
243  void _insertPCF(
244  vector<vector<casacore::Array<casacore::Double> > >& pcfArrays, /*casacore::Bool& isSolutionSane,*/
245  const casacore::IPosition& pixel, const PCFSpectralElement& pcf,
246  const casacore::uInt row, const casacore::uInt col,
247  const casacore::Double increment/*, const casacore::uInt npix*/
248  ) const;
249 
250  void _writeImages(
251  const casacore::CoordinateSystem& csys,
253  ) const;
254 
256 
258  const PCFSpectralElement& solution, const casacore::IPosition& imPos
259  ) const;
260 
261  //casacore::Bool _inVelocitySpace() const;
262 
264 
265  void _writeLogfile(const casacore::String& str, casacore::Bool open, casacore::Bool close);
266 
267  // the input array must have a degenerate last axis. It will be replicated
268  // along this axis n times to form an array with a last axis laength of n.
270 
271  void _doWorldCoords(
272  casacore::Array<casacore::String>& directionInfo, const casacore::CoordinateSystem& csysSub,
273  const casacore::IPosition& pixel, const casacore::DirectionCoordinate* const &dcoord,
274  const casacore::SpectralCoordinate* const &spcoord, const casacore::StokesCoordinate* const &polcoord,
275  casacore::Bool returnDirection, const casacore::String& directionType
276  );
277 
278  void _processSolutions(
279  /* casacore::Array<casacore::Bool>& mask, */ casacore::Array<casacore::String>& typeMat, casacore::Array<casacore::Int>& niterArr,
280  casacore::Array<casacore::Int>& nCompArr, const casacore::IPosition& pixel,
281  std::shared_ptr<const ProfileFitResults> fitter,
282  /* const casacore::RO_MaskedLatticeIterator<casacore::Float>& inIter, */
283  std::unique_ptr<std::vector<vector<casacore::Array<casacore::Double> > > >& pcfArrays,
284  std::vector<casacore::Array<casacore::Double> >& plpArrays, std::vector<casacore::Array<casacore::Double> >& ltpArrays,
285  casacore::Double increment
286  );
287 };
288 }
289 
290 #endif
static const casacore::uInt _lsPlane
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::Array< casacore::String > _worldCoords
static const casacore::String _CONVERGED
ImageProfileFitterResults(const std::shared_ptr< casacore::LogIO > log, const casacore::CoordinateSystem &csysIm, const casacore::Array< std::shared_ptr< ProfileFitResults > > *const &fitters, const SpectralList &nonPolyEstimates, const std::shared_ptr< const casacore::SubImage< casacore::Float > > subImage, casacore::Int fitAxis, casacore::Int polyOrder, casacore::uInt nGaussSinglets, casacore::uInt nGaussMultiplets, casacore::uInt nLorentzSinglets, casacore::uInt nPLPCoeffs, casacore::uInt nLTPCoeffs, casacore::Bool logResults, casacore::Bool multiFit, const std::shared_ptr< LogFile > logfile, const casacore::String &xUnit, const casacore::String &summaryHeader)
int Int
Definition: aipstype.h:50
void _setResults()
static void _makeSolutionImages(const casacore::String &name, const casacore::CoordinateSystem &csys, const casacore::Array< casacore::Double > &values, const casacore::String &unit, const casacore::Array< casacore::Bool > &mask)
LatticeExprNode log(const LatticeExprNode &expr)
Describes a multiplet of Gaussian shaped spectral lines.
void _insertPCF(vector< vector< casacore::Array< casacore::Double > > > &pcfArrays, const casacore::IPosition &pixel, const PCFSpectralElement &pcf, const casacore::uInt row, const casacore::uInt col, const casacore::Double increment) const
void setAmpErrName(const casacore::String &s)
gaussian amplitude error image name
casacore::Bool _doVelocity
casacore::Vector< casacore::Double > _goodCenterRange
casacore::String _logTransPolyToString(const LogTransformedPolynomialSpectralElement &ltp) const
static const casacore::String _class
casacore::String _centerErrName
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
casacore::Record getResults() const
get the result Record
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1886
casacore::String _integralErrName
Describes a polynomial spectral profile.
static const casacore::String _VALID
casacore::String _xUnit
void _resultsToLog()
static casacore::Array< casacore::Bool > _replicateMask(const casacore::Array< casacore::Bool > &array, casacore::Int n)
the input array must have a degenerate last axis.
std::vector< String > logSummary(casacore::uInt nProfiles, casacore::uInt nAttempted, casacore::uInt nSucceeded, casacore::uInt nConverged, casacore::uInt nValid)
void setLTPErrName(const casacore::String &s)
set the name of the power logarithmic polynomial image.
casacore::String _ltpErrName
casacore::Int _fitAxis
std::vector< axisType > _axisTypes
casacore::String _summaryHeader
static const casacore::String _SUCCEEDED
casacore::Vector< casacore::Double > _goodFWHMRange
casacore::String _ltpName
static const casacore::uInt _gsPlane
std::shared_ptr< LogFile > _logfile
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
void setFWHMErrName(const casacore::String &s)
gaussian fwhm error image name
void _doWorldCoords(casacore::Array< casacore::String > &directionInfo, const casacore::CoordinateSystem &csysSub, const casacore::IPosition &pixel, const casacore::DirectionCoordinate *const &dcoord, const casacore::SpectralCoordinate *const &spcoord, const casacore::StokesCoordinate *const &polcoord, casacore::Bool returnDirection, const casacore::String &directionType)
casacore::String _fwhmErrName
Describes the often used for determining spectral index plus higher order terms: y = log (S_x) = ln(c...
casacore::String _ampErrName
casacore::Bool _logResults
void _processSolutions(casacore::Array< casacore::String > &typeMat, casacore::Array< casacore::Int > &niterArr, casacore::Array< casacore::Int > &nCompArr, const casacore::IPosition &pixel, std::shared_ptr< const ProfileFitResults > fitter, std::unique_ptr< std::vector< vector< casacore::Array< casacore::Double > > > > &pcfArrays, std::vector< casacore::Array< casacore::Double > > &plpArrays, std::vector< casacore::Array< casacore::Double > > &ltpArrays, casacore::Double increment)
casacore::String _elementToString(const casacore::Double value, const casacore::Double error, const casacore::String &unit, casacore::Bool isFixed) const
void setFWHMName(const casacore::String &s)
gaussian fwhm image name
void createResults()
create all the products.
casacore::uInt _nLorentzSinglets
casacore::String _gaussianMultipletToString(const GaussianMultipletSpectralElement &gm, const casacore::CoordinateSystem &csys, const casacore::Vector< casacore::Double > &world, const casacore::IPosition &imPos) const
casacore::uInt _nGaussMultiplets
casacore::String _powerLogPolyToString(const PowerLogPolynomialSpectralElement &plp) const
casacore::Double _fitAxisIncrement() const
SpectralList _nonPolyEstimates
casacore::String _integralName
const casacore::Array< std::shared_ptr< ProfileFitResults > > *const _fitters
Interconvert pixel positions and directions (e.g. RA/DEC).
void setCenterErrName(const casacore::String &s)
gaussian center error image name
static const casacore::uInt _nOthers
const casacore::Vector< casacore::Double > getPixelCenter(uint index) const
Returns the center, in pixels of the indexth fit.
double Double
Definition: aipstype.h:55
std::shared_ptr< casacore::LogIO > _log
Abstract base class that describes a spectral profile that can be parameterized by a peak value (ampl...
casacore::String _fwhmName
void setPLPDivisor(const casacore::String &x)
void _marshalFitResults(casacore::Array< casacore::Bool > &attemptedArr, casacore::Array< casacore::Bool > &successArr, casacore::Array< casacore::Bool > &convergedArr, casacore::Array< casacore::Bool > &validArr, casacore::Array< casacore::String > &typeMat, casacore::Array< casacore::Int > &niterArr, casacore::Array< casacore::Int > &nCompArr, std::unique_ptr< std::vector< vector< casacore::Array< casacore::Double > > > > &pcfArrays, std::vector< casacore::Array< casacore::Double > > &plpArrayss, std::vector< casacore::Array< casacore::Double > > &ltpArrays, casacore::Bool returnDirection, casacore::Array< casacore::String > &directionInfo)
casacore::String _plpErrName
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool _multiFit
casacore::uInt _nGaussSinglets
casacore::String _plpName
A (masked) subset of an ImageInterface object.
casacore::Double getWorldValue(double pixelVal, const casacore::IPosition &imPos, const casacore::String &units, bool velocity, bool wavelength) const
Converts a pixel value into a world value either in velocity, wavelength, or frequency units...
casacore::String _getTag(const casacore::uInt i) const
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
const casacore::Array< ImageFit1D< casacore::Float > > & getFitters() const
void _writeImages(const casacore::CoordinateSystem &csys, const casacore::Array< casacore::Bool > &mask, const casacore::String &yUnit) const
const std::shared_ptr< const casacore::SubImage< casacore::Float > > _subImage
subimage contains the region of the original image on which the fit is performed. ...
void setIntegralErrName(const casacore::String &s)
gaussian integral error image name
casacore::Double _centerWorld(const PCFSpectralElement &solution, const casacore::IPosition &imPos) const
void setPLPErrName(const casacore::String &s)
set the name of the power logarithmic polynomial image.
void _writeLogfile(const casacore::String &str, casacore::Bool open, casacore::Bool close)
Interconvert pixel and frequency values.
casacore::Record _results
casacore::Vector< casacore::Vector< casacore::Double > > _pixelPositions
casacore::Bool _inVelocitySpace() const;
casacore::String _pcfToString(const PCFSpectralElement *const &pcf, const casacore::CoordinateSystem &csys, const casacore::Vector< casacore::Double > &world, const casacore::IPosition &imPos, casacore::Bool showTypeString=true, const casacore::String &indent="") const
casacore::uInt _nPLPCoeffs
A set of SpectralElements.
Definition: SpectralList.h:85
void setCenterName(const casacore::String &s)
gaussian center image name
Interconvert between pixel and Stokes value.
casacore::Bool _setAxisTypes()
casacore::String _ampName
String: the storage and methods of handling collections of characters.
Definition: String.h:223
const casacore::CoordinateSystem _csysIm
casacore::String _plpDivisor
void setLTPName(const casacore::String &s)
set the name of the power logarithmic polynomial image.
void setPLPName(const casacore::String &s)
set the name of the power logarithmic polynomial image.
Describes the function most often used for determining spectral index plus higher order terms: y = c_...
std::unique_ptr< std::vector< vector< casacore::Array< casacore::Double > > > > _createPCFArrays() const
casacore::uInt _nLTPCoeffs
casacore::String _polynomialToString(const PolynomialSpectralElement &poly, const casacore::CoordinateSystem &csys, const casacore::Vector< casacore::Double > &imPix, const casacore::Vector< casacore::Double > &world) const
casacore::String _centerName
casacore::Vector< casacore::Double > _goodAmpRange
void setAmpName(const casacore::String &s)
gaussian amplitude image name
Interconvert pixel and world coordinates.
void setIntegralName(const casacore::String &s)
gaussian integral image name
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
unsigned int uInt
Definition: aipstype.h:51
casacore::Int _polyOrder
void writeImages(casacore::Bool someConverged) const
void setLogResults(const casacore::Bool logResults)
stream results to logger? This can be a lot of output.