version  0.0.1
Defines the C++ API for MsPASS
Loading...
Searching...
No Matches
Butterworth.h
1#ifndef _MSPASS_BUTTERWORTH_H_
2#define _MSPASS_BUTTERWORTH_H_
3#include "mspass/algorithms/deconvolution/ComplexArray.h"
4#include "mspass/seismic/Seismogram.h"
5#include "mspass/seismic/TimeSeries.h"
6namespace mspass::algorithms {
36public:
99 Butterworth(const bool zerophase, const bool enable_lo, const bool enable_hi,
100 const double fstoplo, const double astoplo, const double fpasslo,
101 const double apasslo, const double fpasshi, const double apasshi,
102 const double fstophi, const double astophi,
103 const double sample_interval);
130 Butterworth(const bool zerophase, const bool enable_lo, const bool enable_hi,
131 const int npolelo, const double f3dblo, const int npolehi,
132 const double f3dbhi, const double sample_interval);
134 Butterworth(const Butterworth &parent);
136 Butterworth &operator=(const Butterworth &parent);
211 void apply(std::vector<double> &d);
275 transfer_function(const int n);
293 void change_dt(const double dtnew) {
294 this->f3db_lo *= (dtnew / (this->dt));
295 this->f3db_hi *= (dtnew / (this->dt));
296 this->dt = dtnew;
297 };
299 double low_corner() const { return f3db_lo / dt; };
301 double high_corner() const { return f3db_hi / dt; };
304 int npoles_low() const { return npoles_lo; };
307 int npoles_high() const { return npoles_hi; };
309 double current_dt() const { return dt; };
319 std::string filter_type() const {
320 if (use_lo) {
321 if (use_hi)
322 return std::string("bandpass");
323 else
324 return std::string("highpass");
325 } else {
326 if (use_hi)
327 return std::string("lowpass");
328 else
329 return std::string("Undefined");
330 }
331 };
334 bool is_zerophase() const { return zerophase; };
335
336private:
337 bool use_lo, use_hi;
338 bool zerophase;
339
340 /* bfdesign sets npoles and 3db points based on specified band properties.
341 These stored these when the constructor calls bfdesign for high and
342 low pass elements. Names should make clear which is which. These are
343 always stored in nondimensional form (f_nd=f*dt)*/
344 double f3db_lo, f3db_hi;
345 int npoles_lo, npoles_hi;
346 double dt;
347 /* These three functions are nearly exact copies of seismic unix
348 functions with a couple of differences:
349 1. All floats in the su code are made double here to mesh with modern arch
350 2. bfhighpass is changed to bflowpass and bflowpass is changed to bfhighcut
351 to mesh with the names used here more cleanly. that is, pass and cut define
352 the opposite sense of a filter and it gets very confusing when the
353 terms get mixed up in the same set of code. This way low always means the
354 low end of the pass band and high is the high end of the pass band.
355 */
356
357 void bfdesign(double fpass, double apass, double fstop, double astop,
358 int *npoles, double *f3db);
359 void bfhighcut(int npoles, double f3db, int n, double p[], double q[]);
360 void bflowcut(int npoles, double f3db, int n, double p[], double q[]);
361 /* These internal methods use internal dt value to call bfdesign with
362 nondimensional frequencies. Hence they should always be called after
363 a change in dt. They are also handy to contain common code for constructors.
364*/
365 void set_lo(const double fstop, const double fpass, const double astop,
366 const double apass);
367 void set_hi(const double fstop, const double fpass, const double astop,
368 const double apass);
369};
370} // namespace mspass::algorithms
371#endif
MsPASS implementation of Butterworth filter as processing object.
Definition Butterworth.h:35
int npoles_high() const
Definition Butterworth.h:307
void apply(std::vector< double > &d)
Filter a raw vector of data.
int npoles_low() const
Definition Butterworth.h:304
std::string filter_type() const
Definition Butterworth.h:319
mspass::algorithms::deconvolution::ComplexArray transfer_function(const int n)
Return the response of the filter in the frequency domain.
Definition Butterworth.cc:394
Butterworth & operator=(const Butterworth &parent)
Definition Butterworth.cc:204
mspass::seismic::CoreTimeSeries impulse_response(const int n)
Return the impulse response.
Definition Butterworth.cc:217
Butterworth()
Default constructor.
Definition Butterworth.cc:19
bool is_zerophase() const
Definition Butterworth.h:334
void change_dt(const double dtnew)
set the sample interval assumed for input data.
Definition Butterworth.h:293
double low_corner() const
Definition Butterworth.h:299
double high_corner() const
Definition Butterworth.h:301
double current_dt() const
Definition Butterworth.h:309
void apply(mspass::seismic::CoreTimeSeries &d)
pply the filter to a CoreTimeSeries object.
Definition Butterworth.cc:232
Vector (three-component) seismogram data object.
Definition CoreSeismogram.h:39
Scalar time series data object.
Definition CoreTimeSeries.h:17
Implemntation of Seismogram for MsPASS.
Definition Seismogram.h:14
Implemntation of TimeSeries for MsPASS.
Definition TimeSeries.h:14
Definition Metadata.h:71