比较提交

..
7 次代码提交
作者 SHA1 备注 提交日期
ggg b5c1609d90 dr*1000\dz 2023-05-04 10:47:17 +08:00
ggg 109fafd866 ray box RMAX 2023-04-13 17:03:29 +08:00
ggg a64bf169ee dr*1000 2023-04-13 16:54:57 +08:00
wangsli 3d6e9e48f6 放开会聚区range参数 2023-04-11 16:07:06 +08:00
Rose0428 8c156f36d7 增加R 2023-04-11 15:28:10 +08:00
wangsli 4ff11a4b1a 放开距离采样间隔参数dr 2023-04-10 21:19:30 +08:00
wangsli 69b4a03d47 优化多进程调用方式,减少进程间IO等待 2023-04-07 22:00:31 +08:00
共修改 5 个文件,包含 44 行新增和 68 行删除
+2 -2
查看文件
@@ -49,11 +49,11 @@ def calZmax(ssp):
def call_Bellhop_p(filename): def call_Bellhop_p(filename):
system(AtBinPath + "/bellhop " + filename) system(AtBinPath + "/bellhop " + filename)
def call_Bellhop(freq, sd, bathm, ssp, sed, base): def call_Bellhop(freq, sd, bathm, ssp, sed, base, dr=0.1):
# Source and receiving position # Source and receiving position
filename = 'envB' filename = 'envB'
Rmax = bathm.r[-1] # unit: km Rmax = bathm.r[-1] # unit: km
dr = 0.1 # wavelength / 10, unit: km # dr = 0.1 # 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)
NZmax, Zmax, ssp_idx = calZmax(ssp) NZmax, Zmax, ssp_idx = calZmax(ssp)
RD = np.linspace(0, Zmax, round(Zmax / 10) + 1) RD = np.linspace(0, Zmax, round(Zmax / 10) + 1)
+26 -50
查看文件
@@ -11,8 +11,6 @@ from env import Pos, Source, Dom, cInt, SSPraw, SSP, HS, BotBndry, TopBndry, Bnd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from config import AtBinPath from config import AtBinPath
file_cz_data = open('cz_data.txt', 'w')
class CzRangeWidth: class CzRangeWidth:
def __init__(self, minRange, maxRange, width): def __init__(self, minRange, maxRange, width):
@@ -48,11 +46,11 @@ def calZmax(ssp, sed):
return Zmax, ssp_idx return Zmax, ssp_idx
def call_Bellhop(freq, sd, bathm, ssp, sed, base,azi): def call_Bellhop(freq, sd, dr, bathm, ssp, sed, base,azi):
# Source and receiving position # Source and receiving position
filename = 'cz'+str(azi) filename = 'cz'+str(azi)
Rmax = bathm.r[-1] # unit: km Rmax = bathm.r[-1] # unit: km
dr = 0.1 # wavelength / 10, unit: km # dr = 0.1 # 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)
Zmax, ssp_idx = calZmax(ssp, sed) Zmax, ssp_idx = calZmax(ssp, sed)
"""RD 已修改 8.26""" """RD 已修改 8.26"""
@@ -102,7 +100,7 @@ def call_Bellhop(freq, sd, bathm, ssp, sed, base,azi):
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 = 1000 nbeams = 1000
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, Rmax+10) # 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
beam = Beam(RunType=run_type, Nbeams=nbeams, alpha=alpha, box=box, deltas=deltas) # package beam = Beam(RunType=run_type, Nbeams=nbeams, alpha=alpha, box=box, deltas=deltas) # package
"""删除ssp 已修改 8.26""" """删除ssp 已修改 8.26"""
@@ -118,11 +116,11 @@ def call_Bellhop(freq, sd, bathm, ssp, sed, base,azi):
return Pos1, TL return Pos1, TL
def call_Bellhop_Rays(freq, sd, bathm, ssp, sed, base,azi): def call_Bellhop_Rays(freq, sd, dr, bathm, ssp, sed, base,azi):
# Source and receiving position # Source and receiving position
filename = 'cz_ray'+str(azi) filename = 'cz_ray'+str(azi)
Rmax = bathm.r[-1] # unit: km Rmax = bathm.r[-1] # unit: km
dr = 0.1 # wavelength / 10, unit: km # dr = 0.1 # 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)
Zmax, ssp_idx = calZmax(ssp, sed) Zmax, ssp_idx = calZmax(ssp, sed)
"""RD 已修改 8.26""" """RD 已修改 8.26"""
@@ -172,7 +170,7 @@ def call_Bellhop_Rays(freq, sd, bathm, ssp, sed, base,azi):
run_type = 'R' # incoherently sum beams, see AT docs for more info run_type = 'R' # incoherently sum beams, see AT docs for more info
nbeams = 301 nbeams = 301
alpha = np.linspace(-15, 15, 2) # min and max launch angle -20 degrees to 20 degrees alpha = np.linspace(-15, 15, 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, Rmax+10) # 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
beam = Beam(RunType=run_type, Nbeams=nbeams, alpha=alpha, box=box, deltas=deltas) # package beam = Beam(RunType=run_type, Nbeams=nbeams, alpha=alpha, box=box, deltas=deltas) # package
"""删除ssp 已修改 8.26""" """删除ssp 已修改 8.26"""
@@ -227,8 +225,6 @@ def call_hjq(r, TL):
m = r[out[0]] m = r[out[0]]
n = r[out[len(out) - 1]] n = r[out[len(out) - 1]]
l = n - m l = n - m
# file_cz_data.write('\n'"会聚区距离:%.1fm"%m +"-%.1fm" %n)
# file_cz_data.write('\n'"会聚区宽度:%.1fm\n"%l )
czrangewidth_list.append(CzRangeWidth(m, n, l)) czrangewidth_list.append(CzRangeWidth(m, n, l))
out.clear() out.clear()
signal = 0 signal = 0
@@ -236,13 +232,10 @@ def call_hjq(r, TL):
m = r[out[0]] m = r[out[0]]
n = r[out[len(out) - 1]] n = r[out[len(out) - 1]]
l = n - m l = n - m
# file_cz_data.write('\n'"会聚区距离:%.1fm" % m + "-%.1fm" % n)
# file_cz_data.write('\n'"会聚区宽度:%.1fm\n" % l )
czrangewidth_list.append(CzRangeWidth(m, n, l)) czrangewidth_list.append(CzRangeWidth(m, n, l))
out.clear() out.clear()
signal = 0 signal = 0
# if signal==1: # if signal==1:
# file_cz_data.write('\n'" 没有出现会聚区\n")
# 滤波器效果图: # 滤波器效果图:
# plt.plot(r, TL) # plt.plot(r, TL)
# plt.plot(r, TL_R) # plt.plot(r, TL_R)
@@ -266,18 +259,13 @@ def call_hjq(r, TL):
return czrangewidth_list return czrangewidth_list
def call_fangwei(freq, sd, bathm, ssp, sed, base, azi, isPlot=False): def call_fangwei(freq, sd, dr, 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]:
# file_cz_data.write('\n'"直达会聚区:无")
# file_cz_data.write('\n'"反射会聚区:")
# else:
# file_cz_data.write('\n'"直达会聚区:")
sed = None sed = None
rays_total = call_Bellhop_Rays(freq, sd, bathm, ssp, sed, base, azi) rays_total = call_Bellhop_Rays(freq, sd, dr, bathm, ssp, sed, base, azi)
Rays = find_cvgcRays(rays_total) Rays = find_cvgcRays(rays_total)
[Pos, TL] = call_Bellhop(freq, sd, bathm, ssp, sed, base, azi) [Pos, TL] = call_Bellhop(freq, sd, dr, bathm, ssp, sed, base, azi)
[x, x, x, x, Pos, pressure] = read_shd('cz'+str(azi)+'.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
@@ -297,20 +285,12 @@ 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, dr, isPlot, bathm, ssp, sed, base, azi, descript):
descripts = ["正北方向", "东北方向", "正东方向", "东南方向", "正南方向", "西南方向", "正西方向", "西北方向"] ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, dr, 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, R=100, dr=0.1, isPlot=False):
sd = np.array([sourceDepth]) # Source depth sd = np.array([sourceDepth]) # Source depth
results = [] results = []
@@ -321,28 +301,24 @@ def call_cz(database, freq, lat, lon, azi, sourceDepth=10, isPlot=False):
# return czdata # 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=R, azi=azi)
if np.mean(bathm.d) < 2000: if np.mean(bathm.d) >= 2000:
return None ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, dr, bathm, ssp, sed, base, azi,
else:
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:
# file_cz_data.write("各个方位都不会出现会聚区")
return results
else:
pool = Pool(processes=8)
applyResults = [] applyResults = []
for pi in range(8): descripts = ["正北方向", "东北方向", "正东方向", "东南方向", "正南方向", "西南方向", "正西方向", "西北方向"]
applyResults.append(pool.apply_async(partial(child, database, freq, lat, lon, sd, isPlot), (pi,))) 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=R, azi=theta[i])
if np.mean(bathm.d) >= 2000:
applyResults.append(pool.apply_async(partial(child, freq, sd, dr, 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.close()
pool.join() pool.join()
for applyResult in applyResults: for applyResult in applyResults:
@@ -355,5 +331,5 @@ def call_cz(database, freq, lat, lon, azi, sourceDepth=10, isPlot=False):
# ETOPO1Path = '/home/gan/下载/code/20220920/ETOPO1' # ETOPO1Path = '/home/gan/下载/code/20220920/ETOPO1'
# database = DataBase(ETOPO1Path, STPath) # database = DataBase(ETOPO1Path, STPath)
# database.set_timePeriod(timeIndex) # database.set_timePeriod(timeIndex)
# res = call_cz(database, 300, 13, 115, 0, 60, True) # res = call_cz(database, 300, 13, 115, None, 60, 150, 0.1, True)
# a = 1 # a = 1
+2 -2
查看文件
@@ -15,7 +15,7 @@ def calZmax(ssp, sed):
return Zmax return Zmax
def call_krakenc(freq, sd, bathm, ssp, sed, base): def call_krakenc(freq, sd, bathm, ssp, sed, base, dr=0.1):
filename = "envK" filename = "envK"
envFilename = "envK.env" envFilename = "envK.env"
model = "KRAKEN" model = "KRAKEN"
@@ -23,7 +23,7 @@ def call_krakenc(freq, sd, bathm, ssp, sed, base):
# Source and receiving position # Source and receiving position
Rmax = bathm.r[-1] # unit: km Rmax = bathm.r[-1] # unit: km
dr = (1500 / freq / 3) / 1000 # wavelength / 10, unit: km # dr = (1500 / freq / 3) / 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)
Zmax = calZmax(ssp, sed) Zmax = calZmax(ssp, sed)
RD = np.linspace(0, Zmax, round(Zmax) + 1) RD = np.linspace(0, Zmax, round(Zmax) + 1)
+3 -3
查看文件
@@ -13,7 +13,7 @@ def calZmax(ssp, sed):
Zmax = max(d) Zmax = max(d)
return Zmax return Zmax
def call_ram(freq, sd, bathm, ssp, sed): def call_ram(freq, sd, bathm, ssp, sed, dr=0.1):
''' ********************************************************************************* ''' ''' ********************************************************************************* '''
''' ************************** Sound Field Calculation ****************************** ''' ''' ************************** Sound Field Calculation ****************************** '''
''' ********************************************************************************* ''' ''' ********************************************************************************* '''
@@ -23,8 +23,8 @@ def call_ram(freq, sd, bathm, ssp, sed):
rmax = max(bathm.r) # Maximum receiving range (unit: m) rmax = max(bathm.r) # Maximum receiving range (unit: m)
zmax = round(max(bathm.d) * 2) # Maximum receiving depth (uint: m) zmax = round(max(bathm.d) * 2) # Maximum receiving depth (uint: m)
zmplt = round(max(bathm.d)*1.1) # Maximum depth of plot (uint: m) zmplt = round(max(bathm.d)*1.1) # Maximum depth of plot (uint: m)
dz = 1500 / freq / 15 # Step in depth direction: wavelength / 15 dz = 10 # Step in depth direction: wavelength / 15
dr = 10 * dz # Step in range direction dr = 1000* dr # Step in range direction
Zmax = calZmax(ssp, sed) Zmax = calZmax(ssp, sed)
rd = Zmax rd = Zmax
pos = PosRAM(sd, rd, rmax, zmax, dr, dz, zmplt) pos = PosRAM(sd, rd, rmax, zmax, dr, dz, zmplt)
+4 -4
查看文件
@@ -7,7 +7,7 @@ from ram import call_ram
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
def call_tl(database, freq, sourceDepth, sourceLat, sourceLon, def call_tl(database, freq, sourceDepth, sourceLat, sourceLon,
receiveLat=None, receiveLon=None, range=None, azi=None, modelType='kraken', isPlot=False): receiveLat=None, receiveLon=None, range=None, azi=None, dr=0.1, modelType='kraken', isPlot=False):
""" Input: """ Input:
freq - float, Frequency freq - float, Frequency
sourceDepth - float, Source depth sourceDepth - float, Source depth
@@ -40,7 +40,7 @@ def call_tl(database, freq, sourceDepth, sourceLat, sourceLon,
return [], [], [], bathym return [], [], [], bathym
if modelType == 'bellhop': if modelType == 'bellhop':
sd = np.array([sourceDepth]) # Source depth sd = np.array([sourceDepth]) # Source depth
[Pos, TL] = call_Bellhop(freq, sd, bathym, ssp, sed, base) [Pos, TL] = call_Bellhop(freq, sd, bathym, ssp, sed, base, dr)
# Plot # Plot
if isPlot: if isPlot:
plt.pcolor(Pos.r.range, Pos.r.depth, TL[0,0,:,:], vmin=40, vmax=130, cmap='jet_r', shading='auto') plt.pcolor(Pos.r.range, Pos.r.depth, TL[0,0,:,:], vmin=40, vmax=130, cmap='jet_r', shading='auto')
@@ -52,7 +52,7 @@ def call_tl(database, freq, sourceDepth, sourceLat, sourceLon,
return Pos.r.range, Pos.r.depth, TL[0,0,:,:], bathym return Pos.r.range, Pos.r.depth, TL[0,0,:,:], bathym
elif modelType == 'kraken': elif modelType == 'kraken':
sd = np.array([sourceDepth]) # Source depth sd = np.array([sourceDepth]) # Source depth
[Pos, TL] = call_krakenc(freq, sd, bathym, ssp, sed, base) [Pos, TL] = call_krakenc(freq, sd, bathym, ssp, sed, base, dr)
# Plot # Plot
if isPlot: if isPlot:
plt.pcolor(Pos.r.range, Pos.r.depth, TL[0,0,:,:], vmin=40, vmax=130, cmap='jet_r', shading='auto') plt.pcolor(Pos.r.range, Pos.r.depth, TL[0,0,:,:], vmin=40, vmax=130, cmap='jet_r', shading='auto')
@@ -64,7 +64,7 @@ def call_tl(database, freq, sourceDepth, sourceLat, sourceLon,
return Pos.r.range, Pos.r.depth, TL[0,0,:,:], bathym return Pos.r.range, Pos.r.depth, TL[0,0,:,:], bathym
elif modelType == 'ram': elif modelType == 'ram':
# 调用ram模块 # 调用ram模块
[rd, rr, TL] = call_ram(freq, sourceDepth, bathym, ssp, sed) [rd, rr, TL] = call_ram(freq, sourceDepth, bathym, ssp, sed, dr)
# Plot # Plot
if isPlot: if isPlot:
plt.pcolormesh(rr, rd, TL, vmin=60, vmax=130, cmap='jet_r', shading='auto') plt.pcolormesh(rr, rd, TL, vmin=60, vmax=130, cmap='jet_r', shading='auto')