你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 04:56:51 +08:00
Updated to merge and plot (in separate figure windows) multiple receiver points.
这个提交包含在:
@@ -30,8 +30,7 @@ args = parser.parse_args()
|
||||
|
||||
basefilename = args.basefilename
|
||||
modelruns = args.modelruns
|
||||
outputfile = basefilename + '_merge.out'
|
||||
path = '/rxs/rx1'
|
||||
outputfile = basefilename + '_merged.out'
|
||||
|
||||
# Combined output file
|
||||
fout = h5py.File(outputfile, 'w')
|
||||
@@ -39,16 +38,27 @@ fout = h5py.File(outputfile, 'w')
|
||||
# Add positional data for rxs
|
||||
for model in range(modelruns):
|
||||
fin = h5py.File(basefilename + str(model + 1) + '.out', 'r')
|
||||
availableoutputs = list(fin[path].keys())
|
||||
nrx = fin.attrs['nrx']
|
||||
|
||||
# Write properties for merged file on first iteration
|
||||
if model == 0:
|
||||
fout.attrs['Iterations'] = fin.attrs['Iterations']
|
||||
fout.attrs['dt'] = fin.attrs['dt']
|
||||
fields = fout.create_group(path)
|
||||
fout.attrs['nrx'] = fin.attrs['nrx']
|
||||
for rx in range(1, nrx + 1):
|
||||
path = '/rxs/rx' + str(rx)
|
||||
grp = fout.create_group(path)
|
||||
availableoutputs = list(fin[path].keys())
|
||||
for output in availableoutputs:
|
||||
fields[output] = np.zeros((fout.attrs['Iterations'], modelruns), dtype=fin[path + '/' + output].dtype)
|
||||
grp.create_dataset(output, (fout.attrs['Iterations'], modelruns), dtype=fin[path + '/' + output].dtype)
|
||||
|
||||
# For all receivers
|
||||
for rx in range(1, nrx + 1):
|
||||
path = '/rxs/rx' + str(rx) + '/'
|
||||
availableoutputs = list(fin[path].keys())
|
||||
# For all receiver outputs
|
||||
for output in availableoutputs:
|
||||
fields[path + '/' + output][:,model] = fin[path + '/' + output][:]
|
||||
fout[path + '/' + output][:,model] = fin[path + '/' + output][:]
|
||||
|
||||
fin.close()
|
||||
|
||||
|
@@ -33,36 +33,39 @@ args = parser.parse_args()
|
||||
|
||||
# Open output file and read some attributes
|
||||
f = h5py.File(args.outputfile, 'r')
|
||||
path = '/rxs/rx1'
|
||||
availableoutputs = list(f[path].keys())
|
||||
nrx = f.attrs['nrx']
|
||||
|
||||
# Check if requested output is in file
|
||||
if args.output not in availableoutputs:
|
||||
for rx in range(1, nrx + 1):
|
||||
path = '/rxs/rx' + str(rx) + '/'
|
||||
availableoutputs = list(f[path].keys())
|
||||
|
||||
# Check if requested output is in file
|
||||
if args.output not in availableoutputs:
|
||||
raise CmdInputError('{} output requested to plot, but the available output for receiver 1 is {}'.format(args.output, ', '.join(availableoutputs)))
|
||||
|
||||
outputdata = f[path + '/' + args.output]
|
||||
outputdata = f[path + '/' + args.output]
|
||||
|
||||
# Check that there is more than one A-scan present
|
||||
if outputdata.shape[1] == 1:
|
||||
# Check that there is more than one A-scan present
|
||||
if outputdata.shape[1] == 1:
|
||||
raise CmdInputError('{} contains only a single A-scan.'.format(args.outputfile))
|
||||
|
||||
# Plot B-scan image
|
||||
fig = plt.figure(num=args.outputfile, figsize=(20, 10), facecolor='w', edgecolor='w')
|
||||
plt.imshow(outputdata, extent=[0, outputdata.shape[1], outputdata.shape[0]*f.attrs['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.grid()
|
||||
cb = plt.colorbar()
|
||||
if 'E' in args.output:
|
||||
# Plot B-scan image
|
||||
fig = plt.figure(num='rx' + str(rx), figsize=(20, 10), facecolor='w', edgecolor='w')
|
||||
plt.imshow(outputdata, extent=[0, outputdata.shape[1], outputdata.shape[0]*f.attrs['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.grid()
|
||||
cb = plt.colorbar()
|
||||
if 'E' in args.output:
|
||||
cb.set_label('Field strength [V/m]')
|
||||
elif 'H' in args.output:
|
||||
elif 'H' in args.output:
|
||||
cb.set_label('Field strength [A/m]')
|
||||
elif 'I' in args.output:
|
||||
elif 'I' in args.output:
|
||||
cb.set_label('Current [A]')
|
||||
|
||||
# Save a PDF/PNG of the figure
|
||||
#fig.savefig(os.path.splitext(os.path.abspath(file))[0] + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
|
||||
#fig.savefig(os.path.splitext(os.path.abspath(file))[0] + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
|
||||
# Save a PDF/PNG of the figure
|
||||
#fig.savefig(os.path.splitext(os.path.abspath(file))[0] + '.pdf', dpi=None, format='pdf', bbox_inches='tight', pad_inches=0.1)
|
||||
#fig.savefig(os.path.splitext(os.path.abspath(file))[0] + '.png', dpi=150, format='png', bbox_inches='tight', pad_inches=0.1)
|
||||
|
||||
plt.show()
|
||||
f.close()
|
||||
|
在新工单中引用
屏蔽一个用户