去掉了接收深度接口,

更改了间隔dr。
这个提交包含在:
2023-04-07 16:11:16 +08:00
父节点 888a80e69c
当前提交 3ed8fe0dea
共修改 7 个文件,包含 175 行新增和 130 行删除
+66 -58
查看文件
@@ -7,6 +7,7 @@ from multiprocessing import Pool
from scipy.stats import norm
import math
def write_ssp(sspfile, ssp, bathm, NZmax):
if sspfile[-3:] != 'ssp':
sspfile += '.ssp'
@@ -35,9 +36,7 @@ def write_bathy(btyfile, bathm):
f.write(' ' + str(bathm.r[row]) + ' ' + str(bathm.d[row]) + '\r\n')
return
def call_Bellhop_p(filename):
system(AtBinPath + "/bellhop " + filename)
def calZmax(ssp):
d = np.array([], dtype=int)
for it in range(len(ssp)):
@@ -47,15 +46,18 @@ def calZmax(ssp):
Zmax = ssp[ssp_idx].z[-1]
return NZmax, Zmax, ssp_idx
def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base):
def call_Bellhop_p(filename):
system(AtBinPath + "/bellhop " + filename)
def call_Bellhop(freq, sd, bathm, ssp, sed, base):
# Source and receiving position
filename = 'envB'
Rmax = bathm.r[-1] # unit: km
dr = (1500 / freq) / 1000 # wavelength / 10, unit: km
dr = 0.1 # wavelength / 10, unit: km
ran = np.linspace(0, Rmax, round(Rmax / dr)) # Receiving range (unit: km)
NZmax, Zmax, ssp_idx = calZmax(ssp)
RD = np.linspace(0, Zmax, round(Zmax / 10) + 1)
pos = Pos(Source(sd), Dom(ran, rd))
pos = Pos(Source(sd), Dom(ran, RD))
# Range of phase velocity
cInt.Low = 1400
cInt.High = 15000
@@ -100,18 +102,22 @@ def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base):
bdy = Bndry(top, bottom)
# Beam params
run_type = 'C' # incoherently sum beams, see AT docs for more info
NAlphaRange = 12
Alpha = alphadiv(NAlphaRange,Rmax) # min and max launch angle -20 degrees to 20 degrees
totalBeams = beamsnumber(freq, Rmax, max(bathm.r))
Alpha = alphadiv(NAlphaRange,Rmax) # min and max launch angle -20 degrees to 20 degrees
totalBeams = beamsnumber(freq,Rmax,max(bathm.r))
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
# Write *.env file
ialpha = 0
Filenames = []
for iAlphaRange in range(len(Alpha) - 1):
for iAlphaRange in range(len(Alpha)-1):
alpha = np.array([Alpha[iAlphaRange], Alpha[iAlphaRange + 1]])
nbeams = int(totalBeams * (alpha[1] - alpha[0]) / 180)
nbeams = int(totalBeams * (alpha[1]-alpha[0])/180)
beam = Beam(RunType=run_type, Nbeams=nbeams, alpha=alpha, box=box, deltas=deltas) # package
filenameI = filename + str(iAlphaRange)
filenameI = filename+ str(iAlphaRange)
write_env(filenameI + '.env', 'BELLHOP', 'Pekeris profile', freq, sspB, bdy, pos, beam, cInt, Rmax)
write_ssp(filenameI, ssp, bathm, NZmax)
write_bathy(filenameI, bathm)
@@ -122,7 +128,7 @@ def call_Bellhop(freq, sd, rd, bathm, ssp, sed, base):
# Read sound field
[x, x, x, x, Pos1, pressure] = read_shd(filename + '0.shd')
for iAlphaRange in range(NAlphaRange - 1):
for iAlphaRange in range(NAlphaRange-1):
[x, x, x, x, Pos1, pressure1] = read_shd(filename + str(iAlphaRange) + '.shd')
pressure = pressure + pressure1
TL = -10 * np.log10(np.square(np.abs(pressure))) # Transmission Loss
@@ -212,61 +218,63 @@ def find_cvgcRays(rays_total):
Rays.append(ray)
return Rays
def alphadiv(NalphaRange, Rmax):
angle = [-90, 90]
if Rmax > 100 and Rmax <= 1000:
sigma = 25
elif Rmax > 1000:
def alphadiv(NalphaRange,Rmax):
angle = [-90,90]
if Rmax >100 and Rmax<=1000:
sigma = 20
elif Rmax >=1000:
sigma = 15
else:
sigma = 40
for i in range(1, NalphaRange):
angle.append(norm.ppf(i / NalphaRange, loc=0, scale=sigma))
else :
sigma = 25
for i in range(1,NalphaRange):
angle.append(norm.ppf(i/NalphaRange,loc=0, scale=sigma))
angle.sort()
return angle
def beamsnumber(freq, Rmax, depth):
if Rmax > 700:
nbeams = max(int(0.01 * Rmax * 1000 * freq / 1500), 300)
elif Rmax > 300 and Rmax <= 700:
nbeams = max(int(0.05 * Rmax * 1000 * freq / 1500), 300)
elif Rmax > 100 and Rmax <= 300:
nbeams = max(int(0.1 * Rmax * 1000 * freq / 1500), 300)
else:
nbeams = max(int(0.3 * Rmax * 1000 * freq / 1500), 300)
d_theta_recommended = math.atan(depth / (10.0 * Rmax * 1000))
nbeams = max(int(math.pi / d_theta_recommended), nbeams)
def beamsnumber(freq,Rmax,depth):
if Rmax >700 :
nbeams = max(int(0.01 * Rmax*1000 * freq /1500),300)
elif Rmax >300 and Rmax<=700:
nbeams = max(int(0.05 * Rmax*1000 * freq / 1500), 300)
elif Rmax >100 and Rmax<=300:
nbeams = max(int(0.1 * Rmax*1000 * freq / 1500), 300)
else:
nbeams = max(int(0.3 * Rmax*1000 * freq / 1500), 300)
d_theta_recommended =math.atan(depth/(10.0 * Rmax*1000))
nbeams = min(int(math.pi/d_theta_recommended),nbeams,3000)
return nbeams
# if __name__=="__main__":
''' ********************************************** '''
''' ******************** Test ******************** '''
# freq = 25 # Frequency
# sd = np.array([10.0]) # Source depth
# rd = np.linspace(0, 4000, 401) # Receiving depth
# # 定义坐标
# lat = 19.00
# lon = 116.00
# # 定义时间段
# timeIndex = db.timeDict['Annual']
# # 创建类
# data = db.DataBase()
# # 设置时间段
# data.set_timePeriod(timeIndex)
''' ********************************************** '''
''' ******************** Test ******************** '''
# freq = 25 # Frequency
# sd = np.array([10.0]) # Source depth
# rd = np.linspace(0, 4000, 401) # Receiving depth
# # 定义坐标
# lat = 19.00
# lon = 116.00
# # 定义时间段
# timeIndex = db.timeDict['Annual']
# # 创建类
# data = db.DataBase()
# # 设置时间段
# data.set_timePeriod(timeIndex)
# [bathm, ssp, sed, base] = GetEnv(data, freq, Coord(lon, lat), R=100, azi=90)
# [Pos, TL] = call_Bellhop(freq, sd, rd, bathm, ssp, sed, base)
# [bathm, ssp, sed, base] = GetEnv(data, freq, Coord(lon, lat), R=100, azi=90)
# [Pos, TL] = call_Bellhop(freq, sd, rd, bathm, ssp, sed, base)
# #[x, x, x, x, Pos, pressure] = read_shd('envB.shd')
# #TL = -10 * np.log10(np.square(np.abs(pressure))) # Transmission Loss
# # Plot
# plt.pcolor(Pos.r.range, Pos.r.depth, TL[0,0,:,:], vmin=40, vmax=130,cmap='jet_r', shading='auto')
# plt.xlabel("Range/m")
# plt.ylabel("Depth/m")
# plt.gca().invert_yaxis()
# plt.colorbar()
# plt.plot(bathm.r*1000, bathm.d, color='k')
# plt.show()
# #[x, x, x, x, Pos, pressure] = read_shd('envB.shd')
# #TL = -10 * np.log10(np.square(np.abs(pressure))) # Transmission Loss
# # Plot
# plt.pcolor(Pos.r.range, Pos.r.depth, TL[0,0,:,:], vmin=40, vmax=130,cmap='jet_r', shading='auto')
# plt.xlabel("Range/m")
# plt.ylabel("Depth/m")
# plt.gca().invert_yaxis()
# plt.colorbar()
# plt.plot(bathm.r*1000, bathm.d, color='k')
# plt.show()