136 lines
3.7 KiB
C++
136 lines
3.7 KiB
C++
/********************************************************
|
|
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
|
|
*
|
|
* ANT is distributed under a dual licensing scheme. You can redistribute
|
|
* it and/or modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, either version 2
|
|
* of the License, or (at your option) any later version. You should have
|
|
* received a copy of the GNU Lesser General Public License along with this
|
|
* program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
|
* the ANT, please consider the option to obtain a commercial license for a
|
|
* fee. These licenses are offered by the ANT's original author. As a rule,
|
|
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
|
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
|
* to include some description of your company and the realm of its activities.
|
|
* Also add information on how to contact you by electronic and paper mail.
|
|
******************************************************/
|
|
|
|
#include "../lib/seismic.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
/*
|
|
gctl::SIG_UNIT c;
|
|
std::vector<gctl::SIG_UNIT> a(2);
|
|
a[0].delta = 0.1;
|
|
a[1].delta = 0.1;
|
|
a[0].val.resize(1001);
|
|
a[1].val.resize(1001);
|
|
|
|
a[0].t0.set_time("2010-10-01T12:24:34.340");
|
|
a[0].te = a[0].t0;
|
|
a[0].te.add_duration(100);
|
|
|
|
a[1].t0.set_time("2010-10-01T12:26:00.340");
|
|
a[1].te = a[1].t0;
|
|
a[1].te.add_duration(100);
|
|
|
|
double t;
|
|
for (size_t i = 0; i < a[0].val.size(); i++)
|
|
{
|
|
t = a[0].rt0 + a[0].delta*i;
|
|
a[0].val[i] = 10.0*sin(t*2.0*GCTL_Pi);
|
|
a[1].val[i] = 3.0*sin(t*2.0*GCTL_Pi) + 5.0*sin(t*1.0*GCTL_Pi);
|
|
}
|
|
|
|
c.merge_sig_units(a);
|
|
c.info();
|
|
c.plot();
|
|
|
|
c.resampling(0.5, gctl::Second);
|
|
c.info();
|
|
c.plot();
|
|
*/
|
|
/*
|
|
gctl::SIG_UNIT a;
|
|
a.delta = 0.01;
|
|
a.val.resize(1001);
|
|
|
|
double f1 = 10;
|
|
double f2 = 5;
|
|
double f3 = 2;
|
|
|
|
double t;
|
|
for (size_t i = 0; i < a.val.size(); i++)
|
|
{
|
|
t = a.rt0 + a.delta*i;
|
|
a.val[i] = 3.0*sin(t*2*GCTL_Pi*f1) + 5.0*sin(t*2*GCTL_Pi*f2) + 2.0*sin(t*2*GCTL_Pi*f3);
|
|
}
|
|
|
|
a.plot();
|
|
a.filter(gctl::LowPass, gctl::Hamming, 100, 3);
|
|
a.plot();
|
|
*/
|
|
|
|
gctl::SIG_UNIT a, b, c;
|
|
a.init(10001, 0.0, 0.01);
|
|
b.init(10001, 0.0, 0.01);
|
|
a.val.random_float(0.0, 0.02);
|
|
b.val.random_float(0.0, 0.02);
|
|
|
|
double f1 = 1.0/10.0;
|
|
|
|
double t;
|
|
for (size_t i = 0; i < a.val.size(); i++)
|
|
{
|
|
t = a.rt0 + a.delta*i;
|
|
if (t >= 10 && t <= 20) a.val[i] = sin(2.0*M_PI*t*f1);
|
|
if (t >= 60 && t <= 70) b.val[i] += sin(2.0*M_PI*t*f1);
|
|
|
|
}
|
|
//a.plot();
|
|
//b.plot();
|
|
|
|
gctl::SIG_UNIT xc;
|
|
xc.linear_cross_correlation(b, a);
|
|
//xc.plot("tmp.eps");
|
|
/*
|
|
gctl::array<gctl::SIG_UNIT> xcs(sigs.size() - 1);
|
|
for (size_t i = 0; i < sigs.size() -1 ; i++)
|
|
{
|
|
sigs[i].t0 = gctl::UTC_START;
|
|
sigs[i+1].t0 = gctl::UTC_START;
|
|
xcs[i].linear_cross_correlation(sigs[i], sigs[i+1]);
|
|
}
|
|
|
|
gctl::SIG_UNIT x;
|
|
x.stack_sig_units(xcs);
|
|
x.plot();
|
|
*/
|
|
//c.linear_cross_correlation(a, b);
|
|
//c.circular_cross_correlation(a, b);
|
|
//c.normalize();
|
|
//for (size_t i = 0; i < c.val.size(); i++)
|
|
//{
|
|
// std::cout << i*c.delta + c.st << " " << c.val[i] << "\n";
|
|
//}
|
|
/*
|
|
gctl::SIG_UNIT a;
|
|
a.init(10001, 0.0, 0.01);
|
|
a.val.random(0.0, 1.0);
|
|
|
|
double t;
|
|
for (size_t i = 0; i < a.val.size(); i++)
|
|
{
|
|
t = a.rt0 + a.delta*i;
|
|
a.val[i] += 3.0*sin(t*40.0*GCTL_Pi) + 5.0*sin(t*100.0*GCTL_Pi);
|
|
}
|
|
|
|
a.plot();
|
|
a.remove_mean(30);
|
|
a.plot();
|
|
*/
|
|
return 0;
|
|
} |