更改了声线计算方式,合理分配了角度和声线进行并行运算。
这个提交包含在:
+53
-9
@@ -3,7 +3,9 @@ from env import Pos, Source, Dom, cInt, SSPraw, SSP, HS, BotBndry, TopBndry, Bnd
|
|||||||
from os import system
|
from os import system
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from config import AtBinPath
|
from config import AtBinPath
|
||||||
|
from multiprocessing import Pool
|
||||||
|
from scipy.stats import norm
|
||||||
|
import math
|
||||||
|
|
||||||
def write_ssp(sspfile, ssp, bathm, NZmax):
|
def write_ssp(sspfile, ssp, bathm, NZmax):
|
||||||
if sspfile[-3:] != 'ssp':
|
if sspfile[-3:] != 'ssp':
|
||||||
@@ -33,6 +35,8 @@ def write_bathy(btyfile, bathm):
|
|||||||
f.write(' ' + str(bathm.r[row]) + ' ' + str(bathm.d[row]) + '\r\n')
|
f.write(' ' + str(bathm.r[row]) + ' ' + str(bathm.d[row]) + '\r\n')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def call_Bellhop_p(filename):
|
||||||
|
system(AtBinPath + "/bellhop " + filename)
|
||||||
|
|
||||||
def calZmax(ssp):
|
def calZmax(ssp):
|
||||||
d = np.array([], dtype=int)
|
d = np.array([], dtype=int)
|
||||||
@@ -96,20 +100,31 @@ 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 = 3000
|
NAlphaRange = 12
|
||||||
alpha = np.linspace(-45, 45, 2) # min and max launch angle -20 degrees to 20 degrees
|
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
|
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
|
||||||
|
Filenames = []
|
||||||
|
for iAlphaRange in range(len(Alpha) - 1):
|
||||||
|
alpha = np.array([Alpha[iAlphaRange], Alpha[iAlphaRange + 1]])
|
||||||
|
nbeams = int(totalBeams * (alpha[1] - alpha[0]) / 180)
|
||||||
|
|
||||||
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
|
||||||
|
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)
|
||||||
|
Filenames.append(filenameI)
|
||||||
|
|
||||||
# Write *.env file
|
pool = Pool(NAlphaRange)
|
||||||
write_env(filename + '.env', 'BELLHOP', 'Pekeris profile', freq, sspB, bdy, pos, beam, cInt, Rmax)
|
pool.map(call_Bellhop_p, Filenames)
|
||||||
write_ssp(filename, ssp, bathm, NZmax)
|
|
||||||
write_bathy(filename, bathm)
|
|
||||||
|
|
||||||
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 + '0.shd')
|
||||||
|
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
|
TL = -10 * np.log10(np.square(np.abs(pressure))) # Transmission Loss
|
||||||
|
|
||||||
return Pos1, TL
|
return Pos1, TL
|
||||||
@@ -197,6 +212,35 @@ def find_cvgcRays(rays_total):
|
|||||||
Rays.append(ray)
|
Rays.append(ray)
|
||||||
return Rays
|
return Rays
|
||||||
|
|
||||||
|
def alphadiv(NalphaRange, Rmax):
|
||||||
|
angle = [-90, 90]
|
||||||
|
if Rmax > 100 and Rmax <= 1000:
|
||||||
|
sigma = 25
|
||||||
|
elif Rmax > 1000:
|
||||||
|
sigma = 15
|
||||||
|
else:
|
||||||
|
sigma = 40
|
||||||
|
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)
|
||||||
|
|
||||||
|
return nbeams
|
||||||
|
|
||||||
# if __name__=="__main__":
|
# if __name__=="__main__":
|
||||||
''' ********************************************** '''
|
''' ********************************************** '''
|
||||||
''' ******************** Test ******************** '''
|
''' ******************** Test ******************** '''
|
||||||
|
|||||||
+5
-5
@@ -1,8 +1,8 @@
|
|||||||
from os import system
|
from os import system
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from readwrite import write_env, write_fieldflp, read_shd
|
from pyat.readwrite import write_env, write_fieldflp, read_shd
|
||||||
from env import Pos, Source, Dom, cInt, SSPraw, SSP, HS, BotBndry, TopBndry, Bndry
|
from pyat.env import Pos, Source, Dom, cInt, SSPraw, SSP, HS, BotBndry, TopBndry, Bndry
|
||||||
from config import AtBinPath
|
from pyat.config import AtBinPath
|
||||||
|
|
||||||
def calZmax(ssp, sed):
|
def calZmax(ssp, sed):
|
||||||
d = np.array([])
|
d = np.array([])
|
||||||
@@ -15,7 +15,7 @@ def calZmax(ssp, sed):
|
|||||||
return Zmax
|
return Zmax
|
||||||
|
|
||||||
|
|
||||||
def call_krakenc(freq, sd, rd, bathm, ssp, sed, base):
|
def call_krakenc(freq, sd, bathm, ssp, sed, base):
|
||||||
filename = "envK"
|
filename = "envK"
|
||||||
envFilename = "envK.env"
|
envFilename = "envK.env"
|
||||||
model = "KRAKEN"
|
model = "KRAKEN"
|
||||||
@@ -98,7 +98,7 @@ def call_krakenc(freq, sd, rd, bathm, ssp, sed, base):
|
|||||||
system(AtBinPath + "/krakenc " + filename)
|
system(AtBinPath + "/krakenc " + filename)
|
||||||
# Write *.flp file
|
# Write *.flp file
|
||||||
Opt_flp = 'RC'
|
Opt_flp = 'RC'
|
||||||
pos.r.depth = rd
|
pos.r.depth = RD
|
||||||
write_fieldflp(filename, Opt_flp, pos, NProf=len(ssp), rProf=bathm.r)
|
write_fieldflp(filename, Opt_flp, pos, NProf=len(ssp), rProf=bathm.r)
|
||||||
# Call field.exe
|
# Call field.exe
|
||||||
system(AtBinPath + "/field " + filename)
|
system(AtBinPath + "/field " + filename)
|
||||||
|
|||||||
+14
-4
@@ -1,9 +1,17 @@
|
|||||||
from ramRW import PosRAM, PROF, SSPRAM, write_env_RAM, readTL_RAM
|
from pyat.ramRW import PosRAM, PROF, SSPRAM, write_env_RAM, readTL_RAM
|
||||||
from os import system
|
from os import system
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from config import AtBinPath
|
from pyat.config import AtBinPath
|
||||||
|
def calZmax(ssp, sed):
|
||||||
def call_ram(freq, sd, rd, bathm, ssp, sed):
|
d = np.array([])
|
||||||
|
for it in range(len(ssp)):
|
||||||
|
if sed == None:
|
||||||
|
d = np.append(d, ssp[it].z[-1])
|
||||||
|
else:
|
||||||
|
d = np.append(d, ssp[it].z[-1] + sed[it].z[-1])
|
||||||
|
Zmax = max(d)
|
||||||
|
return Zmax
|
||||||
|
def call_ram(freq, sd, bathm, ssp, sed):
|
||||||
''' ********************************************************************************* '''
|
''' ********************************************************************************* '''
|
||||||
''' ************************** Sound Field Calculation ****************************** '''
|
''' ************************** Sound Field Calculation ****************************** '''
|
||||||
''' ********************************************************************************* '''
|
''' ********************************************************************************* '''
|
||||||
@@ -15,6 +23,8 @@ def call_ram(freq, sd, rd, bathm, ssp, sed):
|
|||||||
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 = 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)
|
pos = PosRAM(sd, rd, rmax, zmax, dr, dz, zmplt)
|
||||||
|
|
||||||
# Sound speed profile for RAM
|
# Sound speed profile for RAM
|
||||||
|
|||||||
+19
-11
@@ -1,12 +1,12 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
from AcousticPara import GetEnv, Coord
|
from pyat.AcousticPara import GetEnv, Coord
|
||||||
from DataBase import DataBase
|
from pyat.DataBase import DataBase
|
||||||
from bellhop import call_Bellhop
|
from pyat.bellhop import call_Bellhop
|
||||||
from krakenc import call_krakenc
|
from pyat.krakenc import call_krakenc
|
||||||
from ram import call_ram
|
from pyat.ram import call_ram
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
def call_tl(database, freq, sourceDepth, sourceLat, sourceLon, receiveDepth,
|
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, modelType='kraken', isPlot=False):
|
||||||
""" Input:
|
""" Input:
|
||||||
freq - float, Frequency
|
freq - float, Frequency
|
||||||
@@ -40,8 +40,7 @@ def call_tl(database, freq, sourceDepth, sourceLat, sourceLon, receiveDepth,
|
|||||||
return [], [], [], bathym
|
return [], [], [], bathym
|
||||||
if modelType == 'bellhop':
|
if modelType == 'bellhop':
|
||||||
sd = np.array([sourceDepth]) # Source depth
|
sd = np.array([sourceDepth]) # Source depth
|
||||||
rd = np.linspace(0, receiveDepth, int(receiveDepth/10)) # Receiving depth
|
[Pos, TL] = call_Bellhop(freq, sd, bathym, ssp, sed, base)
|
||||||
[Pos, TL] = call_Bellhop(freq, sd, rd, bathym, ssp, sed, base)
|
|
||||||
# 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')
|
||||||
@@ -53,8 +52,7 @@ def call_tl(database, freq, sourceDepth, sourceLat, sourceLon, receiveDepth,
|
|||||||
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
|
||||||
rd = np.linspace(0, receiveDepth, int(receiveDepth/10)) # Receiving depth
|
[Pos, TL] = call_krakenc(freq, sd, bathym, ssp, sed, base)
|
||||||
[Pos, TL] = call_krakenc(freq, sd, rd, bathym, ssp, sed, base)
|
|
||||||
# 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')
|
||||||
@@ -66,7 +64,7 @@ def call_tl(database, freq, sourceDepth, sourceLat, sourceLon, receiveDepth,
|
|||||||
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, receiveDepth, bathym, ssp, sed)
|
[rd, rr, TL] = call_ram(freq, sourceDepth, bathym, ssp, sed)
|
||||||
# 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')
|
||||||
@@ -79,3 +77,13 @@ def call_tl(database, freq, sourceDepth, sourceLat, sourceLon, receiveDepth,
|
|||||||
else:
|
else:
|
||||||
return [], [], [], bathym
|
return [], [], [], bathym
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# # 创建类
|
||||||
|
# database = DataBase()
|
||||||
|
# # 设置时间段
|
||||||
|
# database.set_timePeriod('06')
|
||||||
|
# # 设置时间段
|
||||||
|
# #database.set_timePeriod(timeIndex)
|
||||||
|
# range, depth, tl, bathym = call_tl(database=database,freq=200, sourceDepth=60, sourceLat=19, sourceLon=127,
|
||||||
|
# receiveLat=17.5, receiveLon=127.1, modelType='ram', isPlot=True)
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户