你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Update to use pathlib.
这个提交包含在:
@@ -17,8 +17,7 @@
|
||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import h5py
|
||||
import numpy as np
|
||||
@@ -42,13 +41,15 @@ def mpl_plot(filename, outputdata, dt, rxnumber, rxcomponent):
|
||||
plt (object): matplotlib plot object.
|
||||
"""
|
||||
|
||||
(path, filename) = os.path.split(filename)
|
||||
file = Path(filename)
|
||||
|
||||
fig = plt.figure(num=filename + ' - rx' + str(rxnumber), figsize=(20, 10), facecolor='w', edgecolor='w')
|
||||
plt.imshow(outputdata, extent=[0, outputdata.shape[1], outputdata.shape[0] * dt, 0], interpolation='nearest', aspect='auto', cmap='seismic', vmin=-np.amax(np.abs(outputdata)), vmax=np.amax(np.abs(outputdata)))
|
||||
fig = plt.figure(num=file.stem + ' - rx' + str(rxnumber), figsize=(20, 10),
|
||||
facecolor='w', edgecolor='w')
|
||||
plt.imshow(outputdata, extent=[0, outputdata.shape[1], outputdata.shape[0] * dt, 0],
|
||||
interpolation='nearest', aspect='auto', cmap='seismic',
|
||||
vmin=-np.amax(np.abs(outputdata)), vmax=np.amax(np.abs(outputdata)))
|
||||
plt.xlabel('Trace number')
|
||||
plt.ylabel('Time [s]')
|
||||
# plt.title('{}'.format(filename))
|
||||
|
||||
# Grid properties
|
||||
ax = fig.gca()
|
||||
@@ -63,9 +64,10 @@ def mpl_plot(filename, outputdata, dt, rxnumber, rxcomponent):
|
||||
cb.set_label('Current [A]')
|
||||
|
||||
# Save a PDF/PNG of the figure
|
||||
# savefile = os.path.splitext(filename)[0]
|
||||
# fig.savefig(path + os.sep + savefile + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
|
||||
# fig.savefig(path + os.sep + savefile + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
|
||||
# fig.savefig(file.with_suffix('.pdf'), dpi=None, format='pdf',
|
||||
# bbox_inches='tight', pad_inches=0.1)
|
||||
# fig.savefig(file.with_suffix('.png'), dpi=150, format='png',
|
||||
# bbox_inches='tight', pad_inches=0.1)
|
||||
|
||||
return plt
|
||||
|
||||
@@ -73,9 +75,11 @@ def mpl_plot(filename, outputdata, dt, rxnumber, rxcomponent):
|
||||
if __name__ == "__main__":
|
||||
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(description='Plots a B-scan image.', usage='cd gprMax; python -m tools.plot_Bscan outputfile output')
|
||||
parser = argparse.ArgumentParser(description='Plots a B-scan image.',
|
||||
usage='cd gprMax; python -m tools.plot_Bscan outputfile output')
|
||||
parser.add_argument('outputfile', help='name of output file including path')
|
||||
parser.add_argument('rx_component', help='name of output component to be plotted', choices=['Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz', 'Ix', 'Iy', 'Iz'])
|
||||
parser.add_argument('rx_component', help='name of output component to be plotted',
|
||||
choices=['Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz', 'Ix', 'Iy', 'Iz'])
|
||||
args = parser.parse_args()
|
||||
|
||||
# Open output file and read number of outputs (receivers)
|
||||
@@ -85,7 +89,7 @@ if __name__ == "__main__":
|
||||
|
||||
# Check there are any receivers
|
||||
if nrx == 0:
|
||||
raise CmdInputError('No receivers found in {}'.format(args.outputfile))
|
||||
raise CmdInputError(f'No receivers found in {args.outputfile}')
|
||||
|
||||
for rx in range(1, nrx + 1):
|
||||
outputdata, dt = get_output_data(args.outputfile, rx, args.rx_component)
|
||||
|
在新工单中引用
屏蔽一个用户