1 #ifndef _BASIC_SPECTRUM_H_
2 #define _BASIC_SPECTRUM_H_
5 #include "mspass/utility/MsPASSError.h"
46 is_live=parent.is_live;
49 parent_dt=parent.parent_dt;
50 parent_npts=parent.parent_npts;
56 is_live=parent.is_live;
59 parent_dt=parent.parent_dt;
60 parent_npts=parent.parent_npts;
72 bool live()
const{
return is_live;};
80 bool dead()
const{
return !is_live;};
87 void kill(){is_live=
false;};
96 double df()
const{
return this->dfval;};
101 double f0()
const{
return this->f0val;};
108 double dt()
const{
return this->parent_dt;};
117 return 1.0/(this->parent_dt*
static_cast<double>(this->parent_npts));
130 int itest=
static_cast<int>( round( (f-f0val)/dfval ) );
134 "BasicSpectrum::sample_number: f must be positive or greater than f0 if f0!=0",
135 mspass::utility::ErrorSeverity::Fatal);
137 else if(itest>=this->
nf())
140 "BasicSpectrum::sample_number: f received exceeds the length of stored vector",
141 mspass::utility::ErrorSeverity::Fatal);
149 void set_df(
const double dfin){dfval=dfin;};
151 void set_f0(
const double f0in){f0val=f0in;};
153 void set_dt(
const double dtin){parent_dt=dtin;};
157 void set_npts(
const int npts_in){parent_npts=npts_in;};
166 virtual size_t nf()
const = 0;
Definition: BasicSpectrum.h:20
virtual double frequency(const int sample_number) const =0
int sample_number(const double f) const
Definition: BasicSpectrum.h:128
double dt() const
Return the original sample interval of data used to generate spectrum.
Definition: BasicSpectrum.h:108
void set_live()
Definition: BasicSpectrum.h:94
bool live() const
Definition: BasicSpectrum.h:72
bool dead() const
Definition: BasicSpectrum.h:80
BasicSpectrum(const BasicSpectrum &parent)
Definition: BasicSpectrum.h:44
int timeseries_npts() const
Definition: BasicSpectrum.h:120
void set_f0(const double f0in)
Definition: BasicSpectrum.h:151
double rayleigh() const
Return the Rayleigh bin size for this spectrum.
Definition: BasicSpectrum.h:116
void set_dt(const double dtin)
Definition: BasicSpectrum.h:153
void kill()
Definition: BasicSpectrum.h:87
virtual size_t nf() const =0
void set_npts(const int npts_in)
Definition: BasicSpectrum.h:157
double df() const
Definition: BasicSpectrum.h:96
BasicSpectrum(const double dfin, const double f0in, const double dtin, const int npts_in)
Definition: BasicSpectrum.h:32
double f0() const
Definition: BasicSpectrum.h:101
BasicSpectrum()
Definition: BasicSpectrum.h:23
virtual std::vector< double > frequencies() const =0
virtual double Nyquist() const =0
void set_df(const double dfin)
Definition: BasicSpectrum.h:149
Base class for error object thrown by MsPASS library routines.
Definition: MsPASSError.h:40
Define metadata keys.
Definition: BasicSpectrum.h:6