casa
$Rev:20696$
|
00001 //# LatticeAddNoise.h: add noise to a Lattice 00002 //# Copyright (C) 1997,1998,1999,2000,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id: LatticeAddNoise.h 18093 2004-11-30 17:51:10Z ddebonis $ 00028 00029 #ifndef LATTICES_LATTICEADDNOISE_H 00030 #define LATTICES_LATTICEADDNOISE_H 00031 00032 00033 //# Includes 00034 #include <casa/aips.h> 00035 #include <casa/Arrays/Vector.h> 00036 #include <casa/BasicMath/Random.h> 00037 00038 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 00041 //# Forward Declarations 00042 00043 template <class T> class MaskedLattice; 00044 template <class T> class Lattice; 00045 00046 00047 // <summary> 00048 // Add noise from specified distribution to a lattice 00049 // </summary> 00050 00051 // <use visibility=export> 00052 00053 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00054 // </reviewed> 00055 00056 // <prerequisite> 00057 // <li> <linkto class="Lattice">Lattice</linkto> 00058 // <li> <linkto class="Random">Random</linkto> 00059 // </prerequisite> 00060 00061 // <synopsis> 00062 // This class allows you to add noise from one of many enumerated 00063 // types to a Lattice. If the Lattice is Complex, then the noise 00064 // is added to real and imaginary separately. 00065 // </synopsis> 00066 00067 // <example> 00068 // <srcblock> 00069 // Vector<Double> pars(2): 00070 // pars(0) = 0.5; // Mean 00071 // pars(1) = 0.2; // Variance 00072 // LatticeAddNoise lan(Random::NORMAL, pars); 00073 // ArrayLattice<Float> lat(IPosition(2,100,100)); 00074 // lan.add(lat); 00075 // </srcblock> 00076 // </example> 00077 00078 00079 //# <todo asof="yyyy/mm/dd"> 00080 //# </todo> 00081 00082 class LatticeAddNoise 00083 { 00084 public: 00085 // Default constructor 00086 LatticeAddNoise(); 00087 00088 // Constructor. An exception will occur if we cannot generate 00089 // the distribution (e.g. illegal parameters). 00090 LatticeAddNoise (Random::Types type, 00091 const Vector<Double>& parameters); 00092 00093 // Copy constructor (copy semantics) 00094 LatticeAddNoise (const LatticeAddNoise& other); 00095 00096 // Assignment (copy semantics) 00097 LatticeAddNoise& operator=(const LatticeAddNoise& other); 00098 00099 // Destructor 00100 ~LatticeAddNoise(); 00101 00102 // Set a new distribution. An exception will occur if we cannot generate 00103 // the distribution (e.g. illegal parameters). 00104 void set (Random::Types type, 00105 const Vector<Double>& parameters); 00106 00107 // Add noise of given type to lattice. For Complex, the 00108 // noise is added to real and imaginary separately. 00109 // Any mask is ignored when adding the noise. I.e. 00110 // noise is added to masked pixels. 00111 // <group> 00112 void add (MaskedLattice<Float>& lattice); 00113 void add (MaskedLattice<Complex>& lattice); 00114 void add (Lattice<Float>& lattice); 00115 void add (Lattice<Complex>& lattice); 00116 // </group> 00117 00118 private: 00119 00120 Random::Types itsType; 00121 Vector<Double> itsParameters; 00122 MLCG itsGen; 00123 Random* itsNoise; 00124 00125 // Add noise to array. For Complex, noise is added to 00126 // real and imaginary separately. 00127 // <group> 00128 void addNoiseToArray (Array<Float>& data); 00129 void addNoiseToArray (Array<Complex>& data); 00130 // </group> 00131 00132 // Make noise generator 00133 void makeDistribution (); 00134 }; 00135 00136 00137 } //# NAMESPACE CASA - END 00138 00139 #endif