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

Last change on this file since 2479 was 2344, checked in by ansari, 23 years ago

Compilation (fin ?) avec SGI-CC -LANG:std - Reza 10/03/2003

File size: 3.5 KB
Line 
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: gaussfilt.cc,v 1.8 2003-03-10 15:13:49 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
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
106DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
107void
108ObjFileIO<GaussianFilter>::WriteSelf(POutPersist& s) const
109{
110 if(dobj == NULL)
111 {
112 cout << " ObjFileIO<GaussianFilter>::WriteSelf:: dobj= null " << endl;
113 return;
114 }
115 int_4 version, nothing;
116 version = 1;
117 nothing = 0; // Reserved for future use
118 s.PutI4(version);
119 s.PutI4(nothing);
120
121 s.PutR8(dobj->minFreq());
122 s.PutR8(dobj->maxFreq());
123 s.PutR8(dobj->giveNorm());
124 s.PutR8(dobj->giveNu0());
125 s.PutR8(dobj->giveDNu());
126}
127
128DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
129void
130ObjFileIO<GaussianFilter>::ReadSelf(PInPersist& s)
131{
132 int_4 version, nothing;
133 version = 1;
134 nothing = 0; // Reserved for future use
135 s.GetI4(version);
136 s.GetI4(nothing);
137
138 if(dobj == NULL)
139 {
140 dobj= new GaussianFilter();
141 ownobj= true;
142 }
143
144 r_8 a, nu0, dnu, numin, numax;
145 s.GetR8(numin);
146 s.GetR8(numax);
147 s.GetR8(a);
148 s.GetR8(nu0);
149 s.GetR8(dnu);
150 dobj->setMinMaxFreq(numin, numax);
151 dobj->setParams(nu0, dnu, a);
152 // cout << " Norm - Nu0 - DNu - minFreq - maxFreq " << endl;
153 // cout << _a << "-" << _nu0 << "-" << _s << "-" << _numin << "-" << _numax << endl;
154}
155
156
157#ifdef __CXX_PRAGMA_TEMPLATES__
158#pragma define_template ObjFileIO<GaussianFilter>
159#endif
160
161#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
162template class ObjFileIO<GaussianFilter>;
163#endif
Note: See TracBrowser for help on using the repository browser.