去掉了接收深度接口,

更改了间隔dr。
这个提交包含在:
2023-04-07 16:11:16 +08:00
父节点 888a80e69c
当前提交 3ed8fe0dea
共修改 7 个文件,包含 175 行新增和 130 行删除
+38 -29
查看文件
@@ -4,7 +4,7 @@ warnings.filterwarnings('ignore')
import argparse, json
from common import NoIndent, MyEncoder
import os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))+'/pyat')
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + '/pyat')
def _argparse():
parser = argparse.ArgumentParser(description='Average Noise Spectral Level')
@@ -18,13 +18,13 @@ def main():
if argfile[-5:] != '.json':
print('输入的参数文件名有误')
return
with open(argfile,'r') as jsonFile:
with open(argfile, 'r') as jsonFile:
paramData = json.load(jsonFile)
if ("ETOPO1Path" not in paramData) or ("STPath" not in paramData) or \
("freq" not in paramData) or ("sourceDepth" not in paramData) or ("receiveDepth" not in paramData) or\
("lat" not in paramData) or ("lon" not in paramData) or\
("timeType" not in paramData) or\
("outParam" not in paramData):
("freq" not in paramData) or ("sourceDepth" not in paramData) or ("receiveDepth" not in paramData) or \
("lat" not in paramData) or ("lon" not in paramData) or \
("timeType" not in paramData) or \
("outParam" not in paramData):
print(f'{argfile}中的参数有误,请核实!')
return
ETOPO1Path = paramData["ETOPO1Path"]
@@ -42,7 +42,7 @@ def main():
outParam = paramData["outParam"]
if "outPath" not in outParam:
outParam["outPath"] = ""
from DataBase import DataBase
from czcore import call_cz
import numpy as np
@@ -50,7 +50,7 @@ def main():
# 定义时间段
timeIndex = timeType
# 创建类
database = DataBase(ETOPO1Path, STPath,dataSource="")
database = DataBase(ETOPO1Path, STPath, dataSource="")
# 设置时间段
database.set_timePeriod(timeIndex)
@@ -60,11 +60,11 @@ def main():
# czdata.TL是损失、czdata.bathym是地形数据
# czdata.Rays是声线数据
# czdata.CzDetail是会聚区数据,包括会聚区宽度和距离
res = call_cz(database, freq, lat, lon, azi, sourceDepth, receiveDepth)
res = call_cz(database, freq, lat, lon, azi, sourceDepth)
# call_cz(25, 18.0, 114.0, 10, 3500)
# write data to file
#输出json文件
# 输出json文件
outData = {}
outData["param"] = paramData
if len(res) == 0:
@@ -72,10 +72,10 @@ def main():
outData["data"] = []
else:
outData["result"] = "有会聚区"
outDataData, outBathymData,outTlData,outRayData = [],[],[],[]
outDataData, outBathymData, outTlData, outRayData = [], [], [], []
json.encoder.FLOAT_REPR = lambda x: format(x, '.3f')
for index in range(len(res)):
bathymData,tlData,rayData = {},{},{}
bathymData, tlData, rayData = {}, {}, {}
# 保存地形数据
res[index].bathym.r = np.around(res[index].bathym.r, decimals=0)
res[index].bathym.d = np.around(res[index].bathym.d, decimals=0)
@@ -84,18 +84,20 @@ def main():
"azi": f'{round(res[index].azi)}',
"count": len(res[index].bathym.d),
"descript": "距离、深度",
"data": NoIndent(list(zip(res[index].bathym.r,res[index].bathym.d)))
"data": NoIndent(list(zip(res[index].bathym.r, res[index].bathym.d)))
}
# 保存传播损失数据
tlpoint = []
res[index].depths = np.around(res[index].depths, decimals=0)
res[index].ranges = np.around(res[index].ranges, decimals=0)
res[index].TL = np.around(res[index].TL, decimals=2)
tlpoint = list(zip(np.tile(res[index].depths.reshape(len(res[index].depths),1),len(res[index].ranges)).flatten(), np.tile(res[index].ranges,(len(res[index].depths),1)).flatten(), res[index].TL.flatten()))
tlpoint = list(
zip(np.tile(res[index].depths.reshape(len(res[index].depths), 1), len(res[index].ranges)).flatten(),
np.tile(res[index].ranges, (len(res[index].depths), 1)).flatten(), res[index].TL.flatten()))
tlData = {
"param": paramData,
"azi": f'{round(res[index].azi)}',
"count": len(res[index].ranges)*len(res[index].depths),
"count": len(res[index].ranges) * len(res[index].depths),
"descript": "距离、深度、损失",
"data": NoIndent(tlpoint)
}
@@ -106,7 +108,7 @@ def main():
ray.xy[1] = np.around(ray.xy[1], decimals=2)
tempdata = {
"pointCount": len(ray.xy[0]),
"data": NoIndent(list(zip(ray.xy[0],ray.xy[1])))
"data": NoIndent(list(zip(ray.xy[0], ray.xy[1])))
}
raypoint.append(tempdata)
rayData = {
@@ -124,9 +126,9 @@ def main():
directczdetaillist = []
for directcz in res[index].CzDetail.directCz:
directczdetail = {
"minRange": f'{round(directcz.minRange,1)}',
"maxRange": f'{round(directcz.maxRange,1)}',
"width": f'{round(directcz.width,1)}',
"minRange": f'{round(directcz.minRange, 1)}',
"maxRange": f'{round(directcz.maxRange, 1)}',
"width": f'{round(directcz.width, 1)}',
}
directczdetaillist.append(directczdetail)
czDeatilData["directCz"] = directczdetaillist
@@ -136,9 +138,9 @@ def main():
reflectczdetaillist = []
for reflectcz in res[index].CzDetail.reflectCz:
reflectczdetail = {
"minRange": f'{round(reflectcz.minRange,1)}',
"maxRange": f'{round(reflectcz.maxRange,1)}',
"width": f'{round(reflectcz.width,1)}',
"minRange": f'{round(reflectcz.minRange, 1)}',
"maxRange": f'{round(reflectcz.maxRange, 1)}',
"width": f'{round(reflectcz.width, 1)}',
}
reflectczdetaillist.append(reflectczdetail)
czDeatilData["reflectCz"] = reflectczdetaillist
@@ -146,19 +148,26 @@ def main():
outBathymData.append(bathymData)
outTlData.append(tlData)
outRayData.append(rayData)
with open(("" if outParam["outPath"]=="" else outParam["outPath"] + "/")+"czOut_bathym.json", 'w') as jsonFile:
with open(("" if outParam["outPath"] == "" else outParam["outPath"] + "/") + "czOut_bathym.json",
'w') as jsonFile:
json_data = json.dumps(outBathymData, cls=MyEncoder, indent=2, ensure_ascii=False)
jsonFile.write(json_data)
with open(("" if outParam["outPath"]=="" else outParam["outPath"] + "/")+"czOut_tl.json", 'w') as jsonFile:
with open(("" if outParam["outPath"] == "" else outParam["outPath"] + "/") + "czOut_tl.json",
'w') as jsonFile:
json_data = json.dumps(outTlData, cls=MyEncoder, indent=2, ensure_ascii=False)
jsonFile.write(json_data)
with open(("" if outParam["outPath"]=="" else outParam["outPath"] + "/")+"czOut_ray.json", 'w') as jsonFile:
with open(("" if outParam["outPath"] == "" else outParam["outPath"] + "/") + "czOut_ray.json",
'w') as jsonFile:
json_data = json.dumps(outRayData, cls=MyEncoder, indent=2, ensure_ascii=False)
jsonFile.write(json_data)
outData["data"] = outDataData
with open(("" if outParam["outPath"]=="" else outParam["outPath"] + "/")+"czOut.json", 'w') as jsonFile:
with open(("" if outParam["outPath"] == "" else outParam["outPath"] + "/") + "czOut.json", 'w') as jsonFile:
json.dump(outData, jsonFile, indent=4, ensure_ascii=False)
# import time
if __name__ == '__main__':
main()
# start = time.perf_counter()
main()
# end = time.perf_counter()
# print('time = ',(end-start))