Skip to content

Commit

Permalink
补充了库使用和绘图案例
Browse files Browse the repository at this point in the history
  • Loading branch information
longtsing committed Dec 11, 2024
1 parent b6bc591 commit 38fc16a
Show file tree
Hide file tree
Showing 8 changed files with 10,577 additions and 316 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ cython_debug/
.idea/
.vscode/
.ipynb_checkpoints/
.virtual_documents/

#测试数据目录,避免上传
datas/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,117 @@ import types
from joblib import Parallel, delayed
import metgrs
from metgrs import WindProfileRadar
import glob


metgrs.__version__


datapath='../datas/'





fftfs=sorted(glob.glob(datapath+'/WindProfileRadarFiles/20241204/WIND_FFT/*'))


fftfs[0]





di=WindProfileRadar.readSingleL1file(fftfs[0])


da=di['Datas'][0]['DspToDpDat']


da


fig, axs = plt.subplots(figsize=(18,16),nrows = 35, ncols = 5)
for i in range(35):
for j in range(5):
x = da.Fft
y = np.log(da[j,i])
axs[i][j].plot(x, y)
# 除了最下面一行的子图,隐藏横坐标
if i < 34:
axs[i][j].tick_params(axis='x', which='both', bottom=False, labelbottom=False)
if j >0:
axs[i][j].tick_params(axis='y', which='both', left=False, labelleft=False)





L2fs=sorted(glob.glob(datapath+'/WindProfileRadarFiles/20241204/WIND_RAD/*'))


l2d=WindProfileRadar.readSingleL2file(L2fs[0])


l2d['levels'][0].data


l2d['levels'][1].data





L3fs=sorted(glob.glob(datapath+'/WindProfileRadarFiles/20241204/WIND_ROBS/*.TXT'))


WindProfileRadar.readSingleL3file(L3fs[0])


ds=WindProfileRadar.readL3files(L3fs)


ds[0].data


dtlist=list(map(lambda x:x['Observation_Time']+timedelta(hours=8),ds))
heights=ds[0]['data']['Sampling_Height'].values


data.shape


cdata.shape


data=np.array(list(map(lambda x:x['data'][['U_Wind_Speed','V_Wind_Speed']].values,ds)))
cdata=np.array(list(map(lambda x:x['data']['Vertical_Wind_Speed'].values,ds)))
# da=xr.DataArray(
# data,
# dims=['time','height','wind'],coords={
# 'time':dtlist,
# 'height':heights,
# 'wind':['U_Wind_Speed','V_Wind_Speed']
# })
# gheights,gtimes=np.meshgrid(da.height,da.time)
gtimes,gheights=np.meshgrid(heights,dtlist)
# 绘制凤羽图
# 首先创建一个 figure 对象,
fig = plt.figure(figsize=(18, 12))
ax = fig.add_subplot(1, 1, 1)
# 绘制凤羽图,ax.barbs 有四个参数是必须的,第一个 x 表示绘制凤羽的 x 坐标,第二个 y 表示绘制凤羽的 y 坐标,第三个为 u风 ,第四个为 v风
# 由于我们只对一个 风廓线实时产品数据文件进行绘制,所以 x 坐标不变
cb=ax.barbs(
gheights[::5],gtimes[::5], data[::5,:,0], data[::5,:,1],
cdata[::5],
cmap=WindProfileRadar.velocity_cmap,
norm=WindProfileRadar.velocity_norm,
barb_increments=dict(half=2, full=5, flag=10) # 该行是定义绘制风羽的标准
)
# 添加垂直坐标的标签
ax.set_ylabel('Height(unit:meter)')
plt.colorbar(cb)
plt.show()



Expand Down
Loading

0 comments on commit 38fc16a

Please sign in to comment.