資源簡介
本程序利用Python讀取SA氣象雷達數據,并繪制回波圖。具有較好的效果
代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
“““
-------------------------------------------------------------
#?@Version?:?python3.6
#?@Author??:?wangTongGen
#?@File????:?SaDecoder.py
#?@Software:?PyCharm
#?@Time????:?2018/4/21?15:18
-------------------------------------------------------------
#?@Description:?This?code?is?programed?to?plot?SA_radarof?PPI
-------------------------------------------------------------
“““
import?matplotlib.pyplot?as?plt
import?numpy?as?np
from?array?import?array
from?matplotlib?import?colors
import?tkinter?as?tk
from?tkinter?import?filedialog
def?main():
????file=?openFile()
????k?=?int(input(‘請輸入您想觀察的仰角,請選擇1?3?5?6?7?8?9?10?11:‘))
????print(‘數據讀取中,請稍后...‘)
????el?az?rl?dbz?=?saDecoder(filek)
????#?el?az?rl?dbz?=?datalink(el?az?rl?dbz)?#調用該語句則將數據按照1-360度的方位角排序
????x?y?h?=?sph2cord(el?az?rl)
????plotFunction(x?y?dbz?k)
def?openFile():
????root?=?tk.Tk()
????root.withdraw()
????return?filedialog.askopenfilename()
def?saDecoder(file?k):
????f?=?open(file?‘rb‘)
????data?=?np.asarray(array(‘B‘?f.read()))
????data?=?data.reshape(len(data)//2432?2432)
????if?data[072]?==?11:
????????phi?=?[0.50?0.50?1.45?1.45?2.40?3.35?4.30?5.25?6.2?7.5?8.7?10?12?14?16.7?19.5]
????if?data[0?72]?==?21:
????????phi?=?[0.50?0.50?1.45?1.45?2.40?3.35?4.30?6.00?9.00?14.6?19.5]
????if?data[0?72]?==?31:
????????phi?=?[0.50?0.50?1.50?1.50?2.50?2.50?3.50?4.50]
????if?data[0?72]?==?32:
????????phi?=?[0.50?0.50?2.50?3.50?4.50]
????el?=?np.zeros((len(data)?460))??#仰角
????az?=?np.zeros((len(data)?460))??#方位角
????rl?=?np.zeros((len(data)?460))??#徑向長度
????dbz?=?np.zeros((len(data)?460))??#反射率
????count?=?0
????while?count?????????el_number?=?data[count44]?+?256?*?data[count45]?#仰角序數
????????az_value?=?(data[count36]?+?256?*?data[count37])?/?8?*?180?/?4096??#方位角
????????d_value?=?data[count54]?+?256?*?data[count55]?#庫長
????????if?d_value?==?0:
????????????count?+=?1
????????????continue
????????else:
????????????count?+=?1
????????i?=?0
????????while?i?460:
????????????el[count-1?i]?=?phi[el_number-1]
????????????az[count-1?i]?=?az_value
????????????rl[count-1?i]?=?i?+?1
?
- 上一篇:Python 貪吃蛇
- 下一篇:適合的新手-CNN代碼
評論
共有 條評論