casa
$Rev:20696$
|
00001 //# MCDoppler.h: MDoppler conversion routines 00002 //# Copyright (C) 1995,1996,1997,1998,1999,2002 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: MCDoppler.h 21130 2011-10-18 07:39:05Z gervandiepen $ 00028 00029 #ifndef MEASURES_MCDOPPLER_H 00030 #define MEASURES_MCDOPPLER_H 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <measures/Measures/MeasBase.h> 00035 #include <measures/Measures/MeasRef.h> 00036 #include <measures/Measures/MCBase.h> 00037 #include <measures/Measures/MConvertBase.h> 00038 #include <measures/Measures/MDoppler.h> 00039 #include <casa/OS/Mutex.h> 00040 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 00043 //# Forward Declarations 00044 class MCDoppler; 00045 class String; 00046 00047 //# Typedefs 00048 00049 // <summary> MDoppler conversion routines </summary> 00050 00051 // <use visibility=local> 00052 00053 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos=""> 00054 // </reviewed> 00055 00056 // <prerequisite> 00057 // <li> <linkto class=Measure>Measure</linkto> class 00058 // <li> <linkto class=MCBase>MCBase</linkto> base class 00059 // <li> <linkto class=MConvertBase>overall conversion</linkto> class 00060 // </prerequisite> 00061 // 00062 // <etymology> 00063 // Measure, Convert and Doppler 00064 // </etymology> 00065 // 00066 // <synopsis> 00067 // Contains state machinery and caching for actual conversions 00068 // </synopsis> 00069 // 00070 // <example> 00071 // Conversion of a radio Doppler to an optical 00072 // <srcblock> 00073 // #include <measures/Measures.h> 00074 // #include <measures/Measures/MDoppler.h> 00075 // MDoppler radio(0.01); // A radio Doppler value 00076 // cout << "Doppler radio = " << radio << "; optical = " << 00077 // MDoppler::Convert(radio, MDoppler::OPTICAL)() << // Convert 00078 // endl; 00079 // </srcblock> 00080 // Setting up a conversion 00081 // <srcblock> 00082 // MDoppler::Convert to_opt(MDoppler::RADIO, MDoppler::OPTICAL); 00083 // for (Double d=0; d<0.1; d += 0.005) { 00084 // cout << "radio = " << d << " to optical = " << 00085 // to_opt(d) << endl; 00086 // </srcblock> 00087 // </example> 00088 // 00089 // <motivation> 00090 // </motivation> 00091 // 00092 // <todo asof="1996/05/04"> 00093 // </todo> 00094 00095 class MCDoppler : public MCBase { 00096 00097 public: 00098 00099 //# Friends 00100 // Conversion of data 00101 friend class MeasConvert<MDoppler>; 00102 00103 //# Constructors 00104 // Default constructor 00105 MCDoppler(); 00106 00107 //# Destructor 00108 ~MCDoppler(); 00109 00110 //# Member functions 00111 // Show the state of the conversion engine (mainly for debugging purposes) 00112 static String showState(); 00113 00114 private: 00115 00116 //# Enumerations 00117 // The list of actual routines provided. 00118 // <note role=warning> Each <src>AA_BB</src> in the list points to routine 00119 // that can be used in the FromTo list in the getConvert routine. 00120 // In addition the type to which each is converted should be in the 00121 // ToRef array, again in the proper order. </note> 00122 enum Routes { 00123 RADIO_RATIO, 00124 Z_RATIO, 00125 BETA_RATIO, 00126 GAMMA_RATIO, 00127 RATIO_RADIO, 00128 RATIO_Z, 00129 RATIO_BETA, 00130 RATIO_GAMMA, 00131 N_Routes }; 00132 00133 //# Typedefs 00134 00135 //# Operators 00136 00137 //# General Member Functions 00138 00139 //# Enumerations 00140 00141 //# Cached Data 00142 00143 //# State machine data 00144 // Transition list 00145 static uInt ToRef_p[N_Routes][3]; 00146 // Transition matrix 00147 static uInt FromTo_p[MDoppler::N_Types][MDoppler::N_Types]; 00148 // Mutex for thread-safety. 00149 static MutexedInit theirMutexedInit; 00150 00151 // Fill the global state in a thread-safe way. 00152 static void fillState() 00153 { theirMutexedInit.exec(); } 00154 00155 //# Member functions 00156 00157 // Create conversion function pointer 00158 virtual void getConvert(MConvertBase &mc, 00159 const MRBase &inref, 00160 const MRBase &outref); 00161 00162 // Create help structures for Measure conversion routines 00163 virtual void initConvert(uInt which, MConvertBase &mc); 00164 00165 // Delete the pointers used in the MeasConvert help structure cache 00166 virtual void clearConvert(); 00167 00168 // Routine to convert Doppler from one reference frame to another 00169 virtual void doConvert(MeasValue &in, 00170 MRBase &inref, 00171 MRBase &outref, 00172 const MConvertBase &mc); 00173 // Conversion routine to cater for inheritance question 00174 void doConvert(MVDoppler &in, 00175 MRBase &inref, 00176 MRBase &outref, 00177 const MConvertBase &mc); 00178 00179 private: 00180 // Fill the global state in a thread-safe way. 00181 static void doFillState (void*); 00182 }; 00183 00184 00185 } //# NAMESPACE CASA - END 00186 00187 #endif