更改了bellhop.py文件中,nbeams的数目。
更改了czcore.py文件中,会聚区计算时进行并行运算。
这个提交包含在:
+1
-1
@@ -96,7 +96,7 @@ def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base):
|
|||||||
bdy = Bndry(top, bottom)
|
bdy = Bndry(top, bottom)
|
||||||
# Beam params
|
# Beam params
|
||||||
run_type = 'C' # incoherently sum beams, see AT docs for more info
|
run_type = 'C' # incoherently sum beams, see AT docs for more info
|
||||||
nbeams = 0
|
nbeams = 3000
|
||||||
alpha = np.linspace(-45, 45, 2) # min and max launch angle -20 degrees to 20 degrees
|
alpha = np.linspace(-45, 45, 2) # min and max launch angle -20 degrees to 20 degrees
|
||||||
box = Box(Zmax, max(bathm.r)) # bound the region you let the beams go, depth in meters and range in km
|
box = Box(Zmax, max(bathm.r)) # bound the region you let the beams go, depth in meters and range in km
|
||||||
deltas = 0 # length step of ray trace, 0 means automatically choose
|
deltas = 0 # length step of ray trace, 0 means automatically choose
|
||||||
|
|||||||
+39
-24
@@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from multiprocessing import Process
|
||||||
from os import system
|
from os import system
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pyat.AcousticPara import GetEnv, Coord
|
from pyat.AcousticPara import GetEnv, Coord
|
||||||
@@ -12,18 +12,21 @@ from pyat.config import AtBinPath
|
|||||||
|
|
||||||
file_cz_data = open('cz_data.txt', 'w')
|
file_cz_data = open('cz_data.txt', 'w')
|
||||||
|
|
||||||
|
|
||||||
class CzRangeWidth:
|
class CzRangeWidth:
|
||||||
def __init__(self, minRange, maxRange, width):
|
def __init__(self, minRange, maxRange, width):
|
||||||
self.minRange = minRange
|
self.minRange = minRange
|
||||||
self.maxRange = maxRange
|
self.maxRange = maxRange
|
||||||
self.width = width
|
self.width = width
|
||||||
|
|
||||||
|
|
||||||
class CzDetail:
|
class CzDetail:
|
||||||
def __init__(self, descript, directCz, reflectCz):
|
def __init__(self, descript, directCz, reflectCz):
|
||||||
self.descript = descript
|
self.descript = descript
|
||||||
self.directCz = directCz
|
self.directCz = directCz
|
||||||
self.reflectCz = reflectCz
|
self.reflectCz = reflectCz
|
||||||
|
|
||||||
|
|
||||||
class CzData:
|
class CzData:
|
||||||
def __init__(self, azi, ranges, depths, TL, bathym, Rays, CzDetail):
|
def __init__(self, azi, ranges, depths, TL, bathym, Rays, CzDetail):
|
||||||
self.azi = azi
|
self.azi = azi
|
||||||
@@ -34,6 +37,7 @@ class CzData:
|
|||||||
self.Rays = Rays
|
self.Rays = Rays
|
||||||
self.CzDetail = CzDetail
|
self.CzDetail = CzDetail
|
||||||
|
|
||||||
|
|
||||||
def calZmax(ssp, sed):
|
def calZmax(ssp, sed):
|
||||||
d = np.array([], dtype=int)
|
d = np.array([], dtype=int)
|
||||||
for it in range(len(ssp)):
|
for it in range(len(ssp)):
|
||||||
@@ -42,9 +46,10 @@ def calZmax(ssp, sed):
|
|||||||
ssp_idx = np.argmax(d)
|
ssp_idx = np.argmax(d)
|
||||||
return Zmax, ssp_idx
|
return Zmax, ssp_idx
|
||||||
|
|
||||||
def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base):
|
|
||||||
|
def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base,azi):
|
||||||
# Source and receiving position
|
# Source and receiving position
|
||||||
filename='cz'
|
filename = 'cz'+str(azi)
|
||||||
Rmax = bathm.r[-1] # unit: km
|
Rmax = bathm.r[-1] # unit: km
|
||||||
dr = (1500 / freq) / 1000 # wavelength / 10, unit: km
|
dr = (1500 / freq) / 1000 # wavelength / 10, unit: km
|
||||||
ran = np.linspace(0, Rmax, round(Rmax / dr)) # Receiving range (unit: km)
|
ran = np.linspace(0, Rmax, round(Rmax / dr)) # Receiving range (unit: km)
|
||||||
@@ -72,7 +77,6 @@ def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base):
|
|||||||
|
|
||||||
# Sediment
|
# Sediment
|
||||||
if sed != None:
|
if sed != None:
|
||||||
|
|
||||||
Z = sed[0].z + ssp[0].z[-1] # Depth
|
Z = sed[0].z + ssp[0].z[-1] # Depth
|
||||||
Cp = sed[0].cp # Speed of P-wave
|
Cp = sed[0].cp # Speed of P-wave
|
||||||
Cs = sed[0].cs # Speed of S-wave
|
Cs = sed[0].cs # Speed of S-wave
|
||||||
@@ -95,7 +99,7 @@ def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base):
|
|||||||
bdy = Bndry(top, bottom)
|
bdy = Bndry(top, bottom)
|
||||||
# Beam params
|
# Beam params
|
||||||
run_type = 'I' # incoherently sum beams, see AT docs for more info
|
run_type = 'I' # incoherently sum beams, see AT docs for more info
|
||||||
nbeams = 0
|
nbeams = 3000
|
||||||
alpha = np.linspace(-90, 90, 2) # min and max launch angle -20 degrees to 20 degrees
|
alpha = np.linspace(-90, 90, 2) # min and max launch angle -20 degrees to 20 degrees
|
||||||
box = Box(Zmax, 100) # bound the region you let the beams go, depth in meters and range in km
|
box = Box(Zmax, 100) # bound the region you let the beams go, depth in meters and range in km
|
||||||
deltas = 0 # length step of ray trace, 0 means automatically choose
|
deltas = 0 # length step of ray trace, 0 means automatically choose
|
||||||
@@ -105,7 +109,6 @@ def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base):
|
|||||||
write_env(filename + '.env', 'BELLHOP', 'Pekeris profile', freq, sspK, bdy, pos, beam, cInt, Rmax)
|
write_env(filename + '.env', 'BELLHOP', 'Pekeris profile', freq, sspK, bdy, pos, beam, cInt, Rmax)
|
||||||
write_bathy(filename, bathm)
|
write_bathy(filename, bathm)
|
||||||
|
|
||||||
|
|
||||||
system(AtBinPath + "/bellhop " + filename)
|
system(AtBinPath + "/bellhop " + filename)
|
||||||
# Read sound field
|
# Read sound field
|
||||||
[x, x, x, x, Pos1, pressure] = read_shd(filename + '.shd')
|
[x, x, x, x, Pos1, pressure] = read_shd(filename + '.shd')
|
||||||
@@ -113,9 +116,10 @@ def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base):
|
|||||||
|
|
||||||
return Pos1, TL
|
return Pos1, TL
|
||||||
|
|
||||||
def call_Bellhop_Rays(freq, sd, rd, bathm, ssp, sed, base):
|
|
||||||
|
def call_Bellhop_Rays(freq, sd, rd, bathm, ssp, sed, base,azi):
|
||||||
# Source and receiving position
|
# Source and receiving position
|
||||||
filename = 'cz_ray'
|
filename = 'cz_ray'+str(azi)
|
||||||
Rmax = bathm.r[-1] # unit: km
|
Rmax = bathm.r[-1] # unit: km
|
||||||
dr = (1500 / freq) / 1000 # wavelength / 10, unit: km
|
dr = (1500 / freq) / 1000 # wavelength / 10, unit: km
|
||||||
ran = np.linspace(0, Rmax, round(Rmax / dr)) # Receiving range (unit: km)
|
ran = np.linspace(0, Rmax, round(Rmax / dr)) # Receiving range (unit: km)
|
||||||
@@ -179,6 +183,7 @@ def call_Bellhop_Rays(freq, sd, rd, bathm, ssp, sed, base):
|
|||||||
# Read sound field
|
# Read sound field
|
||||||
return get_rays(filename + ".ray")
|
return get_rays(filename + ".ray")
|
||||||
|
|
||||||
|
|
||||||
def find_cvgcRays(rays_total):
|
def find_cvgcRays(rays_total):
|
||||||
Rays = []
|
Rays = []
|
||||||
num_bnc_min = np.Inf
|
num_bnc_min = np.Inf
|
||||||
@@ -195,6 +200,7 @@ def find_cvgcRays(rays_total):
|
|||||||
Rays.append(ray)
|
Rays.append(ray)
|
||||||
return Rays
|
return Rays
|
||||||
|
|
||||||
|
|
||||||
def call_hjq(r, TL):
|
def call_hjq(r, TL):
|
||||||
TL_R = 20 * np.log10(r)
|
TL_R = 20 * np.log10(r)
|
||||||
out = []
|
out = []
|
||||||
@@ -259,7 +265,7 @@ def call_hjq(r, TL):
|
|||||||
return czrangewidth_list
|
return czrangewidth_list
|
||||||
|
|
||||||
|
|
||||||
def call_fangwei(freq, sd, rd, bathm, ssp, sed, base, isPlot=False):
|
def call_fangwei(freq, sd, rd, bathm, ssp, sed, base, azi, isPlot=False):
|
||||||
czdetail = CzDetail("", [], [])
|
czdetail = CzDetail("", [], [])
|
||||||
last = len(ssp[0].c) - 1
|
last = len(ssp[0].c) - 1
|
||||||
# if ssp[0].c[0] > ssp[0].c[last]:
|
# if ssp[0].c[0] > ssp[0].c[last]:
|
||||||
@@ -268,10 +274,10 @@ def call_fangwei(freq, sd, rd, bathm, ssp, sed, base, isPlot=False):
|
|||||||
# else:
|
# else:
|
||||||
# file_cz_data.write('\n'"直达会聚区:")
|
# file_cz_data.write('\n'"直达会聚区:")
|
||||||
sed = None
|
sed = None
|
||||||
rays_total = call_Bellhop_Rays(freq, sd, rd, bathm, ssp, sed, base)
|
rays_total = call_Bellhop_Rays(freq, sd, rd, bathm, ssp, sed, base, azi)
|
||||||
Rays = find_cvgcRays(rays_total)
|
Rays = find_cvgcRays(rays_total)
|
||||||
[Pos, TL] = call_Bellhop(freq, sd, rd, bathm, ssp, sed, base)
|
[Pos, TL] = call_Bellhop(freq, sd, rd, bathm, ssp, sed, base, azi)
|
||||||
[x, x, x, x, Pos, pressure] = read_shd('cz.shd')
|
[x, x, x, x, Pos, pressure] = read_shd('cz'+str(azi)+'.shd')
|
||||||
TL = -10 * np.log10(np.square(np.abs(pressure))) # Transmission Loss
|
TL = -10 * np.log10(np.square(np.abs(pressure))) # Transmission Loss
|
||||||
# Plot
|
# Plot
|
||||||
if isPlot:
|
if isPlot:
|
||||||
@@ -290,20 +296,37 @@ def call_fangwei(freq, sd, rd, bathm, ssp, sed, base, 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 call_cz(database, freq, lat, lon, azi, sourceDepth=10, receiveDepth=10, isPlot=False):
|
def call_cz(database, freq, lat, lon, azi, sourceDepth=10, receiveDepth=10, isPlot=False):
|
||||||
sd = np.array([sourceDepth]) # Source depth
|
sd = np.array([sourceDepth]) # Source depth
|
||||||
rd = np.linspace(0, receiveDepth, 351) # Receiving depth
|
rd = np.linspace(0, receiveDepth, 351) # Receiving 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, rd, bathm, ssp, sed, base, azi=theta[i],isPlot=True)
|
||||||
|
czdetail.descript = descripts[i]
|
||||||
|
results.append(CzData(theta[i], ranges, depths, TL, bathym, Rays, czdetail))
|
||||||
|
return results
|
||||||
|
|
||||||
|
def child_0(interval):
|
||||||
|
results=child(interval)
|
||||||
|
return results
|
||||||
''' 计算单个方向的会聚区 '''
|
''' 计算单个方向的会聚区 '''
|
||||||
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 results
|
||||||
else:
|
else:
|
||||||
ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, rd, bathm, ssp, sed, base, isPlot=isPlot)
|
ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, rd, bathm, ssp, sed, base,
|
||||||
|
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
|
||||||
@@ -314,15 +337,7 @@ def call_cz(database, freq, lat, lon, azi, sourceDepth=10, receiveDepth=10, isPl
|
|||||||
# file_cz_data.write("各个方位都不会出现会聚区")
|
# file_cz_data.write("各个方位都不会出现会聚区")
|
||||||
return results
|
return results
|
||||||
else:
|
else:
|
||||||
descripts = ["正北方向", "东北方向", "正东方向", "东南方向", "正南方向", "西南方向", "正西方向", "西北方向"]
|
for pi in range(8):
|
||||||
theta = np.arange(0, 359, 45)
|
pi=Process(target=child_0,args=(pi,))
|
||||||
for i in range(8):
|
pi.start()
|
||||||
[bathm, ssp, sed, base] = GetEnv(database, 25, Coord(lon, lat), R=100, azi=theta[i])
|
|
||||||
if np.mean(bathm.d) < 2000:
|
|
||||||
# 不会出现会聚区
|
|
||||||
continue
|
|
||||||
ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, rd, bathm, ssp, sed, base, isPlot=isPlot)
|
|
||||||
czdetail.descript = descripts[i]
|
|
||||||
results.append(CzData(theta[i], ranges, depths, TL, bathym, Rays, czdetail))
|
|
||||||
|
|
||||||
return results
|
return results
|
||||||
在新工单中引用
屏蔽一个用户