Lemma is an Electromagnetics API
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

WindowFilter.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. \ingroup LemmaCore
  26. \brief Fourier domain window filter.
  27. \details Current types are Hamming and Hanning. Others to be added.
  28. */
  29. // ===================================================================
  30. class WindowFilter : public Filter {
  31. public:
  32. // ==================== LIFECYCLE =======================
  33. /**
  34. * Factory method for generating concrete class.
  35. * @return a std::shared_ptr of type WindowFilter
  36. */
  37. static std::shared_ptr< WindowFilter > NewSP();
  38. // ==================== OPERATORS =======================
  39. // ==================== OPERATIONS =======================
  40. /// Sets the bandwith of the window.
  41. /// @param[in] width Bandwidth in Hz
  42. void SetBandwidth(const Real& width);
  43. /// Sets the sampling rate of an input time domain signal.
  44. /// @param[in] dt is the sampling rate, in seconds.
  45. void SetSamplingInterval(const Real& dt);
  46. /// Specifies the length of the time series to apply filter to.
  47. void SetNumberOfSamples(const int& nt);
  48. /// Sets the type of window to compute.
  49. void SetWindowType(const WINDOWTYPE& type);
  50. /** Returns the number of frequency bins for whole data record.
  51. * this is different then the length of the filter. This is
  52. * simply the length of the real to complex FFT, or
  53. * Nw = Nt%2 ? (Nt-1)/2+1 : (Nt)/2+1;
  54. * @return the number of frequency bins.
  55. */
  56. int GetNumberOfFrequencyBins();
  57. // ==================== ACCESS =======================
  58. // ==================== INQUIRY =======================
  59. /// Returns a Vector of the filter coefficients.
  60. VectorXr GetFilterCoefficients( );
  61. /** Returns the name of the underlying class, similiar to Python's type */
  62. virtual inline std::string GetName() const {
  63. return this->CName;
  64. }
  65. protected:
  66. // ==================== LIFECYCLE =======================
  67. /// Default protected constructor.
  68. WindowFilter ( );
  69. /// Default protected constructor.
  70. ~WindowFilter ( );
  71. // ==================== DATA MEMBERS =========================
  72. /// Width of the window
  73. int Width;
  74. /// Length of time series
  75. int Nt;
  76. /// Length of the frequency series representation
  77. int Nw;
  78. /// Sampling rate of a time domain signal
  79. Real SamplingRate;
  80. /// Bandwith of filter
  81. Real Bandwidth;
  82. /// The filter coefficients
  83. VectorXr Coefficients;
  84. /// The type of filter to use
  85. WINDOWTYPE Type;
  86. private:
  87. /** ASCII string representation of the class name */
  88. static constexpr auto CName = "WindowFilter";
  89. }; // ----- end of class WindowFilter -----
  90. } // ----- end of Lemma name -----
  91. #endif // ----- #ifndef WINDOWFILTER_INC -----