Commit 69e042bc authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libpsdxx [WP]: provide file templates for implementation of DPSDComputer

parent ab55b70e
/*! \file dpsdcomputer_coherency.cc
* \brief compute coherency (implementation)
*
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 03/01/2019
*
* compute coherency (implementation)
*
* Copyright (c) 2019 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----
*
* REVISIONS and CHANGES
* - 03/01/2019 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_DPSDCOMPUTER_COHERENCY_CC_VERSION \
"TF_DPSDCOMPUTER_COHERENCY_CC V1.0 "
#include <dpsdcomputer_coherency.h>
namespace tf {
}
/* ----- END OF dpsdcomputer_coherency.cc ----- */
/*! \file dpsdcomputer_cross_psd.cc
* \brief compute cross power spectral density (implementation)
*
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 03/01/2019
*
* compute cross power spectral density (implementation)
*
* Copyright (c) 2019 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----
*
* REVISIONS and CHANGES
* - 03/01/2019 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_DPSDCOMPUTER_CROSS_PSD_CC_VERSION \
"TF_DPSDCOMPUTER_CROSS_PSD_CC V1.0 "
#include <dpsdcomputer_cross_psd.h>
namespace tf {
}
/* ----- END OF dpsdcomputer_cross_psd.cc ----- */
/*! \file dpsdcomputer_psd.cc
* \brief computer power spectral density (implementation)
*
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 03/01/2019
*
* computer power spectral density (implementation)
*
* Copyright (c) 2019 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----
*
* REVISIONS and CHANGES
* - 03/01/2019 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_DPSDCOMPUTER_PSD_CC_VERSION \
"TF_DPSDCOMPUTER_PSD_CC V1.0 "
#include <dpsdcomputer_psd.h>
namespace tf {
}
/* ----- END OF dpsdcomputer_psd.cc ----- */
......@@ -37,8 +37,93 @@
#define PSDXX_PSD_H_VERSION \
"PSDXX_PSD_H V1.0"
#include<aff/series.h>
/*
* internal notes
*
* DPSDComputer is used to compute a spectral representation of
* - power spectral density
* - cross power spectral density
* - coherency
*
* on a uniformly spaced frequency axis. The class provides zero padding,
* segmentation of time series with overlap and averaging
*
* in a subsequent step a second class does sampling on a logarithmic
* frequency scale
*
*/
namespace psd {
/*! Container for series with sampling interval
*/
template<typename T> struct Sampleѕ
{
//! series
aff::Series<T> data;
//! sampling interval (seconds for time series, Hz for spectral data)
double interval;
}; // template<typename T> struct Sampleѕ
/* ====================================================================== */
// containers for equally spaced data providing sampling information
//! time series and real spectral values (PSD and coherency)
typedef Samples<double> Tdouble_series;
//! complex coefficients
typedef Samples<std::complex<double> > Tcomplex_double_series;
/* ====================================================================== */
/*! \brief double precision function class for PSD computation
*
* This class computes
* - power spectral density of a single time series
* - cross power spectral density of two time series
* - coherency of two time series
*
* The actual computation is provided through function operators.
*
* Returns epctral values on uniformly spaced frequency axis.
*/
class DPSDComputer
{
public:
//! compute power spectral density
Tdouble_series psd(const Tdouble_series& s) const;
//! compute cross power spectrum
Tdouble_series cross_psd(const Tdouble_series& s1,
const Tdouble_series& s2) const;
//! compute coherency
Tdouble_series coherency(const Tdouble_series& s1,
const Tdouble_series& s2) const;
private:
//! number of segments split input time series
unsigned int Mnsegments;
//! fraction to let segments of time series overlap
double Moverlap;
//! integer factor in number of samples
unsigned int Mdivisor;
//! factor to increase size of time series by zero-padding
unsigned int Mnpadding;
}; // class DPSDComputer
/* ====================================================================== */
/*! \brief support sampling in the frequency domain
*
* This class supports logarithmic sampling and averaging in the frequency
* domain.
*
* Samples data which is provided on a uniformly spaced frequency axis with
* an equal amount of samples per decade and performs averarging.
*
* Implemented as a function
*/
} // namespace psd
#endif // PSDXX_PSD_H_VERSION (includeguard)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment