Commit 9a45ed6c authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libpsdxx [WP][FIX]: make LogTaper produce correct values

parent 0ab36294
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <psdxx/helper.h> #include <psdxx/helper.h>
#include <psdxx/error.h> #include <psdxx/error.h>
#include <psdxx/debug.h>
#include <cmath> #include <cmath>
namespace psd { namespace psd {
...@@ -46,21 +47,22 @@ namespace psd { ...@@ -46,21 +47,22 @@ namespace psd {
{ {
PSDXX_assert(f.size()>2, PSDXX_assert(f.size()>2,
"at least three values of frequency are required"); "at least three values of frequency are required");
if (i==0) PSDXX_assert((i>=f.f()) && (i<=f.l()),
"index is out of range");
if (i==f.f())
{ {
this->Mloc=Flower_end; this->Mloc=Flower_end;
this->Mli=new psd::helper::LogIndex(f(f.f()), f(f.f()+1), f(f.f()+2)); this->Mli=new psd::helper::LogIndex(f(i), f(i+1), f(i+2));
} }
else if (i==(f.size()-1)) else if (i==f.l())
{ {
this->Mloc=Fupper_end; this->Mloc=Fupper_end;
this->Mli=new psd::helper::LogIndex(f(f.l()-2), f(f.l()-1), f(f.l())); this->Mli=new psd::helper::LogIndex(f(i-2), f(i-1), f(i));
} }
else else
{ {
this->Mloc=Fmiddle; this->Mloc=Fmiddle;
this->Mli=new psd::helper::LogIndex(f(f.f()+i-1), this->Mli=new psd::helper::LogIndex(f(i-1), f(i), f(i+1));
f(f.f()+i), f(f.f()+i+1));
} }
} // LogTaper::LogTaper(const psd::TDseries::Tcoc& f, } // LogTaper::LogTaper(const psd::TDseries::Tcoc& f,
// const unsigned int& i) // const unsigned int& i)
...@@ -89,7 +91,7 @@ namespace psd { ...@@ -89,7 +91,7 @@ namespace psd {
// taper is 1 for frequency index <= 0 // taper is 1 for frequency index <= 0
if ((rindex > 0.) && (rindex < 1.)) if ((rindex > 0.) && (rindex < 1.))
{ {
retval=0.5*(1.-std::sin(rindex*M_PI)); retval=0.5*(1.+std::cos(rindex*M_PI));
} }
else if (rindex <= 0.) else if (rindex <= 0.)
{ {
...@@ -101,9 +103,14 @@ namespace psd { ...@@ -101,9 +103,14 @@ namespace psd {
// index of center frequency is 2 // index of center frequency is 2
// index range is from +1 to +3 // index range is from +1 to +3
// taper is 1 for frequency index >= 2 // taper is 1 for frequency index >= 2
if ((rindex < 2.) && (rindex > 1.)) if ((rindex >= 1.) && (rindex < 2.))
{ {
retval=0.5*(1.-std::sin(rindex*M_PI)); retval=0.5*(1.+std::cos(rindex*M_PI));
/*
std::cerr << PSDXX_value(f) << " "
<< PSDXX_value(rindex) << " "
<< PSDXX_value(retval) << std::endl;
*/
} }
else if (rindex >= 2.) else if (rindex >= 2.)
{ {
...@@ -114,7 +121,7 @@ namespace psd { ...@@ -114,7 +121,7 @@ namespace psd {
{ {
// index of center frequency is 1 // index of center frequency is 1
// index range is from 0 to +2 // index range is from 0 to +2
if ((rindex > -2.) && (rindex < 2.)) if ((rindex > -0.) && (rindex < 2.))
{ {
retval=0.5*(1.-std::cos(rindex*M_PI)); retval=0.5*(1.-std::cos(rindex*M_PI));
} }
......
...@@ -20,7 +20,10 @@ set output 'logtaper.ps' ...@@ -20,7 +20,10 @@ set output 'logtaper.ps'
set logscale x set logscale x
unset logscale y unset logscale y
set mxtics 10 set mxtics 10
set grid set mytics 5
set grid xtics,ytics
set grid mxtics,mytics
set key left
set title 'LogTaper' set title 'LogTaper'
set xlabel 'frequency / Hz' set xlabel 'frequency / Hz'
set ylabel 'taper value' set ylabel 'taper value'
......
...@@ -153,9 +153,9 @@ int main(int iargc, char* argv[]) ...@@ -153,9 +153,9 @@ int main(int iargc, char* argv[])
if (opt.logtaper) if (opt.logtaper)
{ {
const int nsamples=300; const int nsamples=100;
cout << "test class LogTaper" << endl; cout << "test class LogTaper" << endl;
CODE( psd::TDseries linf=psd::lin_frequency(0.1,nsamples) ); CODE( psd::TDseries linf=psd::lin_frequency(0.01,nsamples*10) );
CODE( psd::TDseries logf=psd::log_frequency(0.1,nsamples,6) ); CODE( psd::TDseries logf=psd::log_frequency(0.1,nsamples,6) );
CODE( psd::helper::LogTaper logt(logf, opt.taperindex) ); CODE( psd::helper::LogTaper logt(logf, opt.taperindex) );
DUMP( logf ); DUMP( logf );
......
Markdown is supported
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