你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-06 12:36:51 +08:00
Improved parsing of float and int time values.
这个提交包含在:
@@ -429,15 +429,16 @@ def process_multicmds(multicmds, G):
|
||||
dy = round_value(float(tmp[7])/G.dy)
|
||||
dz = round_value(float(tmp[8])/G.dz)
|
||||
|
||||
# If number of iterations given
|
||||
try:
|
||||
time = int(tmp[9])
|
||||
# If real floating point value given
|
||||
if '.' in tmp[9] or 'e' in tmp[9]:
|
||||
if float(tmp[9]) > 0:
|
||||
time = round_value((float(tmp[9]) / G.dt)) + 1
|
||||
except:
|
||||
time = float(tmp[9])
|
||||
if time > 0:
|
||||
time = round_value((tmp[9] / G.dt)) + 1
|
||||
else:
|
||||
raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' time value must be greater than zero')
|
||||
# If number of iterations given
|
||||
else:
|
||||
time = int(tmp[9])
|
||||
|
||||
if xs < 0 or xs > G.nx:
|
||||
raise CmdInputError("'" + cmdname + ': ' + ' '.join(tmp) + "'" + ' the lower x-coordinate {:g}m is not within the model domain'.format(xs * G.dx))
|
||||
|
@@ -164,17 +164,20 @@ def process_singlecmds(singlecmds, G):
|
||||
if len(tmp) != 1:
|
||||
raise CmdInputError(cmd + ' requires exactly one parameter to specify the time window. Either in seconds or number of iterations.')
|
||||
tmp = tmp[0].lower()
|
||||
|
||||
# If number of iterations given
|
||||
try:
|
||||
tmp = int(tmp)
|
||||
G.timewindow = (tmp - 1) * G.dt
|
||||
G.iterations = tmp
|
||||
# If real floating point value given
|
||||
if '.' in tmp or 'e' in tmp:
|
||||
if float(tmp) > 0:
|
||||
G.timewindow = float(tmp)
|
||||
G.iterations = round_value((float(tmp) / G.dt)) + 1
|
||||
except:
|
||||
tmp = float(tmp)
|
||||
if tmp > 0:
|
||||
G.timewindow = tmp
|
||||
G.iterations = round_value((tmp / G.dt)) + 1
|
||||
else:
|
||||
raise CmdInputError(cmd + ' must have a value greater than zero')
|
||||
# If number of iterations given
|
||||
else:
|
||||
G.timewindow = (int(tmp) - 1) * G.dt
|
||||
G.iterations = int(tmp)
|
||||
if G.messages:
|
||||
print('Time window: {:g} secs ({} iterations)'.format(G.timewindow, G.iterations))
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户