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/algorithms/deconvolution/GSLFFTResources.h"
6#include "mspass/seismic/CoreTimeSeries.h"
7#include "mspass/seismic/PowerSpectrum.h"
8#include "mspass/utility/Metadata.h"
9#include <boost/archive/text_iarchive.hpp>
10#include <boost/archive/text_oarchive.hpp>
11#include <gsl/gsl_errno.h>
12#include <gsl/gsl_fft_complex.h>
14namespace mspass::algorithms::deconvolution {
80 double df(
const double dt) {
82 period =
static_cast<double>(
nfft) * dt;
95 const double t0parent);
110 friend boost::serialization::access;
111 template <
class Archive>
112 void save(Archive &ar,
const unsigned int version)
const {
119 template <
class Archive>
void load(Archive &ar,
const unsigned int version) {
121 int loaded_sample_shift;
124 ar & loaded_sample_shift;
126 const std::string caller(
"FFTDeconOperator serialization load");
127 if (loaded_nfft <= 0)
129 caller +
": archived fft length must be positive",
130 mspass::utility::ErrorSeverity::Invalid);
131 if (loaded_sample_shift < 0 || loaded_sample_shift > loaded_nfft)
133 caller +
": archived sample shift is outside the fft buffer",
134 mspass::utility::ErrorSeverity::Invalid);
136 if (loaded_winv.
size() != 0 && loaded_winv.
size() != loaded_nfft)
138 caller +
": archived inverse size does not match fft length",
139 mspass::utility::ErrorSeverity::Invalid);
140 auto resources = detail::AllocateGSLFFTResources(loaded_nfft, caller);
147 gsl_fft_complex_wavetable_free(
wavetable);
149 gsl_fft_complex_workspace_free(
workspace);
152 wavetable = resources.wavetable.release();
153 workspace = resources.workspace.release();
155 BOOST_SERIALIZATION_SPLIT_MEMBER()
172std::vector<double> circular_shift(
const std::vector<double> &d,
const int i0);
181 const std::string &window_name,
182 const std::string &caller);
205void ValidatePowerSpectrumCoversDC(
207 const std::string &caller);
218std::vector<double> ExtractLagWindow(ComplexArray &fft_buffer,
219 const int output_length,
220 const int sample_shift);
227unsigned int nextPowerOf2(
unsigned int n);
Defines a time window.
Definition TimeWindow.h:12
Interfacing object to ease conversion between FORTRAN and C++ complex.
Definition ComplexArray.h:44
int size() const
Definition ComplexArray.cc:275
void swap(ComplexArray &other) noexcept
Definition ComplexArray.h:88
Object to hold components needed in all fft based decon algorithms.
Definition FFTDeconOperator.h:22
void changeparameter(const mspass::utility::Metadata &md)
Reconfigure the FFT operator from Metadata.
Definition FFTDeconOperator.cc:123
gsl_fft_complex_workspace * workspace
GSL scratch workspace allocated for nfft.
Definition FFTDeconOperator.h:105
FFTDeconOperator()
Construct an empty FFT operator shell.
Definition FFTDeconOperator.cc:16
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:190
gsl_fft_complex_wavetable * wavetable
GSL factorization table allocated for nfft.
Definition FFTDeconOperator.h:103
void change_shift(const int shift)
Set the sample offset used to unwrap deconvolution lag windows.
Definition FFTDeconOperator.h:66
int operator_size()
Return the current FFT work-buffer length.
Definition FFTDeconOperator.h:72
~FFTDeconOperator()
Release allocated GSL FFT work objects.
Definition FFTDeconOperator.cc:84
ComplexArray winv
Frequency-domain inverse wavelet coefficients for derived operators.
Definition FFTDeconOperator.h:107
int operator_shift()
Return the current deconvolution lag-window sample shift.
Definition FFTDeconOperator.h:74
int sample_shift
Sample offset used to place zero lag in deconvolution outputs.
Definition FFTDeconOperator.h:101
int nfft
Current FFT work-buffer length in samples.
Definition FFTDeconOperator.h:99
int get_size()
Return the current FFT work-buffer length.
Definition FFTDeconOperator.h:68
int get_shift()
Return the current deconvolution lag-window sample shift.
Definition FFTDeconOperator.h:70
double df(const double dt)
Return frequency spacing for the current FFT length.
Definition FFTDeconOperator.h:80
FFTDeconOperator & operator=(const FFTDeconOperator &parent)
Assign FFT size and lag shift from another operator.
Definition FFTDeconOperator.cc:90
void change_size(const int nfft_new)
Change the FFT work-buffer length.
Definition FFTDeconOperator.cc:170
Scalar time series data object.
Definition CoreTimeSeries.h:17
Definition PowerSpectrum.h:11
Base class for error object thrown by MsPASS library routines.
Definition MsPASSError.h:38