优化多进程调用方式,减少进程间IO等待
这个提交包含在:
+20
-32
@@ -297,18 +297,10 @@ def call_fangwei(freq, sd, bathm, ssp, sed, base, azi, isPlot=False):
|
|||||||
czdetail.reflectCz = []
|
czdetail.reflectCz = []
|
||||||
return Pos.r.range, Pos.r.depth, TL[0, 0, :, :], bathm, Rays, czdetail
|
return Pos.r.range, Pos.r.depth, TL[0, 0, :, :], bathm, Rays, czdetail
|
||||||
|
|
||||||
def child(database, freq, lat, lon, sd, isPlot, i):
|
def child(freq, sd, isPlot, bathm, ssp, sed, base, azi, descript):
|
||||||
descripts = ["正北方向", "东北方向", "正东方向", "东南方向", "正南方向", "西南方向", "正西方向", "西北方向"]
|
ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, bathm, ssp, sed, base, azi,isPlot=isPlot)
|
||||||
theta = np.arange(0, 359, 45)
|
czdetail.descript = descript
|
||||||
[bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=theta[i])
|
return CzData(azi, ranges, depths, TL, bathym, Rays, czdetail)
|
||||||
if np.mean(bathm.d) < 2000:
|
|
||||||
# 不会出现会聚区
|
|
||||||
ddd=[]
|
|
||||||
return None
|
|
||||||
else:
|
|
||||||
ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, bathm, ssp, sed, base, azi=theta[i],isPlot=isPlot)
|
|
||||||
czdetail.descript = descripts[i]
|
|
||||||
return CzData(theta[i], ranges, depths, TL, bathym, Rays, czdetail)
|
|
||||||
|
|
||||||
def call_cz(database, freq, lat, lon, azi, sourceDepth=10, isPlot=False):
|
def call_cz(database, freq, lat, lon, azi, sourceDepth=10, isPlot=False):
|
||||||
sd = np.array([sourceDepth]) # Source depth
|
sd = np.array([sourceDepth]) # Source depth
|
||||||
@@ -322,32 +314,28 @@ def call_cz(database, freq, lat, lon, azi, sourceDepth=10, isPlot=False):
|
|||||||
''' 计算单个方向的会聚区 '''
|
''' 计算单个方向的会聚区 '''
|
||||||
if azi != None:
|
if azi != None:
|
||||||
[bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=azi)
|
[bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=azi)
|
||||||
if np.mean(bathm.d) < 2000:
|
if np.mean(bathm.d) >= 2000:
|
||||||
return None
|
|
||||||
else:
|
|
||||||
ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, bathm, ssp, sed, base, azi,
|
ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, bathm, ssp, sed, base, azi,
|
||||||
isPlot=isPlot)
|
isPlot=isPlot)
|
||||||
czdetail.descript = "{:.1f}°方向".format(azi)
|
czdetail.descript = "{:.1f}°方向".format(azi)
|
||||||
results.append(CzData(0, ranges, depths, TL, bathym, Rays, czdetail))
|
results.append(CzData(0, ranges, depths, TL, bathym, Rays, czdetail))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
''' 计算8个方向的会聚区 '''
|
''' 计算8个方向的会聚区 '''
|
||||||
[bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=0)
|
pool = Pool()
|
||||||
if bathm.d[0] < 2000:
|
applyResults = []
|
||||||
# file_cz_data.write("各个方位都不会出现会聚区")
|
descripts = ["正北方向", "东北方向", "正东方向", "东南方向", "正南方向", "西南方向", "正西方向", "西北方向"]
|
||||||
return results
|
theta = np.arange(0, 359, 45)
|
||||||
else:
|
for i in range(8):
|
||||||
pool = Pool(processes=8)
|
[bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=theta[i])
|
||||||
applyResults = []
|
if np.mean(bathm.d) >= 2000:
|
||||||
for pi in range(8):
|
applyResults.append(pool.apply_async(partial(child, freq, sd, isPlot), (bathm, ssp, sed, base, theta[i], descripts[i])))
|
||||||
applyResults.append(pool.apply_async(partial(child, database, freq, lat, lon, sd, isPlot), (pi,)))
|
# applyResults.append(pool.apply_async(partial(child, database, freq, lat, lon, sd, isPlot), (pi,)))
|
||||||
# pi=Process(target=child_0,args=(pi,))
|
pool.close()
|
||||||
# pi.start()
|
pool.join()
|
||||||
pool.close()
|
for applyResult in applyResults:
|
||||||
pool.join()
|
results.append(applyResult.get())
|
||||||
for applyResult in applyResults:
|
return results
|
||||||
results.append(applyResult.get())
|
|
||||||
return results
|
|
||||||
# timeIndex = '20190101'
|
# timeIndex = '20190101'
|
||||||
# # 设置时间段
|
# # 设置时间段
|
||||||
#
|
#
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户