[601] | 1 | //--------------------------------------------------------------------------
|
---|
| 2 | // File and Version Information:
|
---|
[3238] | 3 | // $Id: gaussfilt.cc,v 1.11 2007-04-27 16:13:35 ansari Exp $
|
---|
[601] | 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"
|
---|
[2322] | 16 | #include <iostream>
|
---|
[601] | 17 | #include <math.h>
|
---|
| 18 |
|
---|
| 19 | #include "gaussfilt.h"
|
---|
| 20 |
|
---|
[3238] | 21 | namespace SOPHYA {
|
---|
| 22 |
|
---|
[909] | 23 | /*!
|
---|
[3238] | 24 | * \class GaussianFilter
|
---|
[927] | 25 | * \ingroup SkyT
|
---|
[909] | 26 | * Gaussian detector response
|
---|
| 27 | */
|
---|
[668] | 28 | GaussianFilter::GaussianFilter()
|
---|
| 29 | : SpectralResponse()
|
---|
| 30 | {
|
---|
| 31 | setParams(100, 10., 1.);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
[909] | 34 | /*! Constructor: the parameters correspond to the function defined in the
|
---|
| 35 | <a href="#gausseq"> equation </a> below
|
---|
| 36 | */
|
---|
[601] | 37 | GaussianFilter::GaussianFilter(double nu0, double s, double a, double numin, double numax)
|
---|
| 38 | : SpectralResponse(numin, numax)
|
---|
| 39 | {
|
---|
[668] | 40 | setParams(nu0, s, a);
|
---|
[601] | 41 | }
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | //--------------
|
---|
| 45 | // Destructor --
|
---|
| 46 | //--------------
|
---|
| 47 | GaussianFilter::~GaussianFilter()
|
---|
| 48 | {
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | // ---------------------------
|
---|
| 52 | // -- Function Definitions --
|
---|
| 53 | // ---------------------------
|
---|
| 54 |
|
---|
[909] | 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 | */
|
---|
[601] | 61 |
|
---|
| 62 | double
|
---|
| 63 | GaussianFilter::transmission(double nu) const
|
---|
| 64 | {
|
---|
| 65 | if ((nu < _numin) || (nu > _numax)) return(0.);
|
---|
| 66 | else {
|
---|
| 67 | double tmp = (nu-_nu0)/_s;
|
---|
[610] | 68 | return(_a * exp(-tmp*tmp));
|
---|
[601] | 69 | }
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | double
|
---|
| 73 | GaussianFilter::peakFreq() const
|
---|
| 74 | {
|
---|
| 75 | return(_nu0);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | double
|
---|
| 79 | GaussianFilter::peakTransmission() const
|
---|
| 80 | {
|
---|
| 81 | return(_a);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[668] | 84 |
|
---|
| 85 |
|
---|
[601] | 86 | void
|
---|
[668] | 87 | GaussianFilter::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 |
|
---|
| 97 | void
|
---|
[601] | 98 | GaussianFilter::Print(ostream& os) const
|
---|
| 99 | {
|
---|
| 100 | os << "GaussianFilter::Print - Fmin,Fmax= " << minFreq() << "," << maxFreq() << endl;
|
---|
[610] | 101 | os << " T = A * Exp(-((nu-nu0)/s)^2) : " << " nu0= " << _nu0 << " sig= "
|
---|
[601] | 102 | << _s << " A= " << _a << endl;
|
---|
| 103 | os << "PeakFreq= " << peakFreq() << " Transmission= " << transmission(peakFreq()) << endl;
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | }
|
---|
[668] | 107 |
|
---|
[2344] | 108 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[668] | 109 | void
|
---|
| 110 | ObjFileIO<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 |
|
---|
[2344] | 130 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[668] | 131 | void
|
---|
| 132 | ObjFileIO<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)
|
---|
[3238] | 164 | template class ObjFileIO<GaussianFilter>;
|
---|
[668] | 165 | #endif
|
---|
[3238] | 166 |
|
---|
| 167 | } // FIN namespace SOPHYA
|
---|