00001 00002 // ----------------------------------------------------------------------------- 00003 00004 /* 00005 00006 CalStatsDerived.h 00007 00008 Description: 00009 ------------ 00010 This header file contains definitions for the classes derived from CalStats. 00011 00012 Classes: 00013 -------- 00014 CalStatsReal - This class feeds real data to the CalStats base class. 00015 CalStatsAmp - This class converts complex data to amplitudes and initializes 00016 the CalStats base class. 00017 CalStatsPhase - This class converts complex data to phases and initializes the 00018 CalStats base class. 00019 00020 Inhertited classes: 00021 ------------------- 00022 CalStats - This class calculates statistics on CASA caltables. 00023 00024 Modification history: 00025 --------------------- 00026 2011 Nov 15 - Nick Elias, NRAO 00027 Initial version. 00028 2012 Jan 25 - Nick Elias, NRAO 00029 Logging capability added. Error checking added. 00030 00031 */ 00032 00033 // ----------------------------------------------------------------------------- 00034 // Start of define macro to prevent multiple loading 00035 // ----------------------------------------------------------------------------- 00036 00037 #ifndef CAL_STATS_DERIVED_H 00038 #define CAL_STATS_DERIVED_H 00039 00040 // ----------------------------------------------------------------------------- 00041 // Includes 00042 // ----------------------------------------------------------------------------- 00043 00044 #define _USE_MATH_DEFINES 00045 #include <cmath> 00046 00047 #include <casa/Arrays/ArrayMath.h> 00048 #include <casa/Arrays/MaskedArray.h> 00049 00050 #include <calanalysis/CalAnalysis/CalStats.h> 00051 00052 // ----------------------------------------------------------------------------- 00053 // Start of casa namespace definitions 00054 // ----------------------------------------------------------------------------- 00055 00056 namespace casa { 00057 00058 // ----------------------------------------------------------------------------- 00059 // Start of CalStatsReal class definition 00060 // ----------------------------------------------------------------------------- 00061 00062 /* 00063 00064 CalStatsReal 00065 00066 Description: 00067 ------------ 00068 This class feeds real data to the CalStats base class. 00069 00070 Class public member functions: 00071 ------------------------------ 00072 CalStatsReal - This class feeds real data to the CalStats base class. It is 00073 primarily used for initial testing. 00074 ~CalStatsReal - This destructor deallocates the internal memory of an instance. 00075 00076 Modification history: 00077 --------------------- 00078 2011 Dec 11 - Nick Elias, NRAO 00079 Initial version. The public member functions are CalStatsReal() 00080 (generic) and ~CalStatsReal(). 00081 00082 */ 00083 00084 // ----------------------------------------------------------------------------- 00085 00086 class CalStatsReal : public CalStats { 00087 00088 public: 00089 00090 // Generic constructor 00091 CalStatsReal( const Cube<Double>& oValue, const Cube<Double>& oValueErr, 00092 const Cube<Bool>& oFlag, const Vector<String>& oFeed, 00093 const Vector<Double>& oFrequency, const Vector<Double>& oTime, 00094 const CalStats::AXIS& eAxisIterUserID ); 00095 00096 // Destructor 00097 ~CalStatsReal( void ); 00098 00099 }; 00100 00101 // ----------------------------------------------------------------------------- 00102 // End of CalStatsReal class definition 00103 // ----------------------------------------------------------------------------- 00104 00105 // ----------------------------------------------------------------------------- 00106 // Start of CalStatsAmp class definition 00107 // ----------------------------------------------------------------------------- 00108 00109 /* 00110 00111 CalStatsAmp 00112 00113 Description: 00114 ------------ 00115 This class converts complex data to amplitudes and initializes the CalStats base 00116 class. 00117 00118 Class public member functions: 00119 ------------------------------ 00120 CalStatsAmp - This generic constructor converts complex data to amplitudes and 00121 initializes the CalStats base class. It is primarily used for 00122 initial testing. 00123 ~CalStatsAmp - This destructor deallocates the internal memory of an instance. 00124 00125 Class public static member functions: 00126 ------------------------------------- 00127 norm - This member function normalizes the amplitudes and their errors. 00128 00129 Modification history: 00130 --------------------- 00131 2011 Nov 15 - Nick Elias, NRAO 00132 Initial version. The public member functions are CalStatsAmp() 00133 (generic) and ~CalStatsAmp(). The static member function is 00134 norm(). 00135 00136 */ 00137 00138 // ----------------------------------------------------------------------------- 00139 00140 class CalStatsAmp : public CalStats { 00141 00142 public: 00143 00144 // Generic constructor 00145 CalStatsAmp( const Cube<DComplex>& oValue, const Cube<Double>& oValueErr, 00146 const Cube<Bool>& oFlag, const Vector<String>& oFeed, 00147 const Vector<Double>& oFrequency, const Vector<Double>& oTime, 00148 const CalStats::AXIS& eAxisIterUserID, const Bool& bNorm ); 00149 00150 // Destructor 00151 ~CalStatsAmp( void ); 00152 00153 // Normalize member function 00154 static void norm( Vector<Double>& oAmp, Vector<Double>& oAmpErr, 00155 Vector<Bool>& oFlag ); 00156 00157 }; 00158 00159 // ----------------------------------------------------------------------------- 00160 // End of CalStatsAmp class definition 00161 // ----------------------------------------------------------------------------- 00162 00163 // ----------------------------------------------------------------------------- 00164 // Start of CalStatsPhase class definition 00165 // ----------------------------------------------------------------------------- 00166 00167 /* 00168 00169 CalStatsPhase 00170 00171 Description: 00172 ------------ 00173 This class converts complex data to phases and initializes the CalStats base 00174 class. 00175 00176 Inhertited classes: 00177 ------------------- 00178 CalStats - This class calculates statistics of new CASA caltables. 00179 00180 Class public member functions: 00181 ------------------------------ 00182 CalStatsPhase - This generic constructor converts complex data to amplitudes 00183 and initializes the CalStats base class. 00184 ~CalStatsPhase - This destructor deallocates the internal memory of an instance. 00185 00186 CalStatsPhase public static member functions: 00187 --------------------------------------------- 00188 unwrapGD - This member function unwraps the phases along the frequency axis 00189 with respect to the group delay. 00190 unwrapSimple - This member function performs a simple unwrapping procedure for 00191 both frequency and temporal abscissae. 00192 00193 CalStatsPhase private static member functions: 00194 ---------------------------------------------- 00195 fringePacket2 - This member function forms the squared-amplitude fringe packet. 00196 00197 CalStatsPhase templated private static member functions: 00198 -------------------------------------------------------- 00199 maxLocation - This member function finds the abscissa corresponding to the peak 00200 value of an ordinate vector. 00201 00202 Modification history: 00203 --------------------- 00204 2011 Nov 15 - Nick Elias, NRAO 00205 Initial version created with public member functions are 00206 CalStatsPhase() and ~CalStatsPhase(); and public static member 00207 function is unwrap(). 00208 2012 Mar 27 - Nick Elias, NRAO 00209 Private static member functions fringePacket2() and maxLocation() 00210 added. Private static member variables NUM_ITER_UNWRAP and 00211 NEW_RANGE_FACTOR added. 00212 2012 Mar 30 - Nick Elias, NRAO 00213 Public static member function unwrap() renamed to unwrapGD(). 00214 Public static member function unwrapSimple() added. 00215 00216 */ 00217 00218 // ----------------------------------------------------------------------------- 00219 00220 class CalStatsPhase : public CalStats { 00221 00222 public: 00223 00224 // Generic constructor 00225 CalStatsPhase( const Cube<DComplex>& oValue, const Cube<Double>& oValueErr, 00226 const Cube<Bool>& oFlag, const Vector<String>& oFeed, 00227 const Vector<Double>& oFrequency, const Vector<Double>& oTime, 00228 const CalStats::AXIS& eAxisIterUserID, const Bool& bUnwrap, 00229 const Double& dJumpMax ); 00230 00231 // Destructor 00232 ~CalStatsPhase( void ); 00233 00234 // Group-delay unwrapping member function 00235 static void unwrapGD( Vector<Double>& oPhase, 00236 const Vector<Double>& oFrequency, const Vector<Bool>& oFlag ); 00237 00238 // Simple phase unwrapping member function 00239 static void unwrapSimple( Vector<Double>& oPhase, const Double& dJumpMax, 00240 const Vector<Bool>& oFlag ); 00241 00242 private: 00243 00244 // Form the squared-amplitude fringe packet 00245 static Vector<Double>& fringePacket2( const Vector<Double>& oPhase, 00246 const Vector<Double>& oFrequency, const Vector<Double>& oTime ); 00247 00248 // Find the abscissa corresponding to the peak value of an ordinate vector 00249 template <typename T> static Double& maxLocation( const Vector<T>& oAbs, 00250 const Vector<T>& oValue ); 00251 00252 // The maximum number of iterations for unwrapping 00253 static const uInt NUM_ITER_UNWRAP; 00254 00255 // The new time range per unwrapping iteration is this factor times the 00256 // present time increment 00257 static const Double NEW_RANGE_FACTOR; 00258 00259 }; 00260 00261 // ----------------------------------------------------------------------------- 00262 // End of CalStatsPhase class definition 00263 // ----------------------------------------------------------------------------- 00264 00265 // ----------------------------------------------------------------------------- 00266 // Start of CalStatsDerived::maxLocation<T> template private statistics member 00267 // function 00268 // ----------------------------------------------------------------------------- 00269 00270 /* 00271 00272 CalStatsPhase::maxLocation<T> 00273 00274 Description: 00275 ------------ 00276 This member function finds the abscissa corresponding to the peak value of an 00277 ordinate vector. 00278 00279 Inputs: 00280 ------- 00281 oAbs - This Vector<T>() instance contains the abscissae. 00282 oValue - This Vector<T>() instance contains the ordinates. 00283 00284 Outputs: 00285 -------- 00286 The reference to the Double variable containing the abscissa corresponding to 00287 the peak value of the ordinate vector, returned via the function value. 00288 00289 Modification history: 00290 --------------------- 00291 2012 Mar 27 - Nick Elias, NRAO 00292 Initial version. 00293 00294 */ 00295 00296 // ----------------------------------------------------------------------------- 00297 00298 template <typename T> 00299 Double& CalStatsPhase::maxLocation( const Vector<T>& oAbs, 00300 const Vector<T>& oValue ) { 00301 00302 // Call the minMax() function and return the position of the maximum value 00303 00304 Double dValMin = 0.0; 00305 Double dValMax = 0.0; 00306 00307 IPosition oPosMin( 1, 0 ); 00308 IPosition oPosMax( 1, 0 ); 00309 00310 minMax( dValMin, dValMax, oPosMin, oPosMax, oValue ); 00311 00312 Double* pdAbsMax = new Double; 00313 *pdAbsMax = oAbs(oPosMax); 00314 00315 return( *pdAbsMax ); 00316 00317 } 00318 00319 // ----------------------------------------------------------------------------- 00320 // End of CalStatsDerived::maxLocation<T> template private statistics member 00321 // function 00322 // ----------------------------------------------------------------------------- 00323 00324 }; 00325 00326 // ----------------------------------------------------------------------------- 00327 // End of casa namespace 00328 // ----------------------------------------------------------------------------- 00329 00330 #endif 00331 00332 // ----------------------------------------------------------------------------- 00333 // End of define macro to prevent multiple loading 00334 // -----------------------------------------------------------------------------