Commit 21d5de65 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libtsxx, tidofi [FIX]: take return value of filter function

Take the return value in order to allow for a change in number of samples
parent d67e8ae6
...@@ -29,11 +29,13 @@ ...@@ -29,11 +29,13 @@
* REVISIONS and CHANGES * REVISIONS and CHANGES
* - 05/07/2005 V1.0 Thomas Forbriger * - 05/07/2005 V1.0 Thomas Forbriger
* - 18/12/2007 V1.1 - support debugging * - 18/12/2007 V1.1 - support debugging
* - 25/02/2019 V1.2 - pass return value to filter, to allow for change
* in number of samples or sampling interval
* *
* ============================================================================ * ============================================================================
*/ */
#define TF_FILTERBASE_CC_VERSION \ #define TF_FILTERBASE_CC_VERSION \
"TF_FILTERBASE_CC V1.1" "TF_FILTERBASE_CC V1.2"
#include <iostream> #include <iostream>
#include <tsxx/filterbase.h> #include <tsxx/filterbase.h>
...@@ -46,17 +48,18 @@ namespace ts { ...@@ -46,17 +48,18 @@ namespace ts {
Ttimeseries FilterCollection::operator()(const Ttimeseries& s, Ttimeseries FilterCollection::operator()(const Ttimeseries& s,
const bool& debug) const const bool& debug) const
{ {
Ttimeseries retval(s);
Tfilterlist::const_iterator i=this->Tfilterlist::begin(); Tfilterlist::const_iterator i=this->Tfilterlist::begin();
while (i!=this->Tfilterlist::end()) while (i!=this->Tfilterlist::end())
{ {
TSXX_debug(debug, "FilterCollection::operator()", TSXX_debug(debug, "FilterCollection::operator()",
"apply filter" ); "apply filter" );
(*i)->operator()(s, debug); retval=(*i)->operator()(retval, debug);
++i; ++i;
} }
TSXX_debug(debug, "FilterCollection::operator()", TSXX_debug(debug, "FilterCollection::operator()",
"applied all filters" ); "applied all filters" );
return s; return retval;
} }
void Exception::report() const { void Exception::report() const {
......
...@@ -36,11 +36,14 @@ ...@@ -36,11 +36,14 @@
* - write header data only if supported by output * - write header data only if supported by output
* format * format
* - implemented offset variable tapers * - implemented offset variable tapers
* - 25.02.2019 V1.6 take return value of filter function in order to
* allow a change of number of samples or sampling
* interval
* *
* ============================================================================ * ============================================================================
*/ */
#define TIDOFI_VERSION \ #define TIDOFI_VERSION \
"TIDOFI V1.5 time domain filter" "TIDOFI V1.6 time domain filter"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
...@@ -528,7 +531,7 @@ int main(int iargc, char* argv[]) ...@@ -528,7 +531,7 @@ int main(int iargc, char* argv[])
=prefiltertaper.taper(offset, t0, T); =prefiltertaper.taper(offset, t0, T);
taper.apply(series); taper.apply(series);
} }
filter(Ttimeseries(series, wid2.dt), opt.debug); series=filter(Ttimeseries(series, wid2.dt), opt.debug);
if (applypostfiltertaper) if (applypostfiltertaper)
{ {
// apply post-filter taper // apply post-filter taper
...@@ -551,6 +554,7 @@ int main(int iargc, char* argv[]) ...@@ -551,6 +554,7 @@ int main(int iargc, char* argv[])
{ {
if (opt.verbose) { std::cout << " passed unchanged" << std::endl; } if (opt.verbose) { std::cout << " passed unchanged" << std::endl; }
} }
wid2.nsamples=series.size();
os << wid2; os << wid2;
TFXX_debug(opt.debug, "main", TFXX_debug(opt.debug, "main",
" series and WID are written"); " series and WID are written");
......
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