- 积分
- 67314
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-7-23
- 最后登录
- 1970-1-1
|
发表于 2025-1-22 22:19:53
来自手机
|
显示全部楼层
本帖最后由 edwardli 于 2025-1-23 09:50 编辑
雷小Py-037:在经验基础上盲解二进制数据_2025.01.22 https://www.bilibili.com/video/BV1nGfhYGE8Q/?spm_id_from=333.1387.homepage.video_card.click
SWAN_CR_HEADER = [
("elses", "16c"),
("data_type", "12c"),
# ("data_name", "38c"),
("name", "14c"),
# ("version", "8c"),
("year", "u2"),#42
("month", "u2"),#44
("day", "u2"),#46
("hour", "u2"),#48
("minute", "u2"),#50
("start_lon", "u4"),#52
("start_lat", "u4"),#56
("end_lon", "u4"),#60
("end_lat", "u4"),#64
("unknown1", "u4"),#68
("x_number", "u2"),#72
("y_number", "u2"),#74
("unknown2", "u4"),#76
("x_reso", "u4"),#80
("y_reso", "u4"),#84
('剩下的','1012c')
]
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from metpy.plots import colortables
norm, cmap = colortables.get_with_steps('NWSReflectivity', 1, 5)
SWAN_CR_HEADER = np.dtype(SWAN_CR_HEADER)
# f = prepare_file('data/Radar/Z_OTHE_RADAMCR_20200812020000.bin.bz2')
# f = prepare_file('pics/雷小Py/RADA_NCN_DOR_L2_CR-202006252200.zip')
with open(r'pics\雷小Py\2006252200.dat','rb') as f:
header = np.frombuffer(f.read(1100), SWAN_CR_HEADER)
crdata = np.frombuffer(f.read(),'u1').reshape(header['y_number'][0],header['x_number'][0])/2-33
start_lon= header["start_lon"][0]*0.001
start_lat = header["start_lat"][0]*0.001
# end_lon = header["end_lon"][0]*0.001
# end_lat = header["end_lat"][0]*0.001
x_reso = header["x_reso"][0]*0.0001
y_reso = header["y_reso"][0]*0.0001
end_lon = start_lon + x_reso*header['x_number'][0]
end_lat = start_lat + y_reso*header['y_number'][0]
crdata[crdata==-32] = np.nan
lons = np.arange(start_lon,end_lon,x_reso)
lats = np.arange(start_lat,end_lat,y_reso)
# A4纸
fig = plt.figure(dpi=180)
# 坐标系
ax = plt.subplot(111, projection=ccrs.PlateCarree())
plt.pcolormesh(lons, lats, crdata, transform=ccrs.PlateCarree(),norm=norm, cmap=cmap)
from cartopy.io.shapereader import Reader
shpname=r'shp\cn_province.shp'
adm1_shapes=list(Reader(shpname).geometries())
ax.add_geometries(adm1_shapes[:],ccrs.PlateCarree(),edgecolor='k',facecolor='None',linewidth=0.5) #36:72东三省
ax.coastlines()
plt.show() |
|