Lemma is an Electromagnetics API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

windowfilter.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 07/20/2010
  9. @version $Id: windowfilter.h 193 2014-11-10 23:51:41Z tirons $
  10. **/
  11. #ifndef WINDOWFILTER_INC
  12. #define WINDOWFILTER_INC
  13. #include "filter.h"
  14. namespace Lemma {
  15. /** Types of filter window that are supported.
  16. */
  17. enum WINDOWTYPE { HAMMING, /*!< A hamming window */
  18. HANNING, /*!< A hanning window */
  19. RECTANGULAR /*!< Rectangular window */
  20. };
  21. // ===================================================================
  22. // Class: WindowFilter
  23. /**
  24. @class WindowFilter
  25. \brief Fourier domain window filter.
  26. \details Current types are Hamming and Hanning. Others to be added.
  27. */
  28. // ===================================================================
  29. class WindowFilter : public Filter {
  30. public:
  31. // ==================== LIFECYCLE =======================
  32. /**
  33. * Returns a pointer to a new object of type WindowFilter.
  34. * It allocates all necessary memory.
  35. */
  36. static WindowFilter* New();
  37. /**
  38. * @copybrief LemmaObject::Delete()
  39. * @copydetails LemmaObject::Delete()
  40. */
  41. void Delete();
  42. // ==================== OPERATORS =======================
  43. // ==================== OPERATIONS =======================
  44. /// Sets the bandwith of the window.
  45. /// @param[in] width Bandwidth in Hz
  46. void SetBandwidth(const Real& width);
  47. /// Sets the sampling rate of an input time domain signal.
  48. /// @param[in] dt is the sampling rate, in seconds.
  49. void SetSamplingInterval(const Real& dt);
  50. /// Specifies the length of the time series to apply filter to.
  51. void SetNumberOfSamples(const int& nt);
  52. /// Sets the type of window to compute.
  53. void SetWindowType(const WINDOWTYPE& type);
  54. /** Returns the number of frequency bins for whole data record.
  55. * this is different then the length of the filter. This is
  56. * simply the length of the real to complex FFT, or
  57. * Nw = Nt%2 ? (Nt-1)/2+1 : (Nt)/2+1;
  58. * @return the number of frequency bins.
  59. */
  60. int GetNumberOfFrequencyBins();
  61. // ==================== ACCESS =======================
  62. // ==================== INQUIRY =======================
  63. /// Returns a Vector of the filter coefficients.
  64. VectorXr GetFilterCoefficients( );
  65. protected:
  66. // ==================== LIFECYCLE =======================
  67. /// Default protected constructor.
  68. WindowFilter (const std::string& name);
  69. /// Default protected constructor.
  70. ~WindowFilter ();
  71. /**
  72. * @copybrief LemmaObject::Release()
  73. * @copydetails LemmaObject::Release()
  74. */
  75. void Release();
  76. // ==================== DATA MEMBERS =========================
  77. /// Width of the window
  78. int Width;
  79. /// Length of time series
  80. int Nt;
  81. /// Length of the frequency series representation
  82. int Nw;
  83. /// Sampling rate of a time domain signal
  84. Real SamplingRate;
  85. /// Bandwith of filter
  86. Real Bandwidth;
  87. /// The filter coefficients
  88. VectorXr Coefficients;
  89. /// The type of filter to use
  90. WINDOWTYPE Type;
  91. private:
  92. }; // ----- end of class WindowFilter -----
  93. } // ----- end of Lemma name -----
  94. #endif // ----- #ifndef WINDOWFILTER_INC -----