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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. // ===================================================================
  16. // Class: WindowFilter
  17. /**
  18. \ingroup LemmaCore
  19. \brief Fourier domain window filter.
  20. \details Current types are Hamming and Hanning. Others to be added.
  21. */
  22. // ===================================================================
  23. class WindowFilter : public Filter {
  24. friend std::ostream &operator<<(std::ostream &stream, const WindowFilter& ob);
  25. //struct ctor_key {};
  26. public:
  27. // ==================== LIFECYCLE =======================
  28. /** Default constructor, inaccessible use NewSP */
  29. explicit WindowFilter ( const ctor_key& );
  30. /** DeSerializing constructor, usees factory DeSerialize method, inaccessible use DeSerialize*/
  31. WindowFilter ( const YAML::Node& node, const ctor_key& );
  32. /** Default constructor. */
  33. virtual ~WindowFilter ( );
  34. /**
  35. * Uses YAML to serialize this object.
  36. * @return a YAML::Node
  37. */
  38. YAML::Node Serialize() const;
  39. /**
  40. * Constructs an object from a YAML::Node.
  41. */
  42. static std::shared_ptr< WindowFilter > DeSerialize(const YAML::Node& node);
  43. /**
  44. * Factory method for generating concrete class.
  45. * @return a std::shared_ptr of type WindowFilter
  46. */
  47. static std::shared_ptr< WindowFilter > NewSP();
  48. // ==================== OPERATORS =======================
  49. // ==================== OPERATIONS =======================
  50. /// Sets the bandwith of the window.
  51. /// @param[in] width Bandwidth in Hz
  52. void SetBandwidth(const Real& width);
  53. /// Sets the sampling rate of an input time domain signal.
  54. /// @param[in] dt is the sampling rate, in seconds.
  55. void SetSamplingInterval(const Real& dt);
  56. /// Specifies the length of the time series to apply filter to.
  57. void SetNumberOfSamples(const int& nt);
  58. /// Sets the type of window to compute.
  59. void SetWindowType(const WINDOWTYPE& type);
  60. /** Returns the number of frequency bins for whole data record.
  61. * this is different then the length of the filter. This is
  62. * simply the length of the real to complex FFT, or
  63. * Nw = Nt%2 ? (Nt-1)/2+1 : (Nt)/2+1;
  64. * @return the number of frequency bins.
  65. */
  66. int GetNumberOfFrequencyBins();
  67. // ==================== ACCESS =======================
  68. // ==================== INQUIRY =======================
  69. /// Returns a Vector of the filter coefficients.
  70. VectorXr GetFilterCoefficients( );
  71. /** Returns the name of the underlying class, similiar to Python's type */
  72. virtual std::string GetName() const ;
  73. protected:
  74. // ==================== LIFECYCLE =======================
  75. private:
  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. /** ASCII string representation of the class name */
  92. static constexpr auto CName = "WindowFilter";
  93. WindowFilter ( const WindowFilter& ) = delete;
  94. }; // ----- end of class WindowFilter -----
  95. } // ----- end of Lemma name -----
  96. #endif // ----- #ifndef WINDOWFILTER_INC -----