Fast Fourier Trasform Functions.
More...
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <direct.h>
#include "mgui.h"
#include "DAS_Spatram.h"
#include "dcl.h"
#include "dil.h"
#include "bil.h"
#include "DOAS.h"
Go to the source code of this file.
|
#define | SWAP(a, b) temp=(a);(a)=(b);(b)=temp |
|
|
int | CheckSpikes (int mod, double *tmp, int npix) |
|
int | FilterData (unsigned short *mat, int horpix, int verpix, int filw, int bp) |
|
void | four1 (double data[], unsigned long nn, int isign) |
|
void | realft (double data[], unsigned long n, int isign) |
|
int | RemoveSpikes (int mod, unsigned short *mat, int horpix, int verpix, int blindpix) |
| Removes Spikes on a measure. More...
|
|
int | SmoothingF (double *tmp, int npix, int pts) |
| Smoothing of 1D array. More...
|
|
Fast Fourier Trasform Functions.
- Author
- Daniele Bortoli
Definition in file FFT.c.
§ SWAP
#define SWAP |
( |
|
a, |
|
|
|
b |
|
) |
| temp=(a);(a)=(b);(b)=temp |
§ CheckSpikes()
int CheckSpikes |
( |
int |
mod, |
|
|
double * |
tmp, |
|
|
int |
npix |
|
) |
| |
Definition at line 348 of file FFT.c.
Referenced by RemoveSpikes().
351 double deltapoint = 0;
352 double deltapoint1 = 0;
356 for (i = 1;i<npix - 1;i++)
358 deltapoint = fabs( (
double)( (tmp[i+1] - tmp[i])/60000*100) );
359 deltapoint1 = fabs( (
double)( (tmp[i+1] - tmp[i+2])/60000*100) );
360 if( (deltapoint > 1.6) && (deltapoint1 > 1.6))
§ FilterData()
int FilterData |
( |
unsigned short * |
mat, |
|
|
int |
horpix, |
|
|
int |
verpix, |
|
|
int |
filw, |
|
|
int |
bp |
|
) |
| |
Definition at line 250 of file FFT.c.
References IDX, and SmoothingF().
Referenced by BuildLogRatio(), DB_Column(), and DrawAreaPlotCB().
257 unsigned long eln = (
unsigned long)(2 * (horpix - bp + 1)) ;
260 fd = fopen(
"FilterUS_In.tmp",
"w");
263 for(x = 0; x < horpix ; x++)
265 if ((x <= horpix - bp ) & (x > 1))
267 fprintf(fd,
"%04u ", x);
269 for(y = 0; y < verpix; y++)
271 fprintf(fd,
"%05u ", mat[y *
IDX + x]);
273 fprintf(fd,
"\n", NULL);
276 fprintf(fd,
"\n", NULL);
282 avect = (
double *) calloc( eln,
sizeof(
double));
283 else if((filw > 512) & (filw <1024))
284 avect = (
double *) calloc( 2*eln,
sizeof(
double));
285 else if((filw >= 1024) & (filw <2048))
286 avect = (
double *) calloc( 4*eln,
sizeof(
double));
292 for(y = 0; y < verpix; y++)
295 for(x = 0; x < horpix; x++)
297 if ((x < horpix - bp) & (x > 1))
299 avect[n] = (double)mat[y * (horpix) + x];
307 for(x = 0; x < horpix; x++)
309 if ((x < horpix - bp) & (x > 1))
311 mat[y * horpix + x] = (
unsigned int)avect[x - 1] ;
321 fd = fopen(
"FilterUS_Out.tmp",
"w");
325 for(x = 0; x < horpix ; x++)
327 if ((x <= horpix - bp ) & (x > 1))
329 fprintf(fd,
"%04u ", x);
331 for(y = 0; y < verpix; y++)
333 fprintf(fd,
"%05u ", mat[y *
IDX + x]);
335 fprintf(fd,
"\n", NULL);
338 fprintf(fd,
"\n", NULL);
int IDX
Number of sensible horizontal pixels.
int SmoothingF(double *tmp, int npix, int pts)
Smoothing of 1D array.
§ four1()
void four1 |
( |
double |
data[], |
|
|
unsigned long |
nn, |
|
|
int |
isign |
|
) |
| |
Definition at line 26 of file FFT.c.
References SWAP.
Referenced by realft().
34 unsigned long n,mmax,m,j,istep,i;
35 double wtemp,wr,wpr,wpi,wi,theta;
48 while (m >= 2 && j > m)
60 theta=isign*(6.28318530717959/mmax);
62 wpr = -2.0*wtemp*wtemp;
67 for (m=1;m<=mmax;m+=2)
69 for (i=m;i<=n;i+=istep)
73 tempi=wr*data[j+1]+wi*data[j];
75 data[j+1]=data[i+1]-tempi;
79 wr=(wtemp=wr)*wpr-wi*wpi+wr;
80 wi=wi*wpr+wtemp*wpi+wi;
unsigned int data[576]
Conversion data buffer 64 samples * 8 channels * 2 bytes.
§ realft()
void realft |
( |
double |
data[], |
|
|
unsigned long |
n, |
|
|
int |
isign |
|
) |
| |
Definition at line 95 of file FFT.c.
References c2, and four1().
Referenced by SmoothingF().
97 void four1(
double data[],
unsigned long nn,
int isign);
98 unsigned long i,i1,i2,i3,i4,np3;
99 double c1=0.5,
c2,h1r,h1i,h2r,h2i;
100 double wr,wi,wpr,wpi,wtemp,theta;
102 theta=3.141592653589793/(double) (n);
114 wtemp=sin(0.5*theta);
115 wpr = -2.0*wtemp*wtemp;
122 for (i=2;i<=(n/2)+1;i++)
124 i4=1+(i3=np3-(i2=1+(i1=i+i-1)));
129 data[i1]=h1r+wr*h2r-wi*h2i;
130 data[i2]=h1i+wr*h2i+wi*h2r;
131 data[i3]=h1r-wr*h2r+wi*h2i;
132 data[i4] = -h1i+wr*h2i+wi*h2r;
133 wr=(wtemp=wr)*wpr-wi*wpi+wr;
134 wi=wi*wpr+wtemp*wpi+wi;
void four1(double data[], unsigned long nn, int isign)
unsigned int data[576]
Conversion data buffer 64 samples * 8 channels * 2 bytes.
§ RemoveSpikes()
int RemoveSpikes |
( |
int |
mod, |
|
|
unsigned short * |
mat, |
|
|
int |
horpix, |
|
|
int |
verpix, |
|
|
int |
blindpix |
|
) |
| |
Removes Spikes on a measure.
- Parameters
-
mod | NOT USED (=0) |
*mat | source buffer |
horpix | horizontal pixels |
verpix | vertical pixels |
blindpix | blind pixels |
Definition at line 369 of file FFT.c.
References CheckSpikes(), and IDX.
Referenced by DrawAreaPlotCB().
375 unsigned long eln = (
unsigned long)(2 * (horpix - blindpix + 1)) ;
378 fd = fopen(
"Spikes.tmp",
"w");
381 for(x = 0; x < horpix ; x++)
383 if ((x <= horpix - blindpix ) & (x > 1))
385 fprintf(fd,
"%04u ", x);
387 for(y = 0; y < verpix; y++)
389 fprintf(fd,
"%05u ", mat[y *
IDX + x]);
391 fprintf(fd,
"\n", NULL);
394 fprintf(fd,
"\n", NULL);
399 avect = (
double *) calloc( eln,
sizeof(
double));
405 for(y = 0; y < verpix; y++)
408 for(x = 0; x < horpix; x++)
410 if ((x < horpix - blindpix) & (x > 1))
412 avect[n] = (double)mat[y * (horpix) + x];
420 for(x = 0; x < horpix; x++)
422 if ((x < horpix - blindpix) & (x > 1))
424 mat[y * horpix + x] = (
unsigned int)avect[x - 1] ;
434 fd = fopen(
"NoSpikes.tmp",
"w");
438 for(x = 0; x < horpix ; x++)
440 if ((x <= horpix - blindpix ) & (x > 1))
442 fprintf(fd,
"%04u ", x);
444 for(y = 0; y < verpix; y++)
446 fprintf(fd,
"%05u ", mat[y *
IDX + x]);
448 fprintf(fd,
"\n", NULL);
451 fprintf(fd,
"\n", NULL);
int IDX
Number of sensible horizontal pixels.
int CheckSpikes(int mod, double *tmp, int npix)
§ SmoothingF()
int SmoothingF |
( |
double * |
tmp, |
|
|
int |
npix, |
|
|
int |
pts |
|
) |
| |
Smoothing of 1D array.
- Parameters
-
*tmp | source buffer |
npix | number of elements of the array |
pts | smoothing window |
Definition at line 151 of file FFT.c.
References MMessageDialog(), and realft().
Referenced by FilterData(), SmoothData(), and SmoothFloatData().
159 long double y0, yn, FAC;
160 long double rn1, dummy, dummy1;
162 NMin = npix + 2 * pts;
175 kost = pow( (
double)pts / (
double)M, (
double)2.0);
180 rn1 = (double) (1.0 / (
double)(npix - 1));
187 for(i = 1; i<= npix;i++)
188 tmp[i] = tmp[i ] - rn1 * (y0 * (
double)(npix - i) + yn * (
double)(i - 1));
192 for(i = npix+1; i<M;i++)
199 tmp[1] = tmp[1] / MO2;
202 for (i=1; i <= (int) (MO2 - 1);i++)
206 if ((FAC > 0) | (FAC <0))
209 a = (1 - kost * pow((
double)i, (
double)2)) / MO2;
217 tmp[k] = FAC * tmp[k];
218 tmp[k + 1] = FAC * tmp[k + 1];
227 dummy = pow(((
double)0.25 * (
double)pts),(
double)2);
228 dummy1= (0.25 * pts) * (0.25 * pts);
229 a = (1 - pow(((
double)0.25 * (
double)pts),(
double)2)) / MO2;
233 tmp[2] = FAC * tmp[2];
241 for (i=1;i<=npix;i++)
243 tmp[i] = (tmp[i] + rn1 * (y0 * (
double)(npix - i) + yn * (
double)(i - 1)));
int MMessageDialog(const char *t, const char *msg, const char *btn1, const char *btn2,...)
void realft(double data[], unsigned long n, int isign)
§ DOAS
Definition at line 15 of file FFT.c.