version  0.0.1
Defines the C++ API for MsPASS
Butterworth.h
1 #ifndef _MSPASS_BUTTERWORTH_H_
2 #define _MSPASS_BUTTERWORTH_H_
3 #include "mspass/seismic/TimeSeries.h"
4 #include "mspass/seismic/Seismogram.h"
5 #include "mspass/algorithms/deconvolution/ComplexArray.h"
6 namespace mspass::algorithms{
36 {
37 public:
48  Butterworth();
100  Butterworth(const bool zerophase, const bool enable_lo, const bool enable_hi,
101  const double fstoplo, const double astoplo,
102  const double fpasslo, const double apasslo,
103  const double fpasshi, const double apasshi,
104  const double fstophi, const double astophi,
105  const double sample_interval);
132  Butterworth(const bool zerophase, const bool enable_lo, const bool enable_hi,
133  const int npolelo, const double f3dblo,
134  const int npolehi, const double f3dbhi,
135  const double sample_interval);
137  Butterworth(const Butterworth& parent);
139  Butterworth& operator=(const Butterworth& parent);
214  void apply(std::vector<double>& d);
295  void change_dt(const double dtnew)
296  {
297  this->f3db_lo *= (dtnew/(this->dt));
298  this->f3db_hi *= (dtnew/(this->dt));
299  this->dt=dtnew;
300  };
302  double low_corner() const
303  {
304  return f3db_lo/dt;
305  };
307  double high_corner() const
308  {
309  return f3db_hi/dt;
310  };
313  int npoles_low() const {return npoles_lo;};
316  int npoles_high() const {return npoles_hi;};
318  double current_dt()const {return dt;};
328  std::string filter_type() const
329  {
330  if(use_lo)
331  {
332  if(use_hi)
333  return std::string("bandpass");
334  else
335  return std::string("highpass");
336  }
337  else
338  {
339  if(use_hi)
340  return std::string("lowpass");
341  else
342  return std::string("Undefined");
343  }
344  };
347  bool is_zerophase() const
348  {
349  return zerophase;
350  };
351 private:
352  bool use_lo,use_hi;
353  bool zerophase;
354 
355  /* bfdesign sets npoles and 3db points based on specified band properties.
356  These stored these when the constructor calls bfdesign for high and
357  low pass elements. Names should make clear which is which. These are
358  always stored in nondimensional form (f_nd=f*dt)*/
359  double f3db_lo, f3db_hi;
360  int npoles_lo, npoles_hi;
361  double dt;
362  /* These three functions are nearly exact copies of seismic unix
363  functions with a couple of differences:
364  1. All floats in the su code are made double here to mesh with modern arch
365  2. bfhighpass is changed to bflowpass and bflowpass is changed to bfhighcut to mesh
366  with the names used here more cleanly. that is, pass and cut define
367  the opposite sense of a filter and it gets very confusing when the
368  terms get mixed up in the same set of code. This way low always means the
369  low end of the pass band and high is the high end of the pass band.
370  */
371 
372  void bfdesign (double fpass, double apass, double fstop, double astop,
373  int *npoles, double *f3db);
374  void bfhighcut (int npoles, double f3db, int n, double p[], double q[]);
375  void bflowcut (int npoles, double f3db, int n, double p[], double q[]);
376  /* These internal methods use internal dt value to call bfdesign with
377  nondimensional frequencies. Hence they should always be called after
378  a change in dt. They are also handy to contain common code for constructors. */
379  void set_lo(const double fstop, const double fpass,
380  const double astop, const double apass);
381  void set_hi(const double fstop, const double fpass,
382  const double astop, const double apass);
383 };
384 } // namespace end
385 #endif
MsPASS implementation of Butterworth filter as processing object.
Definition: Butterworth.h:36
int npoles_high() const
Definition: Butterworth.h:316
void apply(std::vector< double > &d)
Filter a raw vector of data.
int npoles_low() const
Definition: Butterworth.h:313
std::string filter_type() const
Definition: Butterworth.h:328
mspass::algorithms::deconvolution::ComplexArray transfer_function(const int n)
Return the response of the filter in the frequency domain.
Definition: Butterworth.cc:436
Butterworth & operator=(const Butterworth &parent)
Definition: Butterworth.cc:224
mspass::seismic::CoreTimeSeries impulse_response(const int n)
Return the impulse response.
Definition: Butterworth.cc:239
Butterworth()
Default constructor.
Definition: Butterworth.cc:19
bool is_zerophase() const
Definition: Butterworth.h:347
void change_dt(const double dtnew)
set the sample interval assumed for input data.
Definition: Butterworth.h:295
double low_corner() const
Definition: Butterworth.h:302
double high_corner() const
Definition: Butterworth.h:307
double current_dt() const
Definition: Butterworth.h:318
void apply(mspass::seismic::CoreTimeSeries &d)
pply the filter to a CoreTimeSeries object.
Definition: Butterworth.cc:254
Vector (three-component) seismogram data object.
Definition: CoreSeismogram.h:40
Scalar time series data object.
Definition: CoreTimeSeries.h:18
Implemntation of Seismogram for MsPASS.
Definition: Seismogram.h:15
Implemntation of TimeSeries for MsPASS.
Definition: TimeSeries.h:15
Definition: Metadata.h:76