-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnergyPotter.py
More file actions
156 lines (119 loc) · 5.79 KB
/
EnergyPotter.py
File metadata and controls
156 lines (119 loc) · 5.79 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
"""Класс для отображение энергии после обработки методом PMASW."""
import numpy as np
from matplotlib.ticker import FormatStrFormatter
class EnergyPlotter:
"""
Класс для отображения энергии после обработки методом PMASW.
Methods
-------
draw_seismogram(ax, data, dt, dx, scale=2, fontsize=18)
Отображение сеймограмм.
draw_vf2d(ax, spectrum, vel, freq, norm=True, fontsize=18)
Отображение зависимости энергии от скорости и частоты.
draw_f_theta(ax, f_theta, freq, thetas, norm=True, fontsize=18)
Отображение зависимости энергии от частоты и азимута.
"""
@staticmethod
def draw_seismogram(ax, data, dt, dx, scale=2, fontsize=18):
"""
Отображение сейсмограмм ислользуя matplotlib.
Parameters
----------
ax : matplotlib.axes._axes.Axes
Объект Axes, на котором будут отображены сейсмограммы.
data : ndarray[dtype: float64, dim = 2]
Массив сейсмограммы.
[tempor_axis, spatial_axis]
dt : float
Время дескретизации сиганала (в секундах).
dx : float | int
Пространственная дескретизация сейсмограммы (в метрах).
scale : optional | int | float, default = 2
Коэффициент мастабируемости для трасс.
fontsize : optional | int | float, default = 2
Размер шрифта подписей осей и отметок осей.
"""
nt, nx = data.shape
receivers = np.arange(0, nx * dx, dx)
for i in range(nx):
trace_norm = scale * data[:, i] / np.max(data[:, i])
tmp_offset = min(receivers) + dx * i
x = trace_norm + tmp_offset
time = np.arange(0, nt * dt, dt)[: len(x)]
ax.plot(x, time, color='k')
ax.set_ylim([nt * dt, 0])
ax.set_xlim([min(receivers) - dx, max(receivers) + dx])
ax.set_xlabel(r"$x$ (м)", fontsize=fontsize)
ax.set_ylabel(r"$t$ (с)", fontsize=fontsize)
ax.tick_params(axis='both', labelsize=fontsize)
ax.yaxis.set_major_formatter(FormatStrFormatter('%g'))
@staticmethod
def draw_vf2d(ax, spectrum, vel, freq, norm=True, fontsize=18):
"""
Отображение зависимости энергии от скорости и частоты.
Parameters
----------
ax : matplotlib.axes._axes.Axes
Объект Axes, на котором будут отображены сейсмограммы.
spectrum : ndarray[dtype: float64, dim = 2]
Энергия для скоростей и частот.
[vel_axis, freq_axis]
vel : ndarray[dtype: float64 | int32, dim = 1]
Массив фазовых скоростей.
freq : ndarray[dtype: float64 | int32, dim = 1]
Массив частот в Гц.
norm : optional | bool, defaul = True
Флаг нормализаии энергии вдоль оси частот.
fontsize : optional | int | float, default = 2
Размер шрифта подписей осей и отметок осей.
"""
if norm:
spectrum = spectrum / np.max(spectrum, axis=0)
ax.imshow(spectrum,
aspect='auto',
extent=(freq.min(),
freq.max(),
vel.min(),
vel.max()
),
cmap='RdYlBu_r',
origin='lower',
interpolation='gaussian')
ax.set_xlabel(r"$f$ (Гц)", fontsize=fontsize)
ax.set_ylabel(r"$V_R$ (м/с)", fontsize=fontsize)
ax.tick_params(axis='both', labelsize=fontsize)
@staticmethod
def draw_f_theta(ax, f_theta, freq, thetas, norm=True, fontsize=18):
"""
Отображение зависимости энергии от частоты и азимута.
Parameters
----------
ax : matplotlib.axes._axes.Axes
Объект Axes, на котором будут отображены сейсмограммы.
f_theta : ndarray[dtype: float64, dim = 2]
Энергия для скоростей и частот.
[vel_axis, freq_axis]
freq : ndarray[dtype: float64 | int32, dim = 1]
Массив частот в Гц.
thetas : ndarray[dtype: float64 | int32, dim = 1]
Массив азимутов в градусах.
norm : optional | bool, defaul = True
Флаг нормализаии энергии вдоль оси частот.
fontsize : optional | int | float, default = 2
Размер шрифта подписей осей и отметок осей.
"""
if norm:
f_theta = (f_theta.T / f_theta.T.max(axis=0)).T
ax.imshow(f_theta,
aspect='auto',
extent=(thetas.min(),
thetas.max(),
freq.max(),
freq.min()
),
cmap='RdYlBu_r',
interpolation='gaussian')
ax.set_xlabel("Азимут, $^o$", fontsize=fontsize)
ax.set_ylabel("Частота, Гц", fontsize=fontsize)
ax.tick_params(axis='both', labelsize=fontsize)
ax.invert_yaxis()