//-------------------------------------------------------------------------- // File and Version Information: // $Id: specrespvector.cc,v 1.13 2007-04-27 16:17:01 ansari 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 "specrespvector.h" #include "pexceptions.h" #include "fioarr.h" namespace SOPHYA { //---------------- // Constructor -- //---------------- /*! * \class SpecRespVec \ingroup SkyT One may also want to defined the filter of a detector by two vectors: one for the frequencies and one for the corresponding transmission values. In this case on should use the SpecRespVec class ! */ SpecRespVec::SpecRespVec() : SpectralResponse() { } /*! Constructor: \param nu vector of the frequencies \param fdenu vector of the corresponding transmission values of the filter */ SpecRespVec::SpecRespVec(Vector const & nu, Vector const & fdenu, double numin, double numax) : SpectralResponse(numin, numax) { if(nu.NElts() != fdenu.NElts()) throw SzMismatchError("SpecRespVec::SpecRespVec() - Non equal vector sizes"); _vecOfNu = nu; _vecOfFDeNu = fdenu; _size = nu.NElts(); } SpecRespVec::SpecRespVec(Vector const & nu, Vector const & fdenu) : SpectralResponse() { if(nu.NElts() != fdenu.NElts()) throw SzMismatchError("SpecRespVec::SpecRespVec() - Non equal vector sizes"); _vecOfNu = nu; _vecOfFDeNu = fdenu; _numin = nu(0); _numax = nu(nu.NElts()-1); _size = nu.NElts(); } //-------------- // Destructor -- //-------------- SpecRespVec::~SpecRespVec() { } // --------------------------- // -- Function Definitions -- // --------------------------- /*! The transmission function extrapolates the transmission values for the frequencies that are not present in the nu vector
given at the instanciation of the class. */ double SpecRespVec::transmission(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::WriteSelf:: dobj= null " << endl; return; } int_4 version, nothing; version = 1; nothing = 0; // Reserved for future use s.PutI4(version); s.PutI4(nothing); s.PutR8(dobj->minFreq()); s.PutR8(dobj->maxFreq()); // TVector has Persistence Manager s << dobj->getNuVec(); { Vector& xv2 = dobj->getTNuVec(); cout << xv2 ; FIO_TArray vio2(&xv2); vio2.Write(s); } } DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */ void ObjFileIO::ReadSelf(PInPersist& s) { int_4 version, nothing; version = 1; nothing = 0; // Reserved for future use s.GetI4(version); s.GetI4(nothing); if(dobj == NULL) { dobj= new SpecRespVec(); ownobj= true; } r_8 minf, maxf; s.GetR8(minf); s.GetR8(maxf); dobj->setMinMaxFreq(minf, maxf); // TVector has Persistence Manager FIO_TArray vio(&(dobj->getNuVec())); vio.Read(s); FIO_TArray vio2(&(dobj->getTNuVec())); vio2.Read(s); } #ifdef __CXX_PRAGMA_TEMPLATES__ #pragma define_template ObjFileIO #endif #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) template class ObjFileIO; #endif } // FIN namespace SOPHYA