[601] | 1 | //--------------------------------------------------------------------------
|
---|
| 2 | // File and Version Information:
|
---|
[610] | 3 | // $Id: specrespvector.cc,v 1.3 1999-11-21 23:25:47 ansari Exp $
|
---|
[601] | 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 "machdefs.h"
|
---|
| 18 | #include <iostream.h>
|
---|
| 19 | #include <math.h>
|
---|
| 20 | // #include <typeinfo>
|
---|
| 21 |
|
---|
| 22 | #include "specrespvector.h"
|
---|
| 23 | #include "pexceptions.h"
|
---|
| 24 |
|
---|
| 25 | //----------------
|
---|
| 26 | // Constructor --
|
---|
| 27 | //----------------
|
---|
| 28 | SpecRespVec::SpecRespVec(Vector const & nu, Vector const & fdenu, double numin, double numax)
|
---|
| 29 | : SpectralResponse(numin, numax)
|
---|
| 30 | {
|
---|
| 31 | if(nu.NElts() != fdenu.NElts())
|
---|
| 32 | throw SzMismatchError("SpecRespVec::SpecRespVec() - Non equal vector sizes");
|
---|
| 33 | _vecOfNu = nu;
|
---|
| 34 | _vecOfFDeNu = fdenu;
|
---|
| 35 | _numin = nu(0);
|
---|
| 36 | _numax = nu(nu.NElts()-1);
|
---|
| 37 | if(_vecOfNu.NElts() != _vecOfFDeNu.NElts()) cout << "vectors are not compatible" << exit;
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | //--------------
|
---|
| 42 | // Destructor --
|
---|
| 43 | //--------------
|
---|
| 44 | SpecRespVec::~SpecRespVec()
|
---|
| 45 | {
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | // ---------------------------
|
---|
| 49 | // -- Function Definitions --
|
---|
| 50 | // ---------------------------
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | double
|
---|
| 56 | SpecRespVec::transmission(double nu) const
|
---|
| 57 | {
|
---|
| 58 | if ( (nu < _numin) || (nu > _numax) ) return(0.);
|
---|
[610] | 59 | double value = 0.;
|
---|
[601] | 60 | int sizeVecOfNu = _vecOfNu.NElts();
|
---|
[610] | 61 | if(nu <= _vecOfNu(0)) return _vecOfFDeNu(0);
|
---|
[601] | 62 | if(nu >= _vecOfNu(sizeVecOfNu-1)) return _vecOfFDeNu(sizeVecOfNu-1);
|
---|
| 63 |
|
---|
| 64 | for (int i=1; i<sizeVecOfNu; i++)
|
---|
| 65 | {
|
---|
[610] | 66 | if(nu < _vecOfNu(i))
|
---|
[601] | 67 | {
|
---|
| 68 | double up = _vecOfFDeNu(i) ;
|
---|
| 69 | double down = _vecOfFDeNu(i-1);
|
---|
| 70 | double xmin = _vecOfNu(i-1);
|
---|
| 71 | double xmax = _vecOfNu(i);
|
---|
| 72 | double a = ((up-down)/(xmax-xmin));
|
---|
| 73 | value = a*nu+(up-a*xmax);
|
---|
| 74 | return value;
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 | return value;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 | void
|
---|
| 83 | SpecRespVec::Print(ostream& os) const
|
---|
| 84 | {
|
---|
| 85 |
|
---|
| 86 | // os << "SpecRespVec::Print (" << typeid(*this).name()
|
---|
| 87 | //<< ") - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
|
---|
| 88 | os << "SpecRespVec ::Print - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
|
---|
| 89 | os << "MeanFreq= " << meanFreq() << " Transmission= " << transmission(meanFreq()) << endl;
|
---|
| 90 | os << "PeakFreq= " << peakFreq() << " Transmission= " << transmission(peakFreq()) << endl;
|
---|
| 91 |
|
---|
| 92 | }
|
---|