diff --git a/pyat/czcore.py b/pyat/czcore.py index 34aa5a1..f62c687 100644 --- a/pyat/czcore.py +++ b/pyat/czcore.py @@ -297,18 +297,10 @@ def call_fangwei(freq, sd, bathm, ssp, sed, base, azi, isPlot=False): czdetail.reflectCz = [] return Pos.r.range, Pos.r.depth, TL[0, 0, :, :], bathm, Rays, czdetail -def child(database, freq, lat, lon, sd, isPlot, 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, bathm, ssp, sed, base, azi=theta[i],isPlot=isPlot) - czdetail.descript = descripts[i] - return CzData(theta[i], ranges, depths, TL, bathym, Rays, czdetail) +def child(freq, sd, isPlot, bathm, ssp, sed, base, azi, descript): + ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, bathm, ssp, sed, base, azi,isPlot=isPlot) + czdetail.descript = descript + return CzData(azi, ranges, depths, TL, bathym, Rays, czdetail) def call_cz(database, freq, lat, lon, azi, sourceDepth=10, isPlot=False): 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: [bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=azi) - if np.mean(bathm.d) < 2000: - return None - else: + if np.mean(bathm.d) >= 2000: ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, bathm, ssp, sed, base, azi, isPlot=isPlot) czdetail.descript = "{:.1f}°方向".format(azi) results.append(CzData(0, ranges, depths, TL, bathym, Rays, czdetail)) - return results + return results ''' 计算8个方向的会聚区 ''' - [bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=0) - if bathm.d[0] < 2000: - # file_cz_data.write("各个方位都不会出现会聚区") - return results - else: - pool = Pool(processes=8) - applyResults = [] - for pi in range(8): - applyResults.append(pool.apply_async(partial(child, database, freq, lat, lon, sd, isPlot), (pi,))) - # pi=Process(target=child_0,args=(pi,)) - # pi.start() - pool.close() - pool.join() - for applyResult in applyResults: - results.append(applyResult.get()) - return results + pool = Pool() + applyResults = [] + descripts = ["正北方向", "东北方向", "正东方向", "东南方向", "正南方向", "西南方向", "正西方向", "西北方向"] + theta = np.arange(0, 359, 45) + for i in range(8): + [bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=theta[i]) + if np.mean(bathm.d) >= 2000: + 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,))) + pool.close() + pool.join() + for applyResult in applyResults: + results.append(applyResult.get()) + return results # timeIndex = '20190101' # # 设置时间段 #