source: Sophya/trunk/SophyaLib/SkyT/gaussfilt.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.3 KB
Line 
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: gaussfilt.cc,v 1.5 2000-04-13 14:10:44 ansari Exp $
4//
5// Description:
6//
7// History (add to end):
8// Sophie Oct, 1999 - creation
9//
10//------------------------------------------------------------------------
11
12//---------------
13// C++ Headers --
14//---------------
15#include "machdefs.h"
16#include <iostream.h>
17#include <math.h>
18
19#include "gaussfilt.h"
20
21/*!
22 * \class SOPHYA::GaussianFilter
23 * Gaussian detector response
24 */
25GaussianFilter::GaussianFilter()
26 : SpectralResponse()
27{
28 setParams(100, 10., 1.);
29}
30
31/*! Constructor: the parameters correspond to the function defined in the
32 <a href="#gausseq"> equation </a> below
33*/
34GaussianFilter::GaussianFilter(double nu0, double s, double a, double numin, double numax)
35 : SpectralResponse(numin, numax)
36{
37 setParams(nu0, s, a);
38}
39
40
41//--------------
42// Destructor --
43//--------------
44GaussianFilter::~GaussianFilter()
45{
46}
47
48// ---------------------------
49// -- Function Definitions --
50// ---------------------------
51
52/*! The transmission function is the wel known gaussian:
53 <a name="gausseq"> </a>
54 \f[
55 \hbox{transmission}= A e^{-{({\nu-\nu_0\over s})^2}};
56 \f]
57*/
58
59double
60GaussianFilter::transmission(double nu) const
61{
62 if ((nu < _numin) || (nu > _numax)) return(0.);
63 else {
64 double tmp = (nu-_nu0)/_s;
65 return(_a * exp(-tmp*tmp));
66 }
67}
68
69double
70GaussianFilter::peakFreq() const
71{
72return(_nu0);
73}
74
75double
76GaussianFilter::peakTransmission() const
77{
78return(_a);
79}
80
81
82
83void
84GaussianFilter::setParams(double nu0, double s, double a)
85{
86 if (s < 1.e-19) s = 1.e-19;
87 _s = s;
88 _nu0 = nu0;
89 _a = a;
90}
91
92
93
94void
95GaussianFilter::Print(ostream& os) const
96{
97 os << "GaussianFilter::Print - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
98 os << " T = A * Exp(-((nu-nu0)/s)^2) : " << " nu0= " << _nu0 << " sig= "
99 << _s << " A= " << _a << endl;
100 os << "PeakFreq= " << peakFreq() << " Transmission= " << transmission(peakFreq()) << endl;
101
102
103}
104
105void
106ObjFileIO<GaussianFilter>::WriteSelf(POutPersist& s) const
107{
108 if(dobj == NULL)
109 {
110 cout << " ObjFileIO<GaussianFilter>::WriteSelf:: dobj= null " << endl;
111 return;
112 }
113 int_4 version, nothing;
114 version = 1;
115 nothing = 0; // Reserved for future use
116 s.PutI4(version);
117 s.PutI4(nothing);
118
119 s.PutR8(dobj->minFreq());
120 s.PutR8(dobj->maxFreq());
121 s.PutR8(dobj->giveNorm());
122 s.PutR8(dobj->giveNu0());
123 s.PutR8(dobj->giveDNu());
124}
125
126void
127ObjFileIO<GaussianFilter>::ReadSelf(PInPersist& s)
128{
129 int_4 version, nothing;
130 version = 1;
131 nothing = 0; // Reserved for future use
132 s.GetI4(version);
133 s.GetI4(nothing);
134
135 if(dobj == NULL)
136 {
137 dobj= new GaussianFilter();
138 ownobj= true;
139 }
140
141 r_8 a, nu0, dnu, numin, numax;
142 s.GetR8(numin);
143 s.GetR8(numax);
144 s.GetR8(a);
145 s.GetR8(nu0);
146 s.GetR8(dnu);
147 dobj->setMinMaxFreq(numin, numax);
148 dobj->setParams(nu0, dnu, a);
149 // cout << " Norm - Nu0 - DNu - minFreq - maxFreq " << endl;
150 // cout << _a << "-" << _nu0 << "-" << _s << "-" << _numin << "-" << _numax << endl;
151}
152
153
154#ifdef __CXX_PRAGMA_TEMPLATES__
155#pragma define_template ObjFileIO<GaussianFilter>
156#endif
157
158#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
159template class ObjFileIO<GaussianFilter>;
160#endif
Note: See TracBrowser for help on using the repository browser.