1#ifndef _BASIC_SPECTRUM_H_
2#define _BASIC_SPECTRUM_H_
3#include "mspass/utility/MsPASSError.h"
41 parent_npts = npts_in;
45 is_live = parent.is_live;
48 parent_dt = parent.parent_dt;
49 parent_npts = parent.parent_npts;
52 if (
this != (&parent)) {
53 is_live = parent.is_live;
56 parent_dt = parent.parent_dt;
57 parent_npts = parent.parent_npts;
62 virtual ~BasicSpectrum() {};
69 bool live()
const {
return is_live; };
77 bool dead()
const {
return !is_live; };
84 void kill() { is_live =
false; };
93 double df()
const {
return this->dfval; };
98 double f0()
const {
return this->f0val; };
106 double dt()
const {
return this->parent_dt; };
115 return 1.0 / (this->parent_dt *
static_cast<double>(this->parent_npts));
125 int itest =
static_cast<int>(round((f - f0val) / dfval));
128 "BasicSpectrum::sample_number: f must be positive or greater than "
130 mspass::utility::ErrorSeverity::Fatal);
131 }
else if (itest >= this->
nf()) {
133 "BasicSpectrum::sample_number: f received exceeds the length of "
135 mspass::utility::ErrorSeverity::Fatal);
141 void set_df(
const double dfin) { dfval = dfin; };
143 void set_f0(
const double f0in) { f0val = f0in; };
145 void set_dt(
const double dtin) { parent_dt = dtin; };
149 void set_npts(
const int npts_in) { parent_npts = npts_in; };
158 virtual size_t nf()
const = 0;
Definition BasicSpectrum.h:19
virtual double frequency(const int sample_number) const =0
int sample_number(const double f) const
Definition BasicSpectrum.h:124
double dt() const
Return the original sample interval of data used to generate spectrum.
Definition BasicSpectrum.h:106
void set_live()
Definition BasicSpectrum.h:91
bool live() const
Definition BasicSpectrum.h:69
bool dead() const
Definition BasicSpectrum.h:77
BasicSpectrum(const BasicSpectrum &parent)
Definition BasicSpectrum.h:44
int timeseries_npts() const
Definition BasicSpectrum.h:119
void set_f0(const double f0in)
Definition BasicSpectrum.h:143
double rayleigh() const
Return the Rayleigh bin size for this spectrum.
Definition BasicSpectrum.h:114
void set_dt(const double dtin)
Definition BasicSpectrum.h:145
void kill()
Definition BasicSpectrum.h:84
virtual size_t nf() const =0
void set_npts(const int npts_in)
Definition BasicSpectrum.h:149
double df() const
Definition BasicSpectrum.h:93
virtual std::vector< double > frequencies() const =0
BasicSpectrum(const double dfin, const double f0in, const double dtin, const int npts_in)
Definition BasicSpectrum.h:35
double f0() const
Definition BasicSpectrum.h:98
BasicSpectrum()
Definition BasicSpectrum.h:22
virtual double Nyquist() const =0
void set_df(const double dfin)
Definition BasicSpectrum.h:141
Base class for error object thrown by MsPASS library routines.
Definition MsPASSError.h:38
Define metadata keys.
Definition BasicSpectrum.h:6