From 4ff11a4b1a14dd5fd4e00389782b96883c9003ca Mon Sep 17 00:00:00 2001 From: shunli Date: Mon, 10 Apr 2023 21:19:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BE=E5=BC=80=E8=B7=9D=E7=A6=BB=E9=87=87?= =?UTF-8?q?=E6=A0=B7=E9=97=B4=E9=9A=94=E5=8F=82=E6=95=B0dr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyat/bellhop.py | 4 ++-- pyat/czcore.py | 36 ++++++++++++------------------------ pyat/krakenc.py | 4 ++-- pyat/ram.py | 4 ++-- pyat/tlcore.py | 8 ++++---- 5 files changed, 22 insertions(+), 34 deletions(-) diff --git a/pyat/bellhop.py b/pyat/bellhop.py index d957253..6e904dc 100644 --- a/pyat/bellhop.py +++ b/pyat/bellhop.py @@ -49,11 +49,11 @@ def calZmax(ssp): def call_Bellhop_p(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 filename = 'envB' 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) NZmax, Zmax, ssp_idx = calZmax(ssp) RD = np.linspace(0, Zmax, round(Zmax / 10) + 1) diff --git a/pyat/czcore.py b/pyat/czcore.py index f62c687..0615cc2 100644 --- a/pyat/czcore.py +++ b/pyat/czcore.py @@ -11,8 +11,6 @@ from env import Pos, Source, Dom, cInt, SSPraw, SSP, HS, BotBndry, TopBndry, Bnd import matplotlib.pyplot as plt from config import AtBinPath -file_cz_data = open('cz_data.txt', 'w') - class CzRangeWidth: def __init__(self, minRange, maxRange, width): @@ -48,11 +46,11 @@ def calZmax(ssp, sed): 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 filename = 'cz'+str(azi) 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) Zmax, ssp_idx = calZmax(ssp, sed) """RD 已修改 8.26""" @@ -118,11 +116,11 @@ def call_Bellhop(freq, sd, bathm, ssp, sed, base,azi): 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 filename = 'cz_ray'+str(azi) 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) Zmax, ssp_idx = calZmax(ssp, sed) """RD 已修改 8.26""" @@ -227,8 +225,6 @@ def call_hjq(r, TL): m = r[out[0]] n = r[out[len(out) - 1]] 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)) out.clear() signal = 0 @@ -236,13 +232,10 @@ def call_hjq(r, TL): m = r[out[0]] n = r[out[len(out) - 1]] 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)) out.clear() signal = 0 # if signal==1: - # file_cz_data.write('\n'" 没有出现会聚区\n") # 滤波器效果图: # plt.plot(r, TL) # plt.plot(r, TL_R) @@ -266,18 +259,13 @@ def call_hjq(r, TL): 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("", [], []) 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 - 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) - [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') TL = -10 * np.log10(np.square(np.abs(pressure))) # Transmission Loss # Plot @@ -297,12 +285,12 @@ 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(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) +def child(freq, sd, dr, isPlot, bathm, ssp, sed, base, azi, descript): + ranges, depths, TL, bathym, Rays, czdetail = call_fangwei(freq, sd, dr, 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): +def call_cz(database, freq, lat, lon, azi, sourceDepth=10, dr=0.1, isPlot=False): sd = np.array([sourceDepth]) # Source depth results = [] @@ -315,7 +303,7 @@ 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: - 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, dr, bathm, ssp, sed, base, azi, isPlot=isPlot) czdetail.descript = "{:.1f}°方向".format(azi) results.append(CzData(0, ranges, depths, TL, bathym, Rays, czdetail)) @@ -329,7 +317,7 @@ def call_cz(database, freq, lat, lon, azi, sourceDepth=10, isPlot=False): 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, 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.join() diff --git a/pyat/krakenc.py b/pyat/krakenc.py index a833a61..d972355 100755 --- a/pyat/krakenc.py +++ b/pyat/krakenc.py @@ -15,7 +15,7 @@ def calZmax(ssp, sed): 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" envFilename = "envK.env" model = "KRAKEN" @@ -23,7 +23,7 @@ def call_krakenc(freq, sd, bathm, ssp, sed, base): # Source and receiving position 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) Zmax = calZmax(ssp, sed) RD = np.linspace(0, Zmax, round(Zmax) + 1) diff --git a/pyat/ram.py b/pyat/ram.py index 459f2c6..8f515da 100755 --- a/pyat/ram.py +++ b/pyat/ram.py @@ -13,7 +13,7 @@ def calZmax(ssp, sed): Zmax = max(d) return Zmax -def call_ram(freq, sd, bathm, ssp, sed): +def call_ram(freq, sd, bathm, ssp, sed, dr=0.1): ''' ********************************************************************************* ''' ''' ************************** Sound Field Calculation ****************************** ''' ''' ********************************************************************************* ''' @@ -24,7 +24,7 @@ def call_ram(freq, sd, bathm, ssp, sed): zmax = round(max(bathm.d) * 2) # Maximum receiving depth (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 - dr = 10 * dz # Step in range direction + # dr = 10 * dz # Step in range direction Zmax = calZmax(ssp, sed) rd = Zmax pos = PosRAM(sd, rd, rmax, zmax, dr, dz, zmplt) diff --git a/pyat/tlcore.py b/pyat/tlcore.py index 7717eac..74f1d82 100644 --- a/pyat/tlcore.py +++ b/pyat/tlcore.py @@ -7,7 +7,7 @@ from ram import call_ram import matplotlib.pyplot as plt 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: freq - float, Frequency sourceDepth - float, Source depth @@ -40,7 +40,7 @@ def call_tl(database, freq, sourceDepth, sourceLat, sourceLon, return [], [], [], bathym if modelType == 'bellhop': 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 if isPlot: 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 elif modelType == 'kraken': 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 if isPlot: 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 elif modelType == 'ram': # 调用ram模块 - [rd, rr, TL] = call_ram(freq, sourceDepth, bathym, ssp, sed) + [rd, rr, TL] = call_ram(freq, sourceDepth, bathym, ssp, sed, dr) # Plot if isPlot: plt.pcolormesh(rr, rd, TL, vmin=60, vmax=130, cmap='jet_r', shading='auto')