Commit 17a51913 authored by flechsig's avatar flechsig
Browse files

improved call of subfunctions

parent 1aad184d
......@@ -74,7 +74,6 @@ void autorange(double *data, int rows, int cols, int logscale)
// apply fftshift,
// parameter outphase determines output data (amplitude, phase, unwrapped phase)
void evalfft2d(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_out)
//double *data, int rows, int cols, int outphase)
{
fftw_complex *in, *out;
fftw_plan p1;
......@@ -93,7 +92,6 @@ void evalfft2d(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_ou
cols= put_in->width;
data= put_out->amp.data; // Array address= 1
idxmax= rows* cols;
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * idxmax);
......@@ -106,10 +104,9 @@ void evalfft2d(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_ou
in[idxc][1]= 0.0; // im[idxc];
}
fftw_execute(p1); // forward fft(-1)
fftw_execute(p1); // forward fft(-1)
fftshift2d(out, rows, cols); // center output
for (idxc= 0; idxc< idxmax; idxc++)
{
amp= sqrt(pow(out[idxc][0], 2)+ pow(out[idxc][1], 2));
......@@ -121,8 +118,6 @@ void evalfft2d(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_ou
put_out->dphi_wrap.copy(&put_out->dphi_unwrap);
unwrap_phase(put_out->dphi_unwrap.data, rows, cols); // call Herra
fftw_destroy_plan(p1); // clean up
fftw_free(in);
fftw_free(out);
......@@ -222,7 +217,6 @@ void evaluf(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_out)
cols= put_in->width;
data= put_out->amp.data; // Array address= 1
// cstp->direction= COLDIR; // evaluate horizontal cuts
switch (cstp->minor) // minor calculation mode
......@@ -237,34 +231,33 @@ void evaluf(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_out)
break;
case 2: // fft(-1)
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp); // fft stuff
eval1d(data, rows, cols, cstp); // fft stuff
autorange(data, rows, cols, cstp->logscale); // cstp->logscale
overlay(data, rows, cols, cstp->center, cstp->width, (double)val4overlay, cstp->direction); // add a overlay
break;
case 3: // filter
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp); // fft stuff
eval1d(data, rows, cols, cstp); // fft stuff
autorange(data, rows, cols, cstp->logscale);
break;
case 4: // shift
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp); // fft stuff
eval1d(data, rows, cols, cstp); // fft stuff
autorange(data, rows, cols, cstp->logscale);
break;
case 5: // FFT(1)
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp);// fft stuff
eval1d(data, rows, cols, cstp);// fft stuff
autorange(data, rows, cols, cstp->logscale);
break;
case 6: // no scaling
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp); // fft stuff
eval1d(data, rows, cols, cstp); // fft stuff
break;
default:
cout << "error: undefined minor mode, minor= " << cstp->minor << endl;
}
if (cstp->direction == COLDIR)
{
put_out->hp.resize(1, cols);
......@@ -344,28 +337,28 @@ void evaluf_zp(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_ou
break;
case 2: // fft(-1)
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d_zp(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp); // fft stuff
eval1d_zp(data, rows, cols, cstp); // fft stuff
autorange(data, rows, cols, cstp->logscale); // logscale
overlay(data, rows, cols, cstp->center, cstp->width, (double)val4overlay, cstp->direction); // add a overlay
break;
case 3: // filter
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d_zp(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp); // fft stuff
eval1d_zp(data, rows, cols, cstp); // fft stuff
autorange(data, rows, cols, cstp->logscale);
break;
case 4: // shift
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d_zp(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp); // fft stuff
eval1d_zp(data, rows, cols, cstp); // fft stuff
autorange(data, rows, cols, cstp->logscale);
break;
case 5: // FFT(1)
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d_zp(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp);// fft stuff
eval1d_zp(data, rows, cols, cstp);// fft stuff
autorange(data, rows, cols, cstp->logscale);
break;
case 6: // no scaling
hanning(data, rows, cols, cstp->direction); // hanning filter
eval1d_zp(data, rows, cols, cstp->direction, cstp->minor, cstp->outphase, cstp->center, cstp->width, cstp); // fft stuff
eval1d_zp(data, rows, cols, cstp); // fft stuff
break;
default:
cout << "error: undefined minor mode, minor= " << cstp->minor << endl;
......@@ -411,12 +404,19 @@ void evaluf_zp(Matrix *put_in, struct ConfigStruct *cstp, struct Xgi_out *put_ou
} // end evaluf_zp()
// makes a 1d fft, default is cols plus other treatment
void eval1d(double *data, int rows, int cols, int rowdir, int minor, int outphase, int center, int width, struct ConfigStruct *cs)
void eval1d(double *data, int rows, int cols, struct ConfigStruct *cs)
{
fftw_complex *in, *out;
fftw_plan p1, p2;
size_t arrsize;
int row, col, idxc;
int rowdir, minor, outphase, center, width;
rowdir= cs->direction;
minor= cs->minor;
outphase= cs->outphase;
center= cs->center;
width= cs->width;
#ifdef DEBUG
cout << "eval1d called" << endl;
......@@ -538,17 +538,24 @@ void eval1d(double *data, int rows, int cols, int rowdir, int minor, int outphas
// makes a 1d fft, default is cols plus other treatment incl zero padding
void eval1d_zp(double *data, int rows, int cols, int rowdir, int minor, int outphase, int center, int width, struct ConfigStruct *cs)
void eval1d_zp(double *data, int rows, int cols, struct ConfigStruct *cs)
{
fftw_complex *in, *out;
fftw_plan p1, p2;
size_t arrsize;
int row, col, i, i0, len0, imax, fftlen[8]= {64, 128, 256, 512, 1024, 2048, 4096, 8192};
int rowdir, minor, outphase, center, width;
#ifdef DEBUG
cout << "eval1d_zp called" << endl;
#endif
rowdir= cs->direction;
minor= cs->minor;
outphase= cs->outphase;
center= cs->center;
width=cs->width;
len0= (rowdir) ? rows : cols;
i= 0;
while ((i < 8) && (fftlen[i] < len0)) i++;
......@@ -739,8 +746,6 @@ void filter1d(fftw_complex *arr0, int cols, int movecenter, int center, int widt
fftw_free(arr1);
} // filter1d
// 1d hanning taper in rows of cols (cols is default)
void hanning(double *data, int rows, int cols, int rowdir)
{
......
......@@ -35,8 +35,8 @@ struct ConfigStruct {
bool is_file_exist(const char *);
double linreg(int, double *, double *, double *, double *);
void autorange(double *, int, int, int);
void eval1d(double *, int, int, int, int, int, int, int, struct ConfigStruct *);
void eval1d_zp(double *, int, int, int, int, int, int, int, struct ConfigStruct *);
void eval1d(double *, int, int, struct ConfigStruct *);
void eval1d_zp(double *, int, int, struct ConfigStruct *);
void evalfft2d(Matrix *, struct ConfigStruct *, struct Xgi_out *);
void evalfft_ifft_2d(Matrix *, struct ConfigStruct *, struct Xgi_out *);
void evaluf(Matrix *, struct ConfigStruct *, struct Xgi_out *);
......
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