修改合并czcore冲突

这个提交包含在:
2023-04-07 10:18:43 +08:00
当前提交 93275af055
+28 -20
查看文件
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from multiprocessing import Process from multiprocessing import Process, Pool
from functools import partial
from os import system from os import system
import numpy as np import numpy as np
from AcousticPara import GetEnv, Coord from AcousticPara import GetEnv, Coord
@@ -296,35 +297,35 @@ 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, rd, i):
descripts = ["正北方向", "东北方向", "正东方向", "东南方向", "正南方向", "西南方向", "正西方向", "西北方向"]
theta = np.arange(0, 359, 45)
[bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=theta[i])
if np.mean(bathm.d) < 2000:
# 不会出现会聚区
ddd=[]
return None
else:
ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, rd, bathm, ssp, sed, base, azi=theta[i],isPlot=True)
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
results = [] results = []
ranges, depths, TL, bathym, Rays = [], [], [], [], [] ranges, depths, TL, bathym, Rays = [], [], [], [], []
def child(i):
descripts = ["正北方向", "东北方向", "正东方向", "东南方向", "正南方向", "西南方向", "正西方向", "西北方向"]
theta = np.arange(0, 359, 45)
[bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=theta[i])
if np.mean(bathm.d) < 2000:
# 不会出现会聚区
ddd=[]
else:
ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, bathm, ssp, sed, base, azi=theta[i],isPlot=isPlot)
czdetail.descript = descripts[i]
results.append(CzData(theta[i], ranges, depths, TL, bathym, Rays, czdetail))
return results
def child_0(interval): # def child_0(interval):
results=child(interval) # czdata=child(interval)
return results # return czdata
''' 计算单个方向的会聚区 ''' ''' 计算单个方向的会聚区 '''
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 results return None
else: 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, rd, 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))
@@ -336,7 +337,14 @@ def call_cz(database, freq, lat, lon, azi, sourceDepth=10, isPlot=False):
# file_cz_data.write("各个方位都不会出现会聚区") # file_cz_data.write("各个方位都不会出现会聚区")
return results return results
else: else:
pool = Pool(processes=8)
applyResults = []
for pi in range(8): for pi in range(8):
pi=Process(target=child_0,args=(pi,)) applyResults.append(pool.apply_async(partial(child, database, freq, lat, lon, sd, rd), (pi,)))
pi.start() # pi=Process(target=child_0,args=(pi,))
# pi.start()
pool.close()
pool.join()
for applyResult in applyResults:
results.append(applyResult.get())
return results return results