//-------------------------------------------------------------------------- // File and Version Information: // $Id: radspecvector.cc,v 1.8 2003-02-11 15:31:07 cmv Exp $ // // Description: // Aim of the class: To give the energy density // The unity used here is W/m^2/Hz/sr // // History (add to end): // Sophie Oct, 1999 - creation // //------------------------------------------------------------------------ //--------------- // C++ Headers -- //--------------- #include "machdefs.h" #include #include // #include #include "radspecvector.h" #include "pexceptions.h" //---------------- // Constructor -- //---------------- /*! * \class SOPHYA::RadSpectraVec \ingroup SkyT * One may define the radiation * spectrum with two vectors:
one for the frequencies and the second for the * value of the flux function.
* In that case, the class to use is RadSpectraVec ! */ RadSpectraVec::RadSpectraVec() { } /*! Constructor: \param nu is the frequency vector
\param fdenu is the corresponding flux values (stored in a vector as well) */ RadSpectraVec::RadSpectraVec(Vector const & nu, Vector const & fdenu, double numin, double numax) : RadSpectra(numin, numax) { if(nu.NElts() != fdenu.NElts()) throw SzMismatchError("RadSpectraVec::RadSpectraVec() - Non equal vector sizes"); _vecOfNu = nu; _vecOfFDeNu = fdenu; _numin = nu(0); _numax = nu(nu.NElts()-1); } //-------------- // Destructor -- //-------------- RadSpectraVec::~RadSpectraVec() { } // --------------------------- // -- Function Definitions -- // --------------------------- /*! The flux function extrapolates the flux values for the frequencies that are not present in the nu vector
given at the instanciation of the class. */ double RadSpectraVec::flux(double nu) const { if ( (nu < _numin) || (nu > _numax) ) return(0.); double value = 0.; int sizeVecOfNu = _vecOfNu.NElts(); if(nu <= _vecOfNu(0)) return _vecOfFDeNu(0); if(nu >= _vecOfNu(sizeVecOfNu-1)) return _vecOfFDeNu(sizeVecOfNu-1); for (int i=1; i