[seiscomp, scanloc] Install, add .gitignore

This commit is contained in:
2025-10-09 15:07:02 +02:00
commit 20f5301bb1
2848 changed files with 1315858 additions and 0 deletions

View File

@ -0,0 +1,76 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_MATH_RESTITUTION_FFT_H
#define SEISCOMP_MATH_RESTITUTION_FFT_H
#include <complex>
#include <vector>
#include <seiscomp/math/math.h>
#include <seiscomp/math/restitution/types.h>
#include <seiscomp/math/restitution/transferfunction.h>
namespace Seiscomp {
namespace Math {
namespace Restitution {
// Transforms a time series into the spectra, deconvolves it with the
// transfer function and transforms the spectra back into the time series.
// The spectra is tapered before min_freq and after max_freq. min_freq or
// max_freq has to be greater than 0 otherwise the tapering on the
// corresponding end is disabled.
template <typename T>
bool transformFFT(int n, T *inout, double fsamp, const FFT::TransferFunction *tf,
double cutoff, double min_freq, double max_freq);
template <typename T>
bool transformFFT(std::vector<T> &inout, double fsamp, const FFT::TransferFunction *tf,
double cutoff, double min_freq, double max_freq) {
return transformFFT(inout.size(), &inout[0], fsamp, tf, cutoff, min_freq, max_freq);
}
template <typename T>
bool transformFFT(int n, T *inout, double fsamp, int n_poles, SeismometerResponse::Pole *poles,
int n_zeros, SeismometerResponse::Zero *zeros, double norm,
double cutoff, double min_freq, double max_freq) {
FFT::PolesAndZeros paz(n_poles, poles, n_zeros, zeros, norm);
return transformFFT(n, inout, fsamp, &paz, cutoff, min_freq, max_freq);
}
template <typename T>
bool transformFFT(std::vector<T> &inout, double fsamp, const Poles &poles,
const Zeros &zeros, double norm, double cutoff,
double min_freq, double max_freq) {
return transformFFT(inout.size(), &inout[0], poles.size(), &poles[0],
zeros.size(), &zeros[0], norm, cutoff, min_freq, max_freq);
}
}
}
}
#endif

View File

@ -0,0 +1,117 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEIS_SIGNAL_TDRESTITUTION_H
#define SEIS_SIGNAL_TDRESTITUTION_H
#include <math.h>
#include <seiscomp/math/filter.h>
#include <seiscomp/math/filter/butterworth.h>
namespace Seiscomp {
namespace Math {
namespace Restitution {
// subroutines to compute parameters for the recursive filter
// from seismometer eigenperiod T0 and damping parameter h bool
bool coefficients_from_T0_h(double fsamp, double gain, double T0, double h, double *c0, double *c1, double *c2);
// from the two seismometer eigenperiods T1 and T2
bool coefficients_from_T1_T2(double fsamp, double gain, double T1, double T2, double *c0, double *c1, double *c2);
template<typename TYPE>
class TimeDomain : public Filtering::InPlaceFilter<TYPE> {
public:
TimeDomain();
~TimeDomain();
// configuration
void setBandpass(int order, double fmin, double fmax);
void setSamplingFrequency(double fsamp);
void setCoefficients(double c0, double c1, double c2);
virtual int setParameters(int n, const double *params);
virtual void reset() {}
virtual void apply(int n, TYPE *inout);
virtual std::string print() const;
protected:
virtual void init();
protected:
// configuration
double c0, c1, c2;
double fsamp, dt;
double gain;
private:
// filter configuration
int order;
double fmin, fmax;
// temp variables
double y0, y1, y2, a1, a2;
double cumsum1, cumsum2;
Filtering::IIR::ButterworthHighLowpass<TYPE> *bandpass;
};
template<typename TYPE>
class TimeDomain_from_T0_h: public TimeDomain<TYPE> {
public:
TimeDomain_from_T0_h(double T0, double h, double gain, double fsamp=0);
void setBandpass(int order, double fmin, double fmax);
virtual std::string print() const;
Filtering::InPlaceFilter<TYPE>* clone() const;
protected:
virtual void init();
private:
// configuration
double T0, h;
};
template<typename TYPE>
class TimeDomain_from_T1_T2: public TimeDomain<TYPE> {
public:
TimeDomain_from_T1_T2(double T1, double T2, double gain, double fsamp=0);
void setBandpass(int order, double fmin, double fmax);
virtual std::string print() const;
Filtering::InPlaceFilter<TYPE>* clone() const;
protected:
virtual void init();
private:
// configuration
double T1, T2;
};
} // namespace Seiscomp::Math::Restitution
} // namespace Seiscomp::Math
} // namespace Seiscomp
#endif

View File

@ -0,0 +1,139 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_MATH_RESTITUTION_TRANSFERFUNCTION_H
#define SEISCOMP_MATH_RESTITUTION_TRANSFERFUNCTION_H
#include <seiscomp/core/baseobject.h>
#include <seiscomp/math/math.h>
#include <seiscomp/math/filter/seismometers.h>
#include <seiscomp/math/restitution/types.h>
#include <vector>
#include <cstdlib>
namespace Seiscomp {
namespace Math {
namespace Restitution {
namespace FFT {
DEFINE_SMARTPOINTER(TransferFunction);
class TransferFunction : public Core::BaseObject {
public:
//! Returns a transfer function proxy object that acts as
//! the product of 'this' and 'a'.
//! Both input transfer function objects are referenced
//! through a pointer and not managed by the proxy.
TransferFunction *operator*(const TransferFunction &a) const;
//! Returns a transfer function proxy object that acts as
//! the quotient of 'this' and 'a'.
//! Both input transfer function objects are referenced
//! through a pointer and not managed by the proxy.
TransferFunction *operator/(const TransferFunction &a) const;
//! Evaluates the transfer function at nodes x and returns the
//! result in out. Out must have enough space for n samples.
void evaluate(Complex *out, int n, const double *x) const {
evaluate_(out, n, x);
}
void evaluate(std::vector<Complex> &out, const std::vector<double> &x) const {
out.resize(x.size());
evaluate_(&out[0], (int)x.size(), &x[0]);
}
//! Devides the spectra by the evaluated nodes of the transfer function
//! for {startFreq, startFreq + 1*df, ..., startFreq + (n-1)*df}
void deconvolve(int n, Complex *spec, double startFreq, double df) const {
deconvolve_(n, spec, startFreq, df);
}
//! Convenience wrapper using a vector as output
void deconvolve(std::vector<Complex> &spec, double startFreq, double df) const {
deconvolve_((int)spec.size(), &spec[0], startFreq, df);
}
//! Multiplies the spectra by the evaluated nodes of the transfer function
//! for {startFreq, startFreq + 1*df, ..., startFreq + (n-1)*df}
void convolve(int n, Complex *spec, double startFreq, double df) const {
convolve_(n, spec, startFreq, df);
}
//! Convenience wrapper using a vector as output
void convolve(std::vector<Complex> &spec, double startFreq, double df) const {
convolve_((int)spec.size(), &spec[0], startFreq, df);
}
protected:
//! The implementations
virtual void evaluate_(Complex *out, int n, const double *x) const = 0;
virtual void deconvolve_(int n, Complex *spec, double startFreq, double df) const;
virtual void convolve_(int n, Complex *spec, double startFreq, double df) const;
};
class PolesAndZeros : public TransferFunction {
public:
PolesAndZeros(const SeismometerResponse::PolesAndZeros &polesAndZeros);
PolesAndZeros(int n_poles, Pole *poles, int n_zeros, Zero *zeros, double k, int addZeros = 0);
protected:
void evaluate_(Complex *out, int n, const double *x) const;
void deconvolve_(int n, Complex *spec, double startFreq, double df) const;
void convolve_(int n, Complex *spec, double startFreq, double df) const;
public:
SeismometerResponse::PolesAndZeros paz;
};
/**
* @brief The ResponseList class evaluates a FAP response list. Phase angles
* are expected in degrees.
*/
class ResponseList : public TransferFunction {
public:
ResponseList(const SeismometerResponse::FAPs &faps, int addZeros = 0);
ResponseList(int n_tuples, const SeismometerResponse::FAP *faps, int addZeros = 0);
protected:
void evaluate_(Complex *out, int n, const double *x) const;
void deconvolve_(int n, Complex *spec, double startFreq, double df) const;
void convolve_(int n, Complex *spec, double startFreq, double df) const;
public:
SeismometerResponse::FAPs faps;
int nZeros;
};
}
}
}
}
#endif

View File

@ -0,0 +1,43 @@
/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_MATH_RESTITUTION_TYPES_H
#define SEISCOMP_MATH_RESTITUTION_TYPES_H
namespace Seiscomp {
namespace Math {
namespace Restitution {
typedef std::complex<double> Pole;
typedef std::complex<double> Zero;
typedef std::vector<Pole> Poles;
typedef std::vector<Zero> Zeros;
}
}
}
#endif