MsPASS C++ API  2.4.1.dev4+g92330b7a
Defines the C++ API for MsPASS
Loading...
Searching...
No Matches
FFTDeconOperator.h
1#ifndef __FFT_DECON_OPERATOR_H__
2#define __FFT_DECON_OPERATOR_H__
3#include "mspass/algorithms/TimeWindow.h"
4#include "mspass/algorithms/deconvolution/ComplexArray.h"
5#include "mspass/seismic/CoreTimeSeries.h"
6#include "mspass/seismic/PowerSpectrum.h"
7#include "mspass/utility/Metadata.h"
8#include <boost/archive/text_iarchive.hpp>
9#include <boost/archive/text_oarchive.hpp>
10#include <gsl/gsl_errno.h>
11#include <gsl/gsl_fft_complex.h>
12#include <string>
13namespace mspass::algorithms::deconvolution {
22public:
60 void change_size(const int nfft_new);
62 void change_shift(const int shift) { sample_shift = shift; };
64 int get_size() { return nfft; };
66 int get_shift() { return sample_shift; };
68 int operator_size() { return static_cast<int>(nfft); };
70 int operator_shift() { return sample_shift; };
76 double df(const double dt) {
77 double period;
78 period = static_cast<double>(nfft) * dt;
79 return 1.0 / period;
80 };
89 const ComplexArray &sw,
90 const double dt,
91 const double t0parent);
92
93protected:
95 int nfft;
99 gsl_fft_complex_wavetable *wavetable;
101 gsl_fft_complex_workspace *workspace;
104
105private:
106 friend boost::serialization::access;
107 template <class Archive>
108 void save(Archive &ar, const unsigned int version) const {
109 // std::cout << "Entered FFTDecon serialization save function"<<std::endl;
110 ar & nfft;
111 ar & sample_shift;
112 ar & winv;
113 // std::cout << "Exiting save function" << std::endl;
114 }
115 template <class Archive> void load(Archive &ar, const unsigned int version) {
116 // std::cout << "Entered FFTDecon serializaton load function" << std::endl;
117 ar &this->nfft;
118 ar &this->sample_shift;
119 // std::cout << "Loading winv vector" << std::endl;
120 ar & winv;
121 // std::cout << "Creating wavetable " << std::endl;
122 this->wavetable = gsl_fft_complex_wavetable_alloc(this->nfft);
123 // std::cout << "Creating workspace" << std::endl;
124 this->workspace = gsl_fft_complex_workspace_alloc(this->nfft);
125 // std::cout << "Exiting load" << std::endl;
126 }
127 BOOST_SERIALIZATION_SPLIT_MEMBER()
128};
129
130/* This helper is best referenced here */
131
144std::vector<double> circular_shift(const std::vector<double> &d, const int i0);
150int ComputeFFTLength(const mspass::algorithms::TimeWindow w, const double dt);
152void ValidateWindowDuration(const mspass::algorithms::TimeWindow w,
153 const std::string &window_name,
154 const std::string &caller);
162int ComputeFFTLength(const mspass::utility::Metadata &md);
170int ComputeDeconSampleShift(const mspass::utility::Metadata &md);
177void ValidatePowerSpectrumCoversDC(
178 const mspass::seismic::PowerSpectrum &spectrum,
179 const std::string &caller);
190std::vector<double> ExtractLagWindow(ComplexArray &fft_buffer,
191 const int output_length,
192 const int sample_shift);
198extern "C" {
199unsigned int nextPowerOf2(unsigned int n);
200}
201} // namespace mspass::algorithms::deconvolution
202#endif
Defines a time window.
Definition TimeWindow.h:12
Interfacing object to ease conversion between FORTRAN and C++ complex.
Definition ComplexArray.h:41
Object to hold components needed in all fft based decon algorithms.
Definition FFTDeconOperator.h:21
void changeparameter(const mspass::utility::Metadata &md)
Reconfigure the FFT operator from Metadata.
Definition FFTDeconOperator.cc:79
gsl_fft_complex_workspace * workspace
GSL scratch workspace allocated for nfft.
Definition FFTDeconOperator.h:101
FFTDeconOperator()
Construct an empty FFT operator shell.
Definition FFTDeconOperator.cc:13
mspass::seismic::CoreTimeSeries FourierInverse(const ComplexArray &winv, const ComplexArray &sw, const double dt, const double t0parent)
Return inverse wavelet for Fourier methods.
Definition FFTDeconOperator.cc:144
gsl_fft_complex_wavetable * wavetable
GSL factorization table allocated for nfft.
Definition FFTDeconOperator.h:99
void change_shift(const int shift)
Set the sample offset used to unwrap deconvolution lag windows.
Definition FFTDeconOperator.h:62
int operator_size()
Return the current FFT work-buffer length.
Definition FFTDeconOperator.h:68
~FFTDeconOperator()
Release allocated GSL FFT work objects.
Definition FFTDeconOperator.cc:63
ComplexArray winv
Frequency-domain inverse wavelet coefficients for derived operators.
Definition FFTDeconOperator.h:103
int operator_shift()
Return the current deconvolution lag-window sample shift.
Definition FFTDeconOperator.h:70
int sample_shift
Sample offset used to place zero lag in deconvolution outputs.
Definition FFTDeconOperator.h:97
int nfft
Current FFT work-buffer length in samples.
Definition FFTDeconOperator.h:95
int get_size()
Return the current FFT work-buffer length.
Definition FFTDeconOperator.h:64
int get_shift()
Return the current deconvolution lag-window sample shift.
Definition FFTDeconOperator.h:66
double df(const double dt)
Return frequency spacing for the current FFT length.
Definition FFTDeconOperator.h:76
FFTDeconOperator & operator=(const FFTDeconOperator &parent)
Assign FFT size and lag shift from another operator.
Definition FFTDeconOperator.cc:69
void change_size(const int nfft_new)
Change the FFT work-buffer length.
Definition FFTDeconOperator.cc:120
Scalar time series data object.
Definition CoreTimeSeries.h:17
Definition PowerSpectrum.h:11
Type-safe metadata container used throughout MsPASS.
Definition Metadata.h:101