[601] | 1 | //--------------------------------------------------------------------------
|
---|
| 2 | // File and Version Information:
|
---|
| 3 | // $Id: specresp.cc,v 1.1.1.1 1999-11-19 16:34:32 ansari Exp $
|
---|
| 4 | //
|
---|
| 5 | // Description:
|
---|
| 6 | // Aim of the class: To give the energy density
|
---|
| 7 | // The unity used here is W/m^2/Hz/sr
|
---|
| 8 | //
|
---|
| 9 | // History (add to end):
|
---|
| 10 | // Sophie Oct, 1999 - creation
|
---|
| 11 | //
|
---|
| 12 | //------------------------------------------------------------------------
|
---|
| 13 |
|
---|
| 14 | //---------------
|
---|
| 15 | // C++ Headers --
|
---|
| 16 | //---------------
|
---|
| 17 | #include <typeinfo>
|
---|
| 18 | #include <math.h>
|
---|
| 19 | #include "specresp.h"
|
---|
| 20 | #include "integ.h"
|
---|
| 21 |
|
---|
| 22 | //----------------
|
---|
| 23 | // Constructor --
|
---|
| 24 | //----------------
|
---|
| 25 | SpectralResponse::SpectralResponse(double numin, double numax)
|
---|
| 26 | {
|
---|
| 27 | _numin = numin;
|
---|
| 28 | _numax = numax;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | //--------------
|
---|
| 33 | // Destructor --
|
---|
| 34 | //--------------
|
---|
| 35 | SpectralResponse::~SpectralResponse()
|
---|
| 36 | {
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | // ---------------------------
|
---|
| 40 | // -- Function Definitions --
|
---|
| 41 | // ---------------------------
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | double
|
---|
| 45 | SpectralResponse::minFreq() const
|
---|
| 46 | {
|
---|
| 47 | return _numin;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | double
|
---|
| 51 | SpectralResponse::maxFreq() const
|
---|
| 52 | {
|
---|
| 53 | return _numax;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | double
|
---|
| 57 | SpectralResponse::meanFreq() const
|
---|
| 58 | {
|
---|
| 59 | return (_numax+_numin)/2.;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | // peakFreq returns the value of the frequency for the
|
---|
| 65 | // peak of the spectrum.
|
---|
| 66 | double
|
---|
| 67 | SpectralResponse::peakFreq() const
|
---|
| 68 | {
|
---|
| 69 | double maxAnswer = -1.e99;
|
---|
| 70 | double maxNu = -10;
|
---|
| 71 | double nu;
|
---|
| 72 | for (int i=1; i<1000;i++)
|
---|
| 73 | {
|
---|
| 74 | nu=(_numax-_numin)*i/1000.+_numin;
|
---|
| 75 | double lookForMax =transmission(nu);
|
---|
| 76 | if(maxAnswer <= lookForMax) {
|
---|
| 77 | maxAnswer= lookForMax;
|
---|
| 78 | maxNu = nu;
|
---|
| 79 | }
|
---|
| 80 | }
|
---|
| 81 | return maxNu;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 |
|
---|
| 85 | double
|
---|
| 86 | SpectralResponse::peakTransmission() const
|
---|
| 87 | {
|
---|
| 88 | double nuPeak = this->peakFreq();
|
---|
| 89 | return transmission(nuPeak);
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | static SpectralResponse* _mySpecResp = NULL;
|
---|
| 93 |
|
---|
| 94 | static double SpectralResponse_transmission(double nu)
|
---|
| 95 | {
|
---|
| 96 | return(_mySpecResp->transmission(nu));
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | double
|
---|
| 101 | SpectralResponse::IntegratedSpect() const
|
---|
| 102 | {
|
---|
| 103 | double value = this->IntegratedSpect(_numin, _numax);
|
---|
| 104 | return value;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | double
|
---|
| 108 | SpectralResponse::IntegratedSpect(double numin, double numax) const
|
---|
| 109 | {
|
---|
| 110 | _mySpecResp = const_cast<SpectralResponse *>(this);
|
---|
| 111 | if(numin <= _numin) numin = _numin;
|
---|
| 112 | if(numax >= _numax) numax = _numax;
|
---|
| 113 | TrpzInteg I(SpectralResponse_transmission , numin, numax);
|
---|
| 114 | return((double)I);
|
---|
| 115 | _mySpecResp= NULL;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 | static SpectralResponse* _myLogSpecResp = NULL;
|
---|
| 120 |
|
---|
| 121 | static double SpectralResponse_logTransmission(double tau)
|
---|
| 122 | {
|
---|
| 123 | double value = _myLogSpecResp->transmission(pow(10,tau))*pow(10,tau);
|
---|
| 124 | return(value);
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | double
|
---|
| 128 | SpectralResponse::logIntegratedSpect(double numin, double numax) const
|
---|
| 129 | {
|
---|
| 130 | if(numin <= _numin) numin = _numin;
|
---|
| 131 | if(numax >= _numax) numax = _numax;
|
---|
| 132 | if(numin == 0) numin = 1.e-99;
|
---|
| 133 | double f1Log = log10(numin);
|
---|
| 134 | double f2Log = log10(numax);
|
---|
| 135 | if(f1Log < -1.e99) f1Log = -1.e99;
|
---|
| 136 | if(f2Log > 1.e99) f2Log = 1.e99;
|
---|
| 137 | _myLogSpecResp = const_cast<SpectralResponse *>(this);
|
---|
| 138 | TrpzInteg I(SpectralResponse_logTransmission ,f1Log,f2Log);
|
---|
| 139 | return((double)I*log(10.));
|
---|
| 140 | _myLogSpecResp= NULL;
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | double
|
---|
| 144 | SpectralResponse::logIntegratedSpect() const
|
---|
| 145 | {
|
---|
| 146 | double value = this->logIntegratedSpect(_numin, _numax);
|
---|
| 147 | return value;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 |
|
---|
| 151 | void
|
---|
| 152 | SpectralResponse::Print(ostream& os) const
|
---|
| 153 | {
|
---|
| 154 |
|
---|
| 155 | // os << "SpectralResponse::Print (" << typeid(*this).name()
|
---|
| 156 | //<< ") - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
|
---|
| 157 | os << "SpectralResponse::Print - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
|
---|
| 158 | os << "MeanFreq= " << meanFreq() << " Transmission= " << transmission(meanFreq()) << endl;
|
---|
| 159 | os << "PeakFreq= " << peakFreq() << " Transmission= " << transmission(peakFreq()) << endl;
|
---|
| 160 |
|
---|
| 161 | }
|
---|