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

Last change on this file since 2743 was 2615, checked in by cmv, 21 years ago

using namespace sophya enleve de machdefs.h, nouveau sopnamsp.h cmv 10/09/2004

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