MsPASS C++ API  2.4.1.dev4+g92330b7a
Defines the C++ API for MsPASS
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
mspass::algorithms::VectorTaper Class Reference

#include <Taper.h>

Inheritance diagram for mspass::algorithms::VectorTaper:
Inheritance graph
[legend]
Collaboration diagram for mspass::algorithms::VectorTaper:
Collaboration graph
[legend]

Public Member Functions

 VectorTaper (const std::vector< double > taperdata)
 
int apply (mspass::seismic::TimeSeries &d)
 
int apply (mspass::seismic::Seismogram &d)
 
void disable ()
 
void enable ()
 
std::vector< double > get_taper ()
 
double get_t0head () const
 
double get_t1head () const
 
- Public Member Functions inherited from mspass::algorithms::BasicTaper
 BasicTaper ()
 
virtual ~BasicTaper ()
 
void enable_head ()
 
void disable_head ()
 
void enable_tail ()
 
void disable_tail ()
 
bool head_is_enabled ()
 
bool tail_is_enable ()
 

Friends

class boost::serialization::access
 

Additional Inherited Members

- Protected Attributes inherited from mspass::algorithms::BasicTaper
bool head
 
bool tail
 
bool all
 

Detailed Description

General taper.

This method provides a simple way to build a taper from a set of uniformly spaced points. The apply methods will dogmatically only accept input data of the same length as the taper defined in the operator.

Constructor & Destructor Documentation

◆ VectorTaper() [1/2]

mspass::algorithms::VectorTaper::VectorTaper ( )
324 {
325 head = false;
326 tail = false;
327 all = false;
328}
bool tail
Definition Taper.h:78
bool all
Definition Taper.h:79
bool head
Definition Taper.h:77

◆ VectorTaper() [2/2]

mspass::algorithms::VectorTaper::VectorTaper ( const std::vector< double >  taperdata)

Construct from a vector of taper weights.

330 : taper(taperdata) {
331 /* Really only all needs to be set true here, but need to initialize
332 others anyway as good practice.*/
333 head = true;
334 tail = true;
335 all = true;
336}

References mspass::algorithms::BasicTaper::all, mspass::algorithms::BasicTaper::head, and mspass::algorithms::BasicTaper::tail.

Member Function Documentation

◆ apply() [1/2]

int mspass::algorithms::VectorTaper::apply ( mspass::seismic::Seismogram d)
virtual

Apply the vector taper to a three-component Seismogram.

Implements mspass::algorithms::BasicTaper.

354 {
355 if (all) {
356 if (d.npts() != taper.size()) {
357 stringstream ss;
358 ss << "VectorTaper apply method: size mismatch with data" << endl
359 << "operator taper size=" << taper.size()
360 << " but data vector length=" << d.npts() << endl
361 << "This operator requires these lengths to match" << endl;
362 d.elog.log_error("VectorTaper", ss.str(), ErrorSeverity::Complaint);
363 return -1;
364 }
365 for (int i = 0; i < d.npts(); ++i) {
366 double wt = taper[i];
367 for (int k = 0; k < 3; ++k) {
368 d.u(k, i) *= wt;
369 }
370 }
371 return 0;
372 } else
373 return -1;
374}
size_t npts() const
Definition BasicTimeSeries.h:173
mspass::utility::dmatrix u
Definition CoreSeismogram.h:52
int log_error(const mspass::utility::MsPASSError &merr)
Definition ErrorLogger.cc:72
ErrorLogger elog
Definition ProcessingHistory.h:246

References mspass::algorithms::BasicTaper::all, mspass::utility::ProcessingHistory::elog, mspass::utility::ErrorLogger::log_error(), mspass::seismic::BasicTimeSeries::npts(), and mspass::seismic::CoreSeismogram::u.

◆ apply() [2/2]

int mspass::algorithms::VectorTaper::apply ( mspass::seismic::TimeSeries d)
virtual

Apply the vector taper to a scalar TimeSeries.

Implements mspass::algorithms::BasicTaper.

337 {
338 if (all) {
339 if (d.npts() != taper.size()) {
340 stringstream ss;
341 ss << "VectorTaper apply method: size mismatch with data" << endl
342 << "operator taper size=" << taper.size()
343 << " but data vector length=" << d.npts() << endl
344 << "This operator requires these lengths to match" << endl;
345 d.elog.log_error("VectorTaper", ss.str(), ErrorSeverity::Complaint);
346 return -1;
347 }
348 for (int i = 0; i < d.npts(); ++i)
349 d.s[i] *= taper[i];
350 return 0;
351 } else
352 return -1;
353}
std::vector< double > s
Definition CoreTimeSeries.h:27

References mspass::algorithms::BasicTaper::all, mspass::utility::ProcessingHistory::elog, mspass::utility::ErrorLogger::log_error(), mspass::seismic::BasicTimeSeries::npts(), and mspass::seismic::CoreTimeSeries::s.

◆ disable()

void mspass::algorithms::VectorTaper::disable ( )
inline

Disable this vector taper.

193{ all = false; };

References mspass::algorithms::BasicTaper::all.

◆ enable()

void mspass::algorithms::VectorTaper::enable ( )
inline

Enable this vector taper when weights are available.

195 {
196 if (taper.size() > 0)
197 all = true;
198 };

References mspass::algorithms::BasicTaper::all.

◆ get_t0head()

double mspass::algorithms::VectorTaper::get_t0head ( ) const
inlinevirtual

Vector tapers do not define a head start time.

Implements mspass::algorithms::BasicTaper.

202 {
203 std::cerr << "get_t0head not implemented for VectorTaper";
204 return 0.0;
205 };

◆ get_t1head()

double mspass::algorithms::VectorTaper::get_t1head ( ) const
inlinevirtual

Vector tapers do not define a head end time.

Implements mspass::algorithms::BasicTaper.

207 {
208 std::cerr << "get_t1head not implemented for VectorTaper";
209 return 0.0;
210 };

◆ get_taper()

std::vector< double > mspass::algorithms::VectorTaper::get_taper ( )
inline

Return a copy of the taper weights.

200{ return taper; };

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