[601] | 1 | //--------------------------------------------------------------------------
|
---|
| 2 | // File and Version Information:
|
---|
| 3 | // $Id: radspecvector.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 "machdefs.h"
|
---|
| 18 | #include <iostream.h>
|
---|
| 19 | #include <math.h>
|
---|
| 20 | // #include <typeinfo>
|
---|
| 21 |
|
---|
| 22 | #include "radspecvector.h"
|
---|
| 23 | #include "pexceptions.h"
|
---|
| 24 |
|
---|
| 25 | //----------------
|
---|
| 26 | // Constructor --
|
---|
| 27 | //----------------
|
---|
| 28 | RadSpectraVec::RadSpectraVec(Vector const & nu, Vector const & fdenu, double numin, double numax)
|
---|
| 29 | : RadSpectra(numin, numax)
|
---|
| 30 | {
|
---|
| 31 | if(nu.NElts() != fdenu.NElts())
|
---|
| 32 | throw SzMismatchError("RadSpectraVec::RadSpectraVec() - 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 | RadSpectraVec::~RadSpectraVec()
|
---|
| 45 | {
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | // ---------------------------
|
---|
| 49 | // -- Function Definitions --
|
---|
| 50 | // ---------------------------
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | double
|
---|
| 56 | RadSpectraVec::flux(double nu) const
|
---|
| 57 | {
|
---|
| 58 | if ( (nu < _numin) || (nu > _numax) ) return(0.);
|
---|
| 59 | double value = -99;
|
---|
| 60 | int sizeVecOfNu = _vecOfNu.NElts();
|
---|
| 61 | double minVal = _vecOfNu(0);
|
---|
| 62 | if(nu <= minVal) return _vecOfFDeNu(0);
|
---|
| 63 | if(nu >= _vecOfNu(sizeVecOfNu-1)) return _vecOfFDeNu(sizeVecOfNu-1);
|
---|
| 64 |
|
---|
| 65 | for (int i=1; i<sizeVecOfNu; i++)
|
---|
| 66 | {
|
---|
| 67 | if(nu>= minVal && nu < _vecOfNu(i))
|
---|
| 68 | {
|
---|
| 69 | double up = _vecOfFDeNu(i) ;
|
---|
| 70 | double down = _vecOfFDeNu(i-1);
|
---|
| 71 | double xmin = _vecOfNu(i-1);
|
---|
| 72 | double xmax = _vecOfNu(i);
|
---|
| 73 | double a = ((up-down)/(xmax-xmin));
|
---|
| 74 | value = a*nu+(up-a*xmax);
|
---|
| 75 | return value;
|
---|
| 76 | }
|
---|
| 77 | else
|
---|
| 78 | {
|
---|
| 79 | minVal = _vecOfNu(i);
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 | return value;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | void
|
---|
| 87 | RadSpectraVec::Print(ostream& os) const
|
---|
| 88 | {
|
---|
| 89 | // os << "RadSpectraVec::Print (" << typeid(*this).name()
|
---|
| 90 | // << ") - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
|
---|
| 91 | os << "RadSpectraVec::Print - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
|
---|
| 92 | os << "MeanFreq= " << meanFreq() << " Emission= " << flux(meanFreq()) << endl;
|
---|
| 93 | os << "PeakFreq= " << peakFreq() << " Emission= " << flux(peakFreq()) << endl;
|
---|
| 94 |
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 |
|
---|