version  0.0.1
Defines the C++ API for MsPASS
Public Member Functions | List of all members
mspass::algorithms::deconvolution::GeneralIterDecon Class Reference

Implements the Generalized Iterative Method of Wang and Pavlis. More...

#include <GeneralIterDecon.h>

Inheritance diagram for mspass::algorithms::deconvolution::GeneralIterDecon:
mspass::algorithms::deconvolution::ScalarDecon mspass::algorithms::deconvolution::BasicDeconOperator

Public Member Functions

 GeneralIterDecon (mspass::utility::AntelopePf &md)
 Create an initialize an operator for subseqquent processing. More...
 
 GeneralIterDecon (const GeneralIterDecon &parent)
 
void changeparameter (const mspass::utility::Metadata &md)
 
int load (const mspass::seismic::CoreSeismogram &d, mspass::algorithms::TimeWindow dwin)
 
int loadnoise (const mspass::seismic::CoreSeismogram &d, mspass::algorithms::TimeWindow nwin)
 
int load (const mspass::seismic::CoreSeismogram &d, mspass::algorithms::TimeWindow dwin, mspass::algorithms::TimeWindow nwin)
 Load all needed data and process. More...
 
void process ()
 
mspass::seismic::CoreSeismogram getresult ()
 
mspass::seismic::CoreTimeSeries ideal_output ()
 
mspass::seismic::CoreTimeSeries actual_output ()
 
mspass::seismic::CoreTimeSeries inverse_wavelet ()
 Return a FIR represention of the inverse filter. More...
 
mspass::seismic::CoreTimeSeries inverse_wavelet (double t0parent)
 
mspass::utility::Metadata QCMetrics ()
 Return appropriate quality measures. More...
 
- Public Member Functions inherited from mspass::algorithms::deconvolution::ScalarDecon
 ScalarDecon (const mspass::utility::Metadata &md)
 
 ScalarDecon (const std::vector< double > &d, const std::vector< double > &w)
 
 ScalarDecon (const ScalarDecon &parent)
 
int load (const std::vector< double > &wavelet, const std::vector< double > &data)
 Load all data required for decon. More...
 
int loaddata (const std::vector< double > &data)
 
int loadwavelet (const std::vector< double > &wavelet)
 
ScalarDeconoperator= (const ScalarDecon &parent)
 
std::vector< double > getresult ()
 
void changeparameter (const mspass::utility::Metadata &md)
 
void change_shaping_wavelet (const ShapingWavelet &nsw)
 
mspass::seismic::CoreTimeSeries ideal_output ()
 

Additional Inherited Members

- Protected Attributes inherited from mspass::algorithms::deconvolution::ScalarDecon
std::vector< double > data
 
std::vector< double > wavelet
 
std::vector< double > result
 
ShapingWavelet shapingwavelet
 

Detailed Description

Implements the Generalized Iterative Method of Wang and Pavlis.

This class is an extension of the idea o the generalized iterative method described in the paper by Wang and Pavlis. Their original paper worked on scalar seismograms. This implemenation differs by iterating on the vector data effectively reducing a 3c seismogram to a sequence of 3D vectors at computed lags. The iterative reduction then iterates on the data matrix. In addition, Wang's original implementation did the iteration by repeated forward and inverse fourier transforms. This algorithm works completely in the time domain.

The class retains a concept Wang used in the original implementation. Many OOP books stress the idea of construction is initialization. That is not pruddent fo this case since construction involves some work that we do not want to repeat for each new seismogram. Hence, construction only initializes parameters required to run the algorithm. Calculation is triggered by calling one of the two overloaded load methods. The user should be warned, however, that we did not build ina test to assure the noise and signal windows are consistent. Anyone wanting to use this code outside of applications developed by the authors must recognize That the assure consistency they need to call loadnoise before load OR call only the load method that includes a signal and noise window.

Constructor & Destructor Documentation

◆ GeneralIterDecon()

mspass::algorithms::deconvolution::GeneralIterDecon::GeneralIterDecon ( mspass::utility::AntelopePf md)

Create an initialize an operator for subseqquent processing.

This is the primary constructor for this object. The PfStyleMetadata object is expected to contain a suite of parameters used to define how this operator will behave along with what inverse filter is to be constructed ans applied before the iterative algorithm is applied. The pf is required to have multiple Arr sections the components.

55  : ScalarDecon()
56 {
57  const string base_error("GeneralIterDecon AntelopePf contructor: ");
58  stringstream ss; // used for constructing error messages
59  /* The pf used for initializing this object has Antelope Arr section
60  for each algorithm. Since the generalized iterative method is a
61  two-stage algorithm we have a section for the iterative algorithm
62  and a (variable) sectin for the preprocessor algorithm. We use
63  the AntelopePf to parse this instead of raw antelope pfget
64  C calls. */
65  try {
66  AntelopePf md=mdtoplevel.get_branch("deconvolution_operator_type");
67  AntelopePf mdgiter=md.get_branch("generalized_iterative_deconvolution");
68  IterDeconType dct = parse_for_itertype(mdgiter);
69  this->decon_type=dct;
70  double ts,te;
71  ts=mdgiter.get<double>("full_data_window_start");
72  te=mdgiter.get<double>("full_data_window_end");
73  dwin=TimeWindow(ts,te);
74  ts=mdgiter.get<double>("deconvolution_data_window_start");
75  te=mdgiter.get<double>("deconvolution_data_window_end");
76  fftwin=TimeWindow(ts,te);
77  ts=mdgiter.get<double>("noise_window_start");
78  te=mdgiter.get<double>("noise_window_end");
79  nwin=TimeWindow(ts,te);
80  /* We need to make sure the noise and decon windows are inside the full_data_window*/
81  if(fftwin.start<dwin.start || fftwin.end>dwin.end)
82  {
83  stringstream ss;
84  ss << base_error << "decon window error"<<endl
85  << "Wavelet inversion window is not inside analysis window"<<endl
86  << "full_data_window (analysis) range="<<dwin.start<<" to "<<dwin.end<<endl
87  << "decon_window (wavelet inversion) range="<<fftwin.start<<" to "<<fftwin.end<<endl;
88  throw MsPASSError(ss.str(),ErrorSeverity::Invalid);
89  }
90  noise_component=mdgiter.get<int>("noise_component");
91  double target_dt=mdgiter.get<double>("target_sample_interval");
92  int maxns=static_cast<int>((fftwin.end-fftwin.start)/target_dt);
93  ++maxns; // Add one - points not intervals
94  nfft=nextPowerOf2(maxns);
95  /* This should override this even if it was previously set */
96  mdgiter.put("operator_nfft",nfft);
97  this->ScalarDecon::changeparameter(mdgiter);
98  shapingwavelet=ShapingWavelet(mdgiter,nfft);
99  /* Note minus sign here */
100  time_shift = -(dwin.start)/target_dt;
101  AntelopePf mdleaf;
102  /* We make sure the window parameters in each algorithm mactch what
103  is set for this algorithm. Abort if they are not consistent. The
104  test code is a bit repetitious but a necessary evil to allow the message
105  to be clearer. */
106  int n1,n2; //temporaries used below - needed because declrations illegal inside case
107  switch(decon_type)
108  {
109  case WATER_LEVEL:
110  mdleaf=md.get_branch("water_level");
111  ts=mdleaf.get<double>("deconvolution_data_window_start");
112  te=mdleaf.get<double>("deconvolution_data_window_end");
113  if((ts!=fftwin.start) || (te!=fftwin.end))
114  {
115  ss << base_error
116  <<"water level method specification of processing window is not"
117  " consistent with gid parameters"<<endl
118  << "water level parameters: deconvolution_data_window_start="<<ts
119  << ", decon_window_end="<<te<<endl
120  << "GID parameters: decon_window_start="<<fftwin.start
121  << ", decon_window_end="<<fftwin.end<<endl;
122  throw MsPASSError(ss.str(),ErrorSeverity::Invalid);
123  }
124  preprocessor=new WaterLevelDecon(mdleaf);
125  break;
126  case LEAST_SQ:
127  mdleaf=md.get_branch("least_square");
128  ts=mdleaf.get<double>("deconvolution_data_window_start");
129  te=mdleaf.get<double>("deconvolution_data_window_end");
130  if((ts!=fftwin.start) || (te!=fftwin.end))
131  {
132  ss << base_error
133  <<"least square method specification of processing window is not"
134  " consistent with gid parameters"<<endl
135  << "least square parameters: deconvolution_data_window_start="<<ts
136  << ", decon_window_end="<<te<<endl
137  << "GID parameters: decon_window_start="<<fftwin.start
138  << ", decon_window_end="<<fftwin.end<<endl;
139  throw MsPASSError(ss.str(),ErrorSeverity::Invalid);
140  }
141  preprocessor=new LeastSquareDecon(mdleaf);
142  break;
143  case MULTI_TAPER:
144  default:
145  mdleaf=md.get_branch("multi_taper");
146  ts=mdleaf.get<double>("deconvolution_data_window_start");
147  te=mdleaf.get<double>("deconvolution_data_window_end");
148  if((ts!=fftwin.start) || (te!=fftwin.end))
149  {
150  ss << base_error
151  <<"mulittaper method specification of processing window is not"
152  " consistent with gid parameters"<<endl
153  << "multitaper parameters: deconvolution_data_window_start="<<ts
154  << ", decon_window_end="<<te<<endl
155  << "GID parameters: decon_window_start="<<fftwin.start
156  << ", decon_window_end="<<fftwin.end<<endl;
157  throw MsPASSError(ss.str(),ErrorSeverity::Invalid);
158  }
159  /* Here we also have to test the noise parameters, but the gid
160  window can be different fromt that passed to the mulittaper method.
161  Hence we test only that the mulittaper noise window is within the bounds
162  of the gid noise window */
163  n1=static_cast<int>((fftwin.end-fftwin.start)/target_dt)+1;
164  n2=static_cast<int>((nwin.end-nwin.start)/target_dt)+1;
165  if(n1>n2)
166  {
167  ss << base_error << "inconsistent noise window specification"<<endl
168  << "multitaper parameters specify taper length="<<n1<<" samples"<<endl
169  << "GID noise window parameters define noise_window_start="<<nwin.start
170  << " and noise_window_end="<<nwin.end<<endl
171  << "The GID window has a length of "<<n2<<" samples"<<endl
172  << "GID implementation insists multitaper noise window be smaller or equal to GID noise window"
173  <<endl;
174  throw MsPASSError(ss.str(),ErrorSeverity::Invalid);
175  }
176  preprocessor=new MultiTaperXcorDecon(mdleaf);
177  };
178  /* Because this may evolve we make this a private method to
179  make changes easier to implement. */
180  this->construct_weight_penalty_function(mdgiter);
181  /* Set convergencd parameters from md keys */
182  iter_max=mdgiter.get<int>("maximum_iterations");
183  lw_linf_floor=mdgiter.get<double>("lag_weight_Linf_floor");
184  lw_l2_floor=mdgiter.get<double>("lag_weight_rms_floor");
185  resid_linf_prob=mdgiter.get<double>("residual_noise_rms_probability_floor");
186  resid_l2_tol=mdgiter.get<double>("residual_fractional_improvement_floor");
187  } catch(...) {
188  throw;
189  };
190 }
Defines a time window.
Definition: TimeWindow.h:14
C++ object version of a parameter file.
Definition: AntelopePf.h:62
AntelopePf get_branch(const std::string key) const
used for subtrees (nested Arrs in antelope)
Definition: AntelopePf.cc:409
T get(const std::string key) const
Definition: Metadata.h:472
Base class for error object thrown by MsPASS library routines.
Definition: MsPASSError.h:40

References mspass::utility::Metadata::get(), and mspass::utility::AntelopePf::get_branch().

Member Function Documentation

◆ actual_output()

mspass::seismic::CoreTimeSeries mspass::algorithms::deconvolution::GeneralIterDecon::actual_output ( )
inlinevirtual

\brif Return the actual output of the deconvolution operator.

The actual output is defined as w^-1*w and is compable to resolution kernels in linear inverse theory. Although not required we would normally expect this function to be peaked at 0. Offsets from 0 would imply a bias.

Implements mspass::algorithms::deconvolution::ScalarDecon.

96  {
97  return this->preprocessor->actual_output();
98  };
virtual mspass::seismic::CoreTimeSeries actual_output()=0

References mspass::algorithms::deconvolution::ScalarDecon::actual_output().

◆ inverse_wavelet()

mspass::seismic::CoreTimeSeries mspass::algorithms::deconvolution::GeneralIterDecon::inverse_wavelet ( )
inlinevirtual

Return a FIR represention of the inverse filter.

After any deconvolution is computed one can sometimes produce a finite impulse response (FIR) respresentation of the inverse filter.

Implements mspass::algorithms::deconvolution::ScalarDecon.

99  {
100  return this->preprocessor->inverse_wavelet();
101  };
virtual mspass::seismic::CoreTimeSeries inverse_wavelet()=0
Return a FIR represention of the inverse filter.

References mspass::algorithms::deconvolution::ScalarDecon::inverse_wavelet().

◆ load()

int mspass::algorithms::deconvolution::GeneralIterDecon::load ( const mspass::seismic::CoreSeismogram d,
mspass::algorithms::TimeWindow  dwin,
mspass::algorithms::TimeWindow  nwin 
)

Load all needed data and process.

This method is little more than a call to loadnoise followed immediately by a call to load that is assumed to initiate the computation.

327 {
328  try {
329  int iretn, iret;
330  iretn=this->loadnoise(draw,nwin);
331  iret=this->load(draw,dwin);
332  return (iretn+iret);
333  } catch(...) {
334  throw;
335  };
336 }

◆ QCMetrics()

Metadata mspass::algorithms::deconvolution::GeneralIterDecon::QCMetrics ( )
virtual

Return appropriate quality measures.

Each operator commonly has different was to measure the quality of the result. This method should return these in a generic Metadata object.

Implements mspass::algorithms::deconvolution::ScalarDecon.

737 {
738  cerr << "QCMetrics method not yet implemented"<<endl;
739  exit(-1);
740 }

The documentation for this class was generated from the following files: