source: Sophya/trunk/SophyaLib/SkyT/gaussfilt.cc@ 1364

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

SOphie : Adding the ingroup SkyT in each .cc file for DoxyGen Doc

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