-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathricker.c
74 lines (59 loc) · 1.73 KB
/
ricker.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* Ricker filter */
/*
Copyright (C) 2004 University of Texas at Austin
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <math.h>
#include <rsf.h>
#include "ricker.h"
static kiss_fft_cpx *shape;
void ricker_init(int nfft /* time samples */,
float freq /* frequency */,
int order /* derivative order */)
/*< initialize >*/
{
int iw, nw;
float dw, w;
kiss_fft_cpx cw;
/* determine frequency sampling (for real to complex FFT) */
nw = nfft/2+1;
dw = 1./(nfft*freq);
shape = (kiss_fft_cpx*) sf_complexalloc(nw);
for (iw=0; iw < nw; iw++) {
w = iw*dw;
w *= w;
switch (order) {
case 2: /* half-order derivative */
cw.r = 2*SF_PI/nfft;
cw.i = iw*2*SF_PI/nfft;
cw = sf_csqrtf(cw);
shape[iw].r = cw.r*w*expf(1-w)/nfft;
shape[iw].i = cw.i*w*expf(1-w)/nfft;
break;
case 0:
default:
shape[iw].r = w*expf(1-w)/nfft;
shape[iw].i = 0.;
break;
}
}
sf_freqfilt_init(nfft,nw);
sf_freqfilt_cset(shape);
}
void ricker_close(void)
/*< free allocated storage >*/
{
free(shape);
sf_freqfilt_close();
}
/* $Id$ */