-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwavelet_2d.py
executable file
·65 lines (46 loc) · 1.99 KB
/
wavelet_2d.py
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
import numpy as np
def select_wavelet(num):
if num == 0:
return gaussian_2d
if num == 1:
return ricker_2d
def gaussian_2d():
def gaussian_dx(points, scale):
xs = np.arange(0, np.sqrt(points)) - (np.sqrt(points) - 1.0) / 2
ys = np.arange(0, np.sqrt(points)) - (np.sqrt(points) - 1.0) / 2
output = np.empty((len(ys), len(xs)))
for j,y in enumerate(ys):
for i,x in enumerate(xs):
mod = x**2 + y**2
output[j][i] = -x/scale**2 * np.exp(-mod/(2*scale**2))
return output
def gaussian_dy(points, scale):
xs = np.arange(0, np.sqrt(points)) - (np.sqrt(points) - 1.0) / 2
ys = np.arange(0, np.sqrt(points)) - (np.sqrt(points) - 1.0) / 2
output = np.empty((len(ys), len(xs)))
for j,y in enumerate(ys):
for i,x in enumerate(xs):
mod = x**2 + y**2
output[j][i] = -y/scale**2 * np.exp(-mod/(2*scale**2))
return output
return gaussian_dx, gaussian_dy
def ricker_2d():
def ricker_dx(points, scale):
xs = np.arange(0, np.sqrt(points)) - (np.sqrt(points) - 1.0) / 2
ys = np.arange(0, np.sqrt(points)) - (np.sqrt(points) - 1.0) / 2
output = np.empty((len(ys), len(xs)))
for j,y in enumerate(ys):
for i,x in enumerate(xs):
mod = x**2 + y**2
output[j][i] = -x/scale**2 * (4 - mod/scale**2) * np.exp(-mod/(2*scale**2))
return output
def ricker_dy(points, scale):
xs = np.arange(0, np.sqrt(points)) - (np.sqrt(points) - 1.0) / 2
ys = np.arange(0, np.sqrt(points)) - (np.sqrt(points) - 1.0) / 2
output = np.empty((len(ys), len(xs)))
for j,y in enumerate(ys):
for i,x in enumerate(xs):
mod = x**2 + y**2
output[j][i] = -y/scale**2 * (4 - mod/scale**2) * np.exp(-mod/(2*scale**2))
return output
return ricker_dx, ricker_dy