Commit 1b48fef8 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

proceeding

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 2377
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 6d348fbd
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: fftwaff.cc,v 1.4 2007-09-12 07:43:03 tforb Exp $
* $Id: fftwaff.cc,v 1.5 2007-09-12 10:26:33 tforb Exp $
* \author Thomas Forbriger
* \date 11/07/2006
*
......@@ -13,13 +13,14 @@
*
* REVISIONS and CHANGES
* - 11/07/2006 V1.0 Thomas Forbriger
* - 12/09/2007 V1.1 first running version
*
* ============================================================================
*/
#define TF_FFTWAFF_CC_VERSION \
"TF_FFTWAFF_CC V1.0 "
"TF_FFTWAFF_CC V1.1"
#define TF_FFTWAFF_CC_CVSID \
"$Id: fftwaff.cc,v 1.4 2007-09-12 07:43:03 tforb Exp $"
"$Id: fftwaff.cc,v 1.5 2007-09-12 10:26:33 tforb Exp $"
#include <fourier/fftwaff.h>
#include <fourier/error.h>
......@@ -85,17 +86,13 @@ namespace fourier {
<< s.size() << " == " << Msize);
FOURIER_assert(int(s.size()) == Msize, "series has wrong size!");
Tspectrum retval(this->Msize/2+1);
/*
aff::Series<fftw_real> out(this->Msize);
aff::Series<fftw_real> in(this->Msize);
fftw_real* pout=out.pointer();
fftw_real* pin=in.pointer();
*/
fftw_real* pout=new fftw_real[Msize];
fftw_real* pin=new fftw_real[Msize];
TFXX_debug(debug, "DRFFTWAFF::operator()",
"processing arrays are created; copy in series");
//in.copyin(s);
in.copyin(s);
TFXX_debug(debug, "DRFFTWAFF::operator()",
"create plan forward");
......@@ -105,7 +102,6 @@ namespace fourier {
rfftw_one(Mplan_forward, pin, pout);
TFXX_debug(debug, "DRFFTWAFF::operator()",
"copy results to output");
/*
retval(0)=out(0);
for (int i=1; i<((Msize+1)/2); ++i)
{
......@@ -115,6 +111,7 @@ namespace fourier {
{
retval(Msize/2)=out(Msize/2);
}
/*
if (debug)
{
DUMP(s);
......@@ -123,8 +120,6 @@ namespace fourier {
DUMP(retval);
}
*/
delete[] pin;
delete[] pout;
TFXX_debug(debug, "DRFFTWAFF::operator()",
"finished; return");
return(retval);
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: fftwaff.h,v 1.3 2007-09-12 07:43:03 tforb Exp $
* $Id: fftwaff.h,v 1.4 2007-09-12 10:26:34 tforb Exp $
* \author Thomas Forbriger
* \date 11/07/2006
*
......@@ -15,6 +15,7 @@
*
* REVISIONS and CHANGES
* - 11/07/2006 V1.0 Thomas Forbriger
* - 12/09/2007 V1.1 first running version
*
* ============================================================================
*/
......@@ -23,12 +24,12 @@
#ifndef TF_FFTWAFF_H_VERSION
#define TF_FFTWAFF_H_VERSION \
"TF_FFTWAFF_H V1.0 "
"TF_FFTWAFF_H V1.1"
#define TF_FFTWAFF_H_CVSID \
"$Id: fftwaff.h,v 1.3 2007-09-12 07:43:03 tforb Exp $"
"$Id: fftwaff.h,v 1.4 2007-09-12 10:26:34 tforb Exp $"
#include<complex>
#include<rfftw.h>
#include<drfftw.h>
#include<aff/series.h>
namespace fourier {
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: foutra.cc,v 1.4 2007-09-12 07:43:04 tforb Exp $
* $Id: foutra.cc,v 1.5 2007-09-12 10:25:43 tforb Exp $
* \author Thomas Forbriger
* \date 25/07/2006
*
......@@ -13,13 +13,14 @@
*
* REVISIONS and CHANGES
* - 25/07/2006 V1.0 Thomas Forbriger
* - 12/09/2007 V1.1 this version produces correct spectra
*
* ============================================================================
*/
#define FOUTRA_VERSION \
"FOUTRA V1.0 Fourier transforms"
"FOUTRA V1.2 Fourier transforms"
#define FOUTRA_CVSID \
"$Id: foutra.cc,v 1.4 2007-09-12 07:43:04 tforb Exp $"
"$Id: foutra.cc,v 1.5 2007-09-12 10:25:43 tforb Exp $"
#include <iostream>
#include <tfxx/commandline.h>
......@@ -46,7 +47,7 @@ using std::endl;
struct Options {
bool verbose, overwrite, debug;
std::string inputformat;
bool amplitudespectrum, powerspectrum;
bool amplitudespectrum, powerspectrum, boxcartaper;
}; // struct Options
// values type to be used for samples
......@@ -74,6 +75,7 @@ int main(int iargc, char* argv[])
FOUTRA_VERSION "\n"
"usage: foutra [-v] [-o] [-type type] [-D]" "\n"
" [-amplitude] [-power]" "\n"
" [-boxcar]" "\n"
" outfile infile [t:T] [infile [t:T] ...]" "\n"
" or: foutra --help|-h" "\n"
};
......@@ -90,6 +92,9 @@ int main(int iargc, char* argv[])
"-v be verbose" "\n"
"-D debug mode" "\n"
"-o overwrite output" "\n"
"-boxcar apply boxcar taper (i.e. no taper; default is Hanning)" "\n"
"-amplitude calculate amplitude spectrum" "\n"
"-power calculate power spectrum" "\n"
"-type type select input file type" "\n"
};
......@@ -111,6 +116,8 @@ int main(int iargc, char* argv[])
{"amplitude",arg_no,"-"},
// 6: power spectrum
{"power",arg_no,"-"},
// 7: apply boxcar taper
{"boxcar",arg_no,"-"},
{NULL}
};
......@@ -146,6 +153,7 @@ int main(int iargc, char* argv[])
opt.debug=cmdline.optset(4);
opt.amplitudespectrum=cmdline.optset(5);
opt.powerspectrum=cmdline.optset(6);
opt.boxcartaper=cmdline.optset(7);
if (opt.verbose)
{ cout << FOUTRA_VERSION << endl << FOUTRA_CVSID << endl; }
......@@ -242,11 +250,11 @@ int main(int iargc, char* argv[])
// will be modified.
// apply taper
taper.apply(series);
if (!opt.boxcartaper) { taper.apply(series); }
// create FFTW processor
Tfft fft(series.size());
if (opt.amplitudespectrum)
if (opt.amplitudespectrum || opt.powerspectrum)
{
TFXX_debug(opt.debug, "main", "call FFT");
Tfft::Tspectrum coeff=fft(series, wid2.dt, opt.debug);
......@@ -259,22 +267,30 @@ int main(int iargc, char* argv[])
TFXX_debug(opt.debug, "main", "calculate modulus and copy");
while(S.valid() && C.valid())
{
*S = std::abs(*C);
*S = C->real()*C->real()+C->imag()*C->imag();
++S; ++C;
}
TFXX_debug(opt.debug, "main", "set series size");
wid2.nsamples=coeff.size();
if (opt.debug)
{
DUMP(series);
DUMP(coeff);
}
}
else if (opt.powerspectrum)
if (opt.amplitudespectrum)
{
TFXX_illegal;
aff::Iterator<Tseries> S(series);
while(S.valid())
{
*S = std::sqrt(*S);
++S;
}
}
// adjust sampling interval to frequency interval
wid2.dt=1./(wid2.dt*wid2.nsamples);
wid2.nsamples=series.size();
/*----------------------------------------------------------------------*/
os << series;
......
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