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

Last change on this file since 2322 was 2322, checked in by cmv, 23 years ago
  • passage xxstream.h en xxstream
  • compile avec gcc_3.2, gcc_2.96 et cxx En 3.2 le seek from ::end semble marcher (voir Eval/COS/pbseekios.cc)

rz+cmv 11/2/2003

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