Lemma is an Electromagnetics API
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

WindowFilter.h 3.9KB

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