你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-06 12:36:51 +08:00
Changed name of module 'plot_builtin_wave' to 'plot_source_wave'. Add functionality to allow plotting (with FFT) in Jupyter notebooks of user-defined waveforms.
这个提交包含在:
@@ -83,14 +83,14 @@ Built-in waveforms
|
||||
|
||||
This section describes the definitions of the functions that are used to create the built-in waveforms, and how to plot them.
|
||||
|
||||
plot_builtin_wave.py
|
||||
plot_source_wave.py
|
||||
--------------------
|
||||
|
||||
This module uses matplotlib to plot one of the built-in waveforms and it's FFT. Usage (from the top-level gprMax directory) is:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
python -m tools.plot_builtin_wave type amp freq timewindow dt
|
||||
python -m tools.plot_source_wave type amp freq timewindow dt
|
||||
|
||||
where:
|
||||
|
||||
|
@@ -98,7 +98,7 @@
|
||||
"source": [
|
||||
"%matplotlib inline\n",
|
||||
"from gprMax.waveforms import Waveform\n",
|
||||
"from tools.plot_builtin_wave import check_timewindow, mpl_plot\n",
|
||||
"from tools.plot_source_wave import check_timewindow, mpl_plot\n",
|
||||
"\n",
|
||||
"w = Waveform()\n",
|
||||
"w.type = 'ricker'\n",
|
||||
|
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
@@ -81,8 +81,15 @@ def mpl_plot(w, timewindow, dt, iterations, fft=False):
|
||||
|
||||
print('Waveform characteristics...')
|
||||
print('Type: {}'.format(w.type))
|
||||
print('Amplitude: {:g}'.format(w.amp))
|
||||
print('Centre frequency: {:g} Hz'.format(w.freq))
|
||||
|
||||
if w.type == 'user':
|
||||
waveform = w.uservalues
|
||||
w.amp = np.max(np.abs(waveform))
|
||||
|
||||
print('Maximum amplitude: {:g}'.format(w.amp))
|
||||
|
||||
if w.freq:
|
||||
print('Centre frequency: {:g} Hz'.format(w.freq))
|
||||
|
||||
if w.type == 'gaussian' or w.type == 'gaussiandot' or w.type == 'gaussiandotdot':
|
||||
delay = 1 / w.freq
|
||||
@@ -110,6 +117,11 @@ def mpl_plot(w, timewindow, dt, iterations, fft=False):
|
||||
power -= np.amax(power)
|
||||
|
||||
# Set plotting range to 4 times centre frequency of waveform
|
||||
if w.type == 'user':
|
||||
fmaxpower = np.where(power == 0)[0][0]
|
||||
w.freq = freqs[fmaxpower]
|
||||
print('Centre frequency: {:g} Hz'.format(w.freq))
|
||||
|
||||
pltrange = np.where(freqs > 4 * w.freq)[0][0]
|
||||
pltrange = np.s_[0:pltrange]
|
||||
|
||||
@@ -149,7 +161,7 @@ def mpl_plot(w, timewindow, dt, iterations, fft=False):
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(description='Plot built-in waveforms that can be used for sources.', usage='cd gprMax; python -m tools.plot_builtin_wave type amp freq timewindow dt')
|
||||
parser = argparse.ArgumentParser(description='Plot built-in waveforms that can be used for sources.', usage='cd gprMax; python -m tools.plot_source_wave type amp freq timewindow dt')
|
||||
parser.add_argument('type', help='type of waveform', choices=Waveform.types)
|
||||
parser.add_argument('amp', type=float, help='amplitude of waveform')
|
||||
parser.add_argument('freq', type=float, help='centre frequency of waveform')
|
在新工单中引用
屏蔽一个用户