aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-08-10 16:02:01 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:36 +0100
commit7f2f2275e0d40873925d03075eae91f2bbba9ce3 (patch)
treee1891d26e6c71e36929a0692759c78b62c34330e
parent17147f4760f7d8be2bfc4d3ba77b7424f9501f49 (diff)
Simplify determination of axis length from FFT output
-rw-r--r--src/reax.c50
1 files changed, 11 insertions, 39 deletions
diff --git a/src/reax.c b/src/reax.c
index 2985f121..a76e394e 100644
--- a/src/reax.c
+++ b/src/reax.c
@@ -102,56 +102,28 @@ static void walk_graph(double *x, double *y, double *z, int smin, int smax,
fftw_complex *fft_out, int nel, double pmax,
double modv_exp)
{
- int i, s, mult;
+ int i, s;
double max, modv;
- FILE *fh = fopen("fft.dat", "w");
- for ( i=0; i<nel/2+1; i++ ) {
+ s = -1;
+ max = 0.0;
+ for ( i=smin; i<=smax; i++ ) {
+
double re, im, m;
+
re = fft_out[i][0];
im = fft_out[i][1];
m = sqrt(re*re + im*im);
- fprintf(fh, "%i %f\n", i, m);
- }
- fclose(fh);
-
- //*x *= modv_exp; *y *= modv_exp; *z *= modv_exp;
- //return;
-
- mult = 1;
- do {
-
- double new_s;
-
- s = -1;
- max = 0.0;
- for ( i=smin; i<=smax; i++ ) {
- double re, im, m;
- re = fft_out[i][0];
- im = fft_out[i][1];
- m = sqrt(re*re + im*im);
- if ( m > max ) {
- max = m;
- s = i;
- }
+ if ( m > max ) {
+ max = m;
+ s = i;
}
- assert(s>0);
- //STATUS("Estimated axis length:%.5f nm\n",
- // (idx_to_m(s)/mult)*1e9);
-
- new_s = (double)s*(mult+1)/mult;
- smin = new_s - 1;
- smax = new_s + 1;
- mult++;
-
- } while ( mult<5 );
+ }
+ assert(s>0);
modv = 2.0*pmax / (double)s;
- modv *= mult-1;
*x *= modv; *y *= modv; *z *= modv;
-
- //exit(1);
}