source: Sophya/trunk/SophyaLib/SkyT/radspecvector.cc@ 909

Last change on this file since 909 was 909, checked in by ansari, 25 years ago

Sophie: adding documentation for Doxygen in the .cc files:wq

File size: 3.5 KB
Line 
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: radspecvector.cc,v 1.6 2000-04-13 14:10:45 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
29/*!
30 * \class SOPHYA::RadSpectraVec
31 * One may define the radiation
32 * spectrum with two vectors: <BR> one for the frequencies and the second for the
33 * value of the flux function. <BR>
34 * In that case, the class to use is RadSpectraVec !
35 */
36
37RadSpectraVec::RadSpectraVec()
38{
39}
40/*! Constructor:
41 \param nu is the frequency vector <BR>
42 \param fdenu is the corresponding flux values (stored in a vector as well)
43 */
44RadSpectraVec::RadSpectraVec(Vector const & nu, Vector const & fdenu, double numin, double numax)
45 : RadSpectra(numin, numax)
46{
47 if(nu.NElts() != fdenu.NElts())
48 throw SzMismatchError("RadSpectraVec::RadSpectraVec() - Non equal vector sizes");
49 _vecOfNu = nu;
50 _vecOfFDeNu = fdenu;
51 _numin = nu(0);
52 _numax = nu(nu.NElts()-1);
53}
54
55
56//--------------
57// Destructor --
58//--------------
59RadSpectraVec::~RadSpectraVec()
60{
61}
62
63// ---------------------------
64// -- Function Definitions --
65// ---------------------------
66
67
68
69/*! The flux function extrapolates the flux values for the
70 frequencies that are not present in the nu vector <BR>
71 given at the instanciation of the class.
72 */
73double
74RadSpectraVec::flux(double nu) const
75{
76 if ( (nu < _numin) || (nu > _numax) ) return(0.);
77 double value = 0.;
78 int sizeVecOfNu = _vecOfNu.NElts();
79 if(nu <= _vecOfNu(0)) return _vecOfFDeNu(0);
80 if(nu >= _vecOfNu(sizeVecOfNu-1)) return _vecOfFDeNu(sizeVecOfNu-1);
81
82 for (int i=1; i<sizeVecOfNu; i++)
83 {
84 if(nu < _vecOfNu(i))
85 {
86 double up = _vecOfFDeNu(i) ;
87 double down = _vecOfFDeNu(i-1);
88 double xmin = _vecOfNu(i-1);
89 double xmax = _vecOfNu(i);
90 double a = ((up-down)/(xmax-xmin));
91 value = a*nu+(up-a*xmax);
92 return value;
93 }
94 }
95 return _vecOfFDeNu(sizeVecOfNu-1);
96}
97
98
99
100void
101RadSpectraVec::Print(ostream& os) const
102{
103 // os << "RadSpectraVec::Print (" << typeid(*this).name()
104 // << ") - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
105 os << "RadSpectraVec::Print - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
106 os << "MeanFreq= " << meanFreq() << " Emission= " << flux(meanFreq()) << endl;
107 os << "PeakFreq= " << peakFreq() << " Emission= " << flux(peakFreq()) << endl;
108
109}
110
111/*
112void
113RadSpectraVec::WriteSelf(POutPersist& s)
114{
115 s.PutI4(this->NbElts());
116 for (int i=0; i< this->NbElts(); i++)
117 {
118 s.PutR8(this->getNuVec(i));
119 s.PutR8(this->getFNuVec(i));
120 }
121 s.PutR8(this->minFreq());
122 s.PutR8(this->maxFreq());
123
124}
125
126void
127RadSpectraVec::ReadSelf(PInPersist& s)
128{
129 s.GetI4(_size);
130
131 _vecOfNu.ReSize(_size);
132 _vecOfFDeNu.ReSize(_size);
133 for (int i=0; i< _size; i++)
134 {
135 s.GetR8(_vecOfNu(i));
136 s.GetR8(_vecOfFDeNu(i));
137 }
138 s.GetR8(_numin);
139 s.GetR8(_numax);
140 cout << "minFreq - maxFreq"<< endl;
141 cout << _numin<< "-" << _numax << endl;
142}
143*/
144
145
Note: See TracBrowser for help on using the repository browser.