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

Last change on this file was 3238, checked in by ansari, 18 years ago

Ajout namespace SOPHYA ds les fichiers .cc au lieu de include sopnamsp.h en presence de DECL_TEMP_SPEC , cmv+reza 27/04/2007

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