你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-05 20:16:52 +08:00
Added functionality to better handle divide by zero error when taking log10.
这个提交包含在:
@@ -83,7 +83,14 @@ ax.annotate('Ground', xy=(np.deg2rad(270), 0), xytext=(8, -15), textcoords='offs
|
||||
for patt in range(0, len(radii)):
|
||||
pattplot = np.append(patterns[patt, :], patterns[patt, 0]) # Append start value to close circle
|
||||
pattplot = pattplot / np.max(np.max(patterns)) # Normalise, based on set of patterns
|
||||
ax.plot(theta, 10 * np.log10(pattplot), label='{:.2f}m'.format(radii[patt]), marker='.', ms=6, lw=1.5)
|
||||
|
||||
# Calculate power (ignore warning from taking a log of any zero values)
|
||||
with np.errstate(divide='ignore'):
|
||||
power = 10 * np.log10(pattplot)
|
||||
# Replace any NaNs or Infs from zero division
|
||||
power[np.invert(np.isfinite(power))] = 0
|
||||
|
||||
ax.plot(theta, power, label='{:.2f}m'.format(radii[patt]), marker='.', ms=6, lw=1.5)
|
||||
|
||||
# Add Hertzian dipole plot
|
||||
# hertzplot1 = np.append(hertzian[0, :], hertzian[0, 0]) # Append start value to close circle
|
||||
|
@@ -13,8 +13,6 @@ import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from scipy import signal
|
||||
|
||||
np.seterr(divide='ignore')
|
||||
|
||||
from gprMax.exceptions import GeneralError
|
||||
|
||||
"""This module contains fitness metric functions that can be used with the Taguchi optimisation method.
|
||||
@@ -183,9 +181,14 @@ def min_sum_diffs(filename, args):
|
||||
if output.attrs['Name'] in args['outputs']:
|
||||
outputname = list(output.keys())[0]
|
||||
modelresp = np.array(output[outputname])
|
||||
|
||||
# Calculate sum of differences
|
||||
tmp = 20 * np.log10(np.abs(modelresp - refresp) / np.amax(np.abs(refresp)))
|
||||
tmp = np.abs(np.sum(tmp[-np.isneginf(tmp)])) / len(tmp[-np.isneginf(tmp)])
|
||||
with np.errstate(divide='ignore'): # Ignore warning from taking a log of any zero values
|
||||
tmp = 20 * np.log10(np.abs(modelresp - refresp) / np.amax(np.abs(refresp)))
|
||||
# Replace any NaNs or Infs from zero division
|
||||
tmp[np.invert(np.isfinite(tmp))] = 0
|
||||
|
||||
tmp = np.abs(np.sum(tmp)) / len(tmp)
|
||||
diffdB += tmp
|
||||
outputs += 1
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户