00001 //# FluxCalcLogFreqPolynomial.h: Implementation base classes for flux standards 00002 //# which are (possibly broken) polynomials of log10(frequency). 00003 //# Copyright (C) 2010 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 adressed 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 #ifndef COMPONENTS_FLUXCALCLOGFREQPOLYNOMIAL_H 00028 #define COMPONENTS_FLUXCALCLOGFREQPOLYNOMIAL_H 00029 00030 #include <components/ComponentModels/FluxStandard.h> 00031 //#include <components/ComponentModels/FluxCalcQS.h> 00032 #include <components/ComponentModels/FluxCalcVQS.h> 00033 #include <casa/BasicSL/String.h> 00034 #include <measures/Measures/MFrequency.h> 00035 00036 //# Handy for passing anonymous arrays to functions. 00037 #include <scimath/Mathematics/RigidVector.h> 00038 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 00041 // <summary> 00042 // FluxCalcLogFreqPolynomial: Implementation base class for flux standards 00043 // which are polynomials of log10(frequency). 00044 // </summary> 00045 00046 // <use visibility=export> 00047 00048 // <reviewed reviewer="" date="" tests="" demos=""> 00049 00050 // <prerequisite> 00051 // <li><linkto class="FluxStandard">FluxStandard</linkto> module 00052 // <li><linkto class="FluxCalcQS">FluxCalcQS</linkto> module 00053 // </prerequisite> 00054 // 00055 // <etymology> 00056 // From "flux density", "calculator", "log10(frequency)", and "polynomial". 00057 // </etymology> 00058 // 00059 // <synopsis> 00060 // The FluxCalcLogFreqPolynomial class provides machinery to compute total flux 00061 // densities for specified (variable or non-variable) sources where the flux density is well 00062 // described by a low order polynomial of log(frequency). 00063 // </synopsis> 00064 // 00065 // <example> 00066 // <srcblock> 00067 // </srcblock> 00068 // </example> 00069 // 00070 // <motivation> 00071 // Encapsulate the machinery for most of the flux density standards in one class. 00072 // 00073 // The flux standards for cm astronomy are deliberately chosen to be distant, 00074 // non-varying, and bright around 1 GHz. Since such objects tend to be 00075 // dominated by synchrotron radiation their flux density is usually described 00076 // by a polynomial of log(frequency). 00077 // </motivation> 00078 // 00079 00080 class FluxCalcLogFreqPolynomial : public virtual FluxCalcVQS { 00081 public: 00082 // Some abbreviations, since the classes derived from this have to 00083 // define many polynomial coefficients. 00084 typedef RigidVector<Float, 2> RVF2; 00085 typedef RigidVector<Float, 3> RVF3; 00086 typedef RigidVector<Float, 4> RVF4; 00087 typedef RigidVector<Float, 5> RVF5; 00088 00089 // Set the log10(frequency) polynomial coefficients for calculating the flux 00090 // density and its uncertainty, and the unit (typically "MHz" or "GHz") that 00091 // the coefficients assume. Note that errcoeffs does not have to have the 00092 // same number of terms as lfcoeffs, or any terms at all, and that each term 00093 // in its polynomial is (errcoeff[order] * pow(log10(freq), order))**2. 00094 //FluxCalcLogFreqPolynomial(const String& freqUnit, const Vector<Double>& lfcoeffs, 00095 // const Vector<Double>& errcoeffs); 00096 00097 // Set value and error with the expected flux density and its uncertainty 00098 // (0.0 if unknown) at mfreq. Set updatecoeffs = True if the source considered to be 00099 // time variable. 00100 virtual Bool operator()(Flux<Double>& value, Flux<Double>& error, 00101 const MFrequency& mfreq, const Bool updatecoeffs=False); 00102 00103 virtual Bool setSource(const String& sourceName, const MDirection& sourceDir); 00104 void setFreqUnit(const String& freqUnit); 00105 00106 // Functions for setting up coeffs_p by taking a bunch of numbers 00107 // (packaged in RigidVectors) and formatting them into coeffs_p. 00108 00109 // Takes a RigidVector for the flux density coefficients and 00110 // second one for the uncertainty coefficients, and fills coeffs_p with them. 00111 template<Int lford, Int errord> 00112 void fill_coeffs(const RigidVector<Float, lford>& lfrv, 00113 const RigidVector<Float, errord>& errrv); 00114 00115 // Like fill_coeffs(lfrv, errrv), but it only takes the flux density 00116 // coefficients, and substitutes an empty Vector for the error coefficients. 00117 template<Int lford> 00118 void fill_coeffs(const RigidVector<Float, lford>& lfrv); 00119 00120 void fill_coeffs(const Vector<Float>& lfv); 00121 00122 private: 00123 virtual Bool setSourceCoeffs() = 0; 00124 00125 // The first element of this pair of Vectors is a Vector of coefficients for 00126 // the flux density polynomial (of log10(frequency)). The second element is 00127 // for estimating the flux density's uncertainty with a similar polynomial, 00128 // but each term is (coeff * log10(freq))**2. It does not need to have the 00129 // same number of coefficients as the first element, or even any 00130 // coefficients. Both Vectors start with the 0th order term. 00131 RigidVector<Vector<Float>, 2> coeffs_p; 00132 00133 // The frequency unit (e.g. "MHz" or "GHz") assumed by coeffs_p. 00134 String freqUnit_p; 00135 00136 }; 00137 00138 // <summary> 00139 // FluxCalcLogFreqBrokenPolynomial: Implementation base class for flux standards 00140 // which are broken polynomials of log10(frequency). 00141 // </summary> 00142 00143 // <use visibility=export> 00144 00145 // <reviewed reviewer="" date="" tests="" demos=""> 00146 00147 // <prerequisite> 00148 // <li><linkto class="FluxCalcLogFreqPolynomial">FluxCalcLogFreqPolynomial</linkto> module 00149 // </prerequisite> 00150 // 00151 // <etymology> 00152 // From FluxCalcLogFreqPolynomial and "broken". 00153 // </etymology> 00154 // 00155 // <synopsis> 00156 // The FluxCalcLogFreqBrokenPolynomial class extends FluxCalcLogFreqPolynomial 00157 // to allow one set of coefficients to be used below a certain frequency (the 00158 // break frequency) and another above it. Ideally the sets should mesh well 00159 // enough to make the resulting function at least roughly continuous. 00160 // </synopsis> 00161 // 00162 // <example> 00163 // <srcblock> 00164 // </srcblock> 00165 // </example> 00166 // 00167 // <motivation> 00168 // Some of the flux classes use a broken polynomial for 1934-638, and some do not. 00169 // </motivation> 00170 // 00171 // <todo asof="2010/07/26"> 00172 // <li> Handle an arbitrary number of breaks. 00173 // </todo> 00174 class FluxCalcLogFreqBrokenPolynomial : public virtual FluxCalcLogFreqPolynomial { 00175 public: 00176 FluxCalcLogFreqBrokenPolynomial(); 00177 00178 template <Int lford1, Int lford2> 00179 void fill_lohi_coeffs(const RigidVector<Float, lford1>& lorv, 00180 const MFrequency& break_freq, 00181 const RigidVector<Float, lford2>& hirv); 00182 00183 virtual Bool operator()(Flux<Double>& value, Flux<Double>& error, 00184 const MFrequency& mfreq, const Bool updatecoeffs); 00185 private: 00186 MFrequency break_freq_p; 00187 Bool in_low_state_p; 00188 Vector<Float> low_coeffs_p; 00189 Vector<Float> high_coeffs_p; 00190 }; 00191 00192 // <summary> 00193 // FluxCalcLogFreqPolynomialSH: Implementation base class for flux standards 00194 // which are polynomials of log10(frequency) following Scaife & Heald (2012). 00195 // </summary> 00196 00197 // <use visibility=export> 00198 00199 // <reviewed reviewer="" date="" tests="" demos=""> 00200 00201 // <prerequisite> 00202 // <li><linkto class="FluxCalcLogFreqPolynomial">FluxCalcLogFreqPolynomial</linkto> module 00203 // </prerequisite> 00204 // 00205 // <etymology> 00206 // From FluxCalcLogFreqPolynomial and Scaife-Heald (SH). 00207 // </etymology> 00208 // 00209 // <synopsis> 00210 // The FluxCalcLogFreqPolynomial class extends FluxCalcLogFreqPolynomial 00211 // to enable the use of polynomial coefficients a la Scaife & Heald (2012). 00212 // </synopsis> 00213 // 00214 // <example> 00215 // <srcblock> 00216 // </srcblock> 00217 // </example> 00218 // 00219 // <motivation> 00220 // The Scaife & Heald (2012) models can used to calibrate broadband 00221 // low-frequency radio observations (<~500 MHz). 00222 // </motivation> 00223 class FluxCalcLogFreqPolynomialSH : public virtual FluxCalcVQS { 00224 public: 00225 typedef RigidVector<Float, 2> RVF2; 00226 typedef RigidVector<Float, 3> RVF3; 00227 typedef RigidVector<Float, 4> RVF4; 00228 typedef RigidVector<Float, 5> RVF5; 00229 00230 //virtual Bool operator()(Flux<Double>& value, Flux<Double>& error, 00231 // const MFrequency& mfreq); 00232 00233 virtual Bool operator()(Flux<Double>& value, Flux<Double>& error, 00234 const MFrequency& mfreq, const Bool /* updatecoeffs */); 00235 00236 virtual Bool setSource(const String& sourceName, const MDirection& sourceDir); 00237 00238 void setFreqUnit(const String& freqUnit); 00239 00240 template<Int lford, Int errord> 00241 void fill_coeffs(const RigidVector<Float, lford>& lfrv, 00242 const RigidVector<Float, errord>& errrv); 00243 00244 private: 00245 virtual Bool setSourceCoeffs() = 0; 00246 RigidVector<Vector<Float>, 2> coeffs_p; 00247 String freqUnit_p; 00248 }; 00249 00250 00251 } //# NAMESPACE CASA - END 00252 00253 #ifndef AIPS_NO_TEMPLATE_SRC 00254 #include <components/ComponentModels/FluxCalcLogFreqPolynomial.tcc> 00255 #endif //# AIPS_NO_TEMPLATE_SRC 00256 00257 #endif