metradar 0.1.6__py3-none-any.whl → 0.1.8.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metradar/__init__.py +4 -2
- metradar/config.py +53 -0
- metradar/core/__init__.py +9 -0
- metradar/{get_cross_section_from_pyart.py → core/get_cross_section.py} +5 -157
- metradar/{mosaic_merge.py → core/mosaic_merge.py} +3 -1
- metradar/{oa_dig_func.py → core/oa_dig_func.py} +83 -333
- metradar/graph/__init__.py +9 -0
- metradar/{mosaic_quickdraw.py → graph/draw_comp_mosaic.py} +71 -68
- metradar/{draw_mosaic_new.py → graph/draw_latlon_func.py} +177 -173
- metradar/graph/draw_radar_aws.py +212 -0
- metradar/{draw_radar_comp_func.py → graph/draw_radar_comp_func.py} +319 -248
- metradar/graph/parse_pal.py +157 -0
- metradar/io/__init__.py +9 -0
- metradar/{cnrad_level2.py → io/cnrad_level2.py} +45 -2
- metradar/{decode_fmt_pyart.py → io/decode_fmt_pyart.py} +20 -3
- metradar/{decode_pup_rose.py → io/decode_pup_rose.py} +241 -684
- metradar/{read_new_mosaic_func.py → io/read_new_mosaic_func.py} +30 -2
- metradar/io/read_swan.py +250 -0
- metradar/{rose_structer.py → io/rose_structer.py} +2 -0
- metradar/project/__init__.py +9 -0
- metradar/project/make_mosaic/__init__.py +9 -0
- metradar/project/make_mosaic/batch_draw_mosaic.py +32 -0
- metradar/{make_mosaic_mp_archive.py → project/make_mosaic/make_mosaic_func.py} +144 -175
- metradar/project/make_mosaic/make_mosaic_mp.ini +29 -0
- metradar/project/make_mosaic/make_mosaic_mp.py +70 -0
- metradar/project/make_vpr_aws/__init__.py +9 -0
- metradar/project/make_vpr_aws/construct_aws_refvpr_mainprog.ini +39 -0
- metradar/project/make_vpr_aws/construct_aws_refvpr_mainprog.py +565 -0
- metradar/project/make_vpr_aws/make_mosaic_20230731_daxing.ini +29 -0
- metradar/project/make_vpr_aws/make_mosaic_basefile.ini +29 -0
- metradar/project/nowcasting/__init__.py +9 -0
- metradar/project/nowcasting/nowcast_by_pysteps.py +214 -0
- metradar/{trans_nc_pgmb.py → project/nowcasting/trans_mosaic_pgmb.py} +19 -17
- metradar/project/qpe/Archive /346/250/241/345/274/217/350/257/264/346/230/216.txt" +2 -0
- metradar/project/qpe/__init__.py +9 -0
- metradar/project/qpe/archive_main_qpe_cfg.ini +91 -0
- metradar/project/qpe/do_s1.sh +6 -0
- metradar/project/qpe/do_s2.sh +6 -0
- metradar/project/qpe/do_s3.sh +6 -0
- metradar/project/qpe/do_s4.sh +6 -0
- metradar/project/qpe/do_s5.sh +6 -0
- metradar/project/qpe/exec_all.sh +11 -0
- metradar/project/qpe/get_rainrate_func.py +80 -0
- metradar/project/qpe/main_qpe_cfg.ini +85 -0
- metradar/project/qpe/s1_download_radar_region_cmadaas.py +123 -0
- metradar/project/qpe/s2_pre_process_single_radar.py +183 -0
- metradar/project/qpe/s3_trans_rainrate_to_qpe.py +499 -0
- metradar/project/qpe/s4_mosaic_qpe.py +523 -0
- metradar/project/qpe/s5_draw_qpe_mosaic.py +308 -0
- metradar/project/wind_retrieval/__init__.py +9 -0
- metradar/project/wind_retrieval/config_3dwind.ini +45 -0
- metradar/{main_pydda.py → project/wind_retrieval/main_pydda.py} +152 -149
- metradar/util/__init__.py +9 -0
- metradar/{comm_func.py → util/comm_func.py} +1 -41
- metradar/util/exceptions.py +50 -0
- metradar/util/geo_transforms_pyart.py +627 -0
- metradar/{get_tlogp_from_sharppy.py → util/get_tlogp_from_sharppy.py} +16 -5
- metradar/{parse_pal.py → util/parse_pal.py} +147 -147
- metradar/util/radar_common.py +16 -0
- metradar/{trans_new_mosaic_nc.py → util/trans_new_mosaic_nc.py} +1 -1
- metradar-0.1.8.2.dist-info/METADATA +90 -0
- metradar-0.1.8.2.dist-info/RECORD +69 -0
- {metradar-0.1.6.dist-info → metradar-0.1.8.2.dist-info}/WHEEL +1 -1
- metradar-0.1.8.2.dist-info/licenses/LICENSE +21 -0
- {metradar-0.1.6.dist-info → metradar-0.1.8.2.dist-info}/top_level.txt +0 -1
- cfg/config.py +0 -90
- metradar/grid.py +0 -281
- metradar/grid_data.py +0 -64
- metradar/oa_couhua.py +0 -166
- metradar/read_new_mosaic.py +0 -33
- metradar/retrieve_cmadaas.py +0 -3126
- metradar/retrieve_micaps_server.py +0 -2061
- metradar-0.1.6.dist-info/METADATA +0 -37
- metradar-0.1.6.dist-info/RECORD +0 -34
- /metradar/{pgmb_io.py → io/pgmb_io.py} +0 -0
- /metradar/{exceptions.py → project/make_vpr_aws/exceptions.py} +0 -0
- /metradar/{geo_transforms_pyart.py → project/make_vpr_aws/geo_transforms_pyart.py} +0 -0
- /metradar/{make_gif.py → util/make_gif.py} +0 -0
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
'''
|
|
4
|
-
@File : decode_pup_rose.py
|
|
5
|
-
@Time : 2023/04/27 23:12:54
|
|
6
|
-
@Author : Wenjian Zhu
|
|
7
|
-
@Version : 1.0
|
|
8
|
-
@Email : kevin2075@163.com
|
|
9
|
-
'''
|
|
1
|
+
|
|
2
|
+
# _*_ coding: utf-8 _*_
|
|
10
3
|
|
|
11
4
|
'''
|
|
12
5
|
解析pup_rose文件
|
|
@@ -16,18 +9,18 @@
|
|
|
16
9
|
# %%
|
|
17
10
|
import os
|
|
18
11
|
import numpy as np
|
|
19
|
-
import geo_transforms_pyart as geotrans
|
|
12
|
+
import metradar.util.geo_transforms_pyart as geotrans
|
|
20
13
|
from datetime import datetime,timedelta
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# STORM_PROPERTY,STORM_TRACK_PARAM,STORM_COMPONENT
|
|
14
|
+
from .rose_structer import _unpack_from_buf,_structure_size
|
|
15
|
+
from .rose_structer import *
|
|
16
|
+
|
|
25
17
|
import xarray as xr
|
|
26
|
-
|
|
18
|
+
from pyart.core import Radar
|
|
19
|
+
from pyart.config import FileMetadata
|
|
20
|
+
from pyart.io.common import make_time_unit_str
|
|
27
21
|
|
|
28
22
|
class READ_ROSE(object):
|
|
29
23
|
|
|
30
|
-
|
|
31
24
|
def __init__(self,):
|
|
32
25
|
self.stiinfo = None
|
|
33
26
|
self.mesoinfo = None
|
|
@@ -149,81 +142,81 @@ class READ_ROSE(object):
|
|
|
149
142
|
pos = 0
|
|
150
143
|
|
|
151
144
|
# 获取通用信息头
|
|
152
|
-
dic_gh =
|
|
145
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
153
146
|
# pprint(dic_gh)
|
|
154
147
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
155
148
|
print('源数据格式错误!')
|
|
156
|
-
pos = pos +
|
|
149
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
157
150
|
|
|
158
151
|
# 获取站点信息
|
|
159
|
-
dic_scfg =
|
|
160
|
-
pos = pos +
|
|
152
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
153
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
161
154
|
|
|
162
155
|
# 获取任务信息
|
|
163
|
-
dic_tcfg =
|
|
164
|
-
pos = pos +
|
|
156
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
157
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
165
158
|
|
|
166
159
|
# 获取扫描信息
|
|
167
160
|
cutinfo = []
|
|
168
161
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
169
|
-
dic_cutcfg =
|
|
162
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
170
163
|
cutinfo.append(dic_cutcfg)
|
|
171
|
-
pos = pos +
|
|
164
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
172
165
|
|
|
173
166
|
# 获取产品头信息
|
|
174
|
-
dic_prod_header =
|
|
175
|
-
pos = pos +
|
|
167
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
168
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
176
169
|
|
|
177
170
|
# 获取产品参数信息
|
|
178
|
-
prod_type =
|
|
171
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
179
172
|
# pprint(prod_type)
|
|
180
|
-
dic_prod_param =
|
|
173
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
181
174
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
182
175
|
|
|
183
176
|
|
|
184
177
|
# 获取产品数据块
|
|
185
178
|
|
|
186
179
|
#获取STI头信息
|
|
187
|
-
dic_sti_header =
|
|
188
|
-
pos = pos +
|
|
180
|
+
dic_sti_header = _unpack_from_buf(buf, pos, SIT_HEADER_BLOCK)
|
|
181
|
+
pos = pos + _structure_size(SIT_HEADER_BLOCK)
|
|
189
182
|
|
|
190
183
|
# 风暴追踪信息块
|
|
191
184
|
# 风暴移动信息
|
|
192
185
|
storm_motion_block=[]
|
|
193
186
|
for nn in np.arange(dic_sti_header['storm_number']):
|
|
194
|
-
storm_motion_block.append(
|
|
195
|
-
pos = pos +
|
|
187
|
+
storm_motion_block.append(_unpack_from_buf(buf, pos, STORM_MOTION_BLOCK))
|
|
188
|
+
pos = pos + _structure_size(STORM_MOTION_BLOCK)
|
|
196
189
|
|
|
197
190
|
# 风暴预报信息
|
|
198
191
|
all_storm_fst_block=[]
|
|
199
192
|
for nn in np.arange(dic_sti_header['storm_number']):
|
|
200
|
-
dic_storm_fst_num =
|
|
201
|
-
pos = pos +
|
|
193
|
+
dic_storm_fst_num = _unpack_from_buf(buf, pos, STORM_FST_HIS_NUM)
|
|
194
|
+
pos = pos + _structure_size(STORM_FST_HIS_NUM)
|
|
202
195
|
|
|
203
196
|
storm_fst_block=[]
|
|
204
197
|
for nn in np.arange(dic_storm_fst_num['position_number']):
|
|
205
|
-
storm_fst_block.append(
|
|
206
|
-
pos = pos +
|
|
198
|
+
storm_fst_block.append(_unpack_from_buf(buf, pos, STORM_FST_HIS_BLOCK))
|
|
199
|
+
pos = pos + _structure_size(STORM_FST_HIS_BLOCK)
|
|
207
200
|
all_storm_fst_block.append(storm_fst_block)
|
|
208
201
|
|
|
209
202
|
# 风暴历史信息
|
|
210
203
|
all_storm_his_block=[]
|
|
211
204
|
for nn in np.arange(dic_sti_header['storm_number']):
|
|
212
|
-
dic_storm_his_num =
|
|
213
|
-
pos = pos +
|
|
205
|
+
dic_storm_his_num = _unpack_from_buf(buf, pos, STORM_FST_HIS_NUM)
|
|
206
|
+
pos = pos + _structure_size(STORM_FST_HIS_NUM)
|
|
214
207
|
|
|
215
208
|
storm_his_block=[]
|
|
216
209
|
for nn in np.arange(dic_storm_his_num['position_number']):
|
|
217
|
-
storm_his_block.append(
|
|
218
|
-
pos = pos +
|
|
210
|
+
storm_his_block.append(_unpack_from_buf(buf, pos, STORM_FST_HIS_BLOCK))
|
|
211
|
+
pos = pos + _structure_size(STORM_FST_HIS_BLOCK)
|
|
219
212
|
all_storm_his_block.append(storm_his_block)
|
|
220
213
|
|
|
221
214
|
# 风暴属性表块数据
|
|
222
215
|
# 风暴属性
|
|
223
216
|
all_storm_prop=[]
|
|
224
217
|
for nn in np.arange(dic_sti_header['storm_number']):
|
|
225
|
-
dic_storm_prop =
|
|
226
|
-
pos = pos +
|
|
218
|
+
dic_storm_prop = _unpack_from_buf(buf, pos, STORM_PROPERTY)
|
|
219
|
+
pos = pos + _structure_size(STORM_PROPERTY)
|
|
227
220
|
|
|
228
221
|
# 将风暴数字ID转换为字符串ID
|
|
229
222
|
dic_storm_prop['id_char'] = self.get_id_char(dic_storm_prop['id'])
|
|
@@ -237,13 +230,13 @@ class READ_ROSE(object):
|
|
|
237
230
|
# 风暴构成表
|
|
238
231
|
all_storm_comp=[]
|
|
239
232
|
for nn in np.arange(dic_sti_header['storm_number']):
|
|
240
|
-
dic_storm_comp =
|
|
241
|
-
pos = pos +
|
|
233
|
+
dic_storm_comp = _unpack_from_buf(buf, pos, STORM_COMPONENT)
|
|
234
|
+
pos = pos + _structure_size(STORM_COMPONENT)
|
|
242
235
|
all_storm_comp.append(dic_storm_comp)
|
|
243
236
|
|
|
244
237
|
# 风暴追踪适配数据
|
|
245
|
-
dic_storm_track_param =
|
|
246
|
-
pos = pos +
|
|
238
|
+
dic_storm_track_param = _unpack_from_buf(buf, pos, STORM_TRACK_PARAM)
|
|
239
|
+
pos = pos + _structure_size(STORM_TRACK_PARAM)
|
|
247
240
|
|
|
248
241
|
|
|
249
242
|
allresult={}
|
|
@@ -331,49 +324,49 @@ class READ_ROSE(object):
|
|
|
331
324
|
pos = 0
|
|
332
325
|
|
|
333
326
|
# 获取通用信息头
|
|
334
|
-
dic_gh =
|
|
327
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
335
328
|
# pprint(dic_gh)
|
|
336
329
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
337
330
|
print('源数据格式错误!')
|
|
338
|
-
pos = pos +
|
|
331
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
339
332
|
|
|
340
333
|
# 获取站点信息
|
|
341
|
-
dic_scfg =
|
|
342
|
-
pos = pos +
|
|
334
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
335
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
343
336
|
|
|
344
337
|
# 获取任务信息
|
|
345
|
-
dic_tcfg =
|
|
346
|
-
pos = pos +
|
|
338
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
339
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
347
340
|
|
|
348
341
|
# 获取扫描信息
|
|
349
342
|
cutinfo = []
|
|
350
343
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
351
|
-
dic_cutcfg =
|
|
344
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
352
345
|
cutinfo.append(dic_cutcfg)
|
|
353
|
-
pos = pos +
|
|
346
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
354
347
|
|
|
355
348
|
# 获取产品头信息
|
|
356
|
-
dic_prod_header =
|
|
357
|
-
pos = pos +
|
|
349
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
350
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
358
351
|
|
|
359
352
|
# 获取产品参数信息
|
|
360
|
-
prod_type =
|
|
353
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
361
354
|
# pprint(prod_type)
|
|
362
|
-
dic_prod_param =
|
|
355
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
363
356
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
364
357
|
|
|
365
358
|
|
|
366
359
|
# 获取产品数据块
|
|
367
360
|
|
|
368
361
|
#获取SS头信息
|
|
369
|
-
dic_ss_header =
|
|
370
|
-
pos = pos +
|
|
362
|
+
dic_ss_header = _unpack_from_buf(buf, pos, SS_HEAD_BLOCK)
|
|
363
|
+
pos = pos + _structure_size(SS_HEAD_BLOCK)
|
|
371
364
|
|
|
372
365
|
# SS结构信息
|
|
373
366
|
ss_tab=[]
|
|
374
367
|
for nn in np.arange(dic_ss_header['storm_number']):
|
|
375
|
-
tmp_tab =
|
|
376
|
-
pos = pos +
|
|
368
|
+
tmp_tab = _unpack_from_buf(buf, pos, SS_TAB)
|
|
369
|
+
pos = pos + _structure_size(SS_TAB)
|
|
377
370
|
# 将风暴数字ID转换为字符串ID
|
|
378
371
|
tmp_tab['id_char'] = self.get_id_char(tmp_tab['storm_id'])
|
|
379
372
|
|
|
@@ -384,29 +377,29 @@ class READ_ROSE(object):
|
|
|
384
377
|
cell_trend=[]
|
|
385
378
|
for nn in np.arange(dic_ss_header['storm_number']):
|
|
386
379
|
cur_cellinfo={}
|
|
387
|
-
cell_info=
|
|
388
|
-
pos = pos +
|
|
380
|
+
cell_info=_unpack_from_buf(buf, pos, CELL_TREND)
|
|
381
|
+
pos = pos + _structure_size(CELL_TREND)
|
|
389
382
|
cur_cellinfo['head_info'] = cell_info
|
|
390
383
|
# 历史体扫信息
|
|
391
384
|
tmpcell_his=[]
|
|
392
385
|
for im in np.arange(cell_info['his_vol_num']):
|
|
393
|
-
tmpcell_his.append(
|
|
394
|
-
pos = pos +
|
|
386
|
+
tmpcell_his.append(_unpack_from_buf(buf, pos, HIS_VOL))
|
|
387
|
+
pos = pos + _structure_size(HIS_VOL)
|
|
395
388
|
cur_cellinfo['cell_info'] = tmpcell_his
|
|
396
389
|
|
|
397
390
|
cell_trend.append(cur_cellinfo)
|
|
398
391
|
|
|
399
392
|
# 风暴段适配数据
|
|
400
|
-
seg_adapt =
|
|
401
|
-
pos = pos +
|
|
393
|
+
seg_adapt = _unpack_from_buf(buf, pos, SEG_ADAPT)
|
|
394
|
+
pos = pos + _structure_size(SEG_ADAPT)
|
|
402
395
|
|
|
403
396
|
# 风暴质心适配数据
|
|
404
|
-
centroid_adapt =
|
|
405
|
-
pos = pos +
|
|
397
|
+
centroid_adapt = _unpack_from_buf(buf, pos, CENTROIDS_ADAPT)
|
|
398
|
+
pos = pos + _structure_size(CENTROIDS_ADAPT)
|
|
406
399
|
|
|
407
400
|
# 风暴追踪适配数据
|
|
408
|
-
storm_track_adapt =
|
|
409
|
-
pos = pos +
|
|
401
|
+
storm_track_adapt = _unpack_from_buf(buf, pos, STORM_TRACK_PARAM)
|
|
402
|
+
pos = pos + _structure_size(STORM_TRACK_PARAM)
|
|
410
403
|
|
|
411
404
|
|
|
412
405
|
# 将所有的方位角和距离转换成经纬度
|
|
@@ -436,59 +429,58 @@ class READ_ROSE(object):
|
|
|
436
429
|
pos = 0
|
|
437
430
|
|
|
438
431
|
# 获取通用信息头
|
|
439
|
-
dic_gh =
|
|
432
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
440
433
|
# pprint(dic_gh)
|
|
441
434
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
442
435
|
print('源数据格式错误!')
|
|
443
|
-
pos = pos +
|
|
436
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
444
437
|
|
|
445
438
|
# 获取站点信息
|
|
446
|
-
dic_scfg =
|
|
447
|
-
pos = pos +
|
|
439
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
440
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
448
441
|
|
|
449
442
|
# 获取任务信息
|
|
450
|
-
dic_tcfg =
|
|
451
|
-
pos = pos +
|
|
443
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
444
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
452
445
|
|
|
453
446
|
# 获取扫描信息
|
|
454
447
|
cutinfo = []
|
|
455
448
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
456
|
-
dic_cutcfg =
|
|
449
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
457
450
|
cutinfo.append(dic_cutcfg)
|
|
458
|
-
pos = pos +
|
|
451
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
459
452
|
|
|
460
453
|
# 获取产品头信息
|
|
461
|
-
dic_prod_header =
|
|
462
|
-
pos = pos +
|
|
454
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
455
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
463
456
|
|
|
464
457
|
# 获取产品参数信息
|
|
465
|
-
prod_type =
|
|
458
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
466
459
|
# pprint(prod_type)
|
|
467
|
-
dic_prod_param =
|
|
460
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
468
461
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
469
462
|
|
|
470
463
|
# 获取产品数据块
|
|
471
464
|
|
|
472
465
|
#获取中气旋头信息
|
|
473
|
-
dic_meso_header =
|
|
474
|
-
pos = pos +
|
|
466
|
+
dic_meso_header = _unpack_from_buf(buf, pos, MESO_HEADER_BLOCK)
|
|
467
|
+
pos = pos + _structure_size(MESO_HEADER_BLOCK)
|
|
475
468
|
|
|
476
469
|
# 中气旋表块
|
|
477
470
|
meso_tab=[]
|
|
478
471
|
for nn in np.arange(dic_meso_header['meso_number']):
|
|
479
|
-
meso_tab.append(
|
|
480
|
-
pos = pos +
|
|
472
|
+
meso_tab.append(_unpack_from_buf(buf, pos, MESO_TABLE))
|
|
473
|
+
pos = pos + _structure_size(MESO_TABLE)
|
|
481
474
|
|
|
482
475
|
# 中气旋特征表
|
|
483
476
|
meso_feature_tab=[]
|
|
484
477
|
for nn in np.arange(dic_meso_header['feature_number']):
|
|
485
|
-
meso_feature_tab.append(
|
|
486
|
-
pos = pos +
|
|
478
|
+
meso_feature_tab.append(_unpack_from_buf(buf, pos, MESO_FEATURE_TAB))
|
|
479
|
+
pos = pos + _structure_size(MESO_FEATURE_TAB)
|
|
487
480
|
|
|
488
481
|
# 中气旋适配数据
|
|
489
|
-
dic_meso_adapt_param =
|
|
490
|
-
pos = pos +
|
|
491
|
-
|
|
482
|
+
dic_meso_adapt_param = _unpack_from_buf(buf, pos, MESO_ADAPTATION_DATA)
|
|
483
|
+
pos = pos + _structure_size(MESO_ADAPTATION_DATA)
|
|
492
484
|
|
|
493
485
|
|
|
494
486
|
for nn in np.arange(dic_meso_header['meso_number']):
|
|
@@ -534,52 +526,52 @@ class READ_ROSE(object):
|
|
|
534
526
|
pos = 0
|
|
535
527
|
|
|
536
528
|
# 获取通用信息头
|
|
537
|
-
dic_gh =
|
|
529
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
538
530
|
# pprint(dic_gh)
|
|
539
531
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
540
532
|
print('源数据格式错误!')
|
|
541
|
-
pos = pos +
|
|
533
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
542
534
|
|
|
543
535
|
# 获取站点信息
|
|
544
|
-
dic_scfg =
|
|
545
|
-
pos = pos +
|
|
536
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
537
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
546
538
|
|
|
547
539
|
# 获取任务信息
|
|
548
|
-
dic_tcfg =
|
|
549
|
-
pos = pos +
|
|
540
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
541
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
550
542
|
|
|
551
543
|
# 获取扫描信息
|
|
552
544
|
cutinfo = []
|
|
553
545
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
554
|
-
dic_cutcfg =
|
|
546
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
555
547
|
cutinfo.append(dic_cutcfg)
|
|
556
|
-
pos = pos +
|
|
548
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
557
549
|
|
|
558
550
|
# 获取产品头信息
|
|
559
|
-
dic_prod_header =
|
|
560
|
-
pos = pos +
|
|
551
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
552
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
561
553
|
|
|
562
554
|
# 获取产品参数信息
|
|
563
|
-
prod_type =
|
|
555
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
564
556
|
# pprint(prod_type)
|
|
565
|
-
dic_prod_param =
|
|
557
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
566
558
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
567
559
|
|
|
568
560
|
# 获取产品数据块
|
|
569
561
|
|
|
570
562
|
#获取TVS头信息
|
|
571
|
-
dic_tvs_header =
|
|
572
|
-
pos = pos +
|
|
563
|
+
dic_tvs_header = _unpack_from_buf(buf, pos, TVS_HEADER_BLOCK)
|
|
564
|
+
pos = pos + _structure_size(TVS_HEADER_BLOCK)
|
|
573
565
|
|
|
574
566
|
# TVS表块
|
|
575
567
|
tvs_tab=[]
|
|
576
568
|
for nn in np.arange(dic_tvs_header['tvs_number']):
|
|
577
|
-
tvs_tab.append(
|
|
578
|
-
pos = pos +
|
|
569
|
+
tvs_tab.append(_unpack_from_buf(buf, pos, TVS_TAB))
|
|
570
|
+
pos = pos + _structure_size(TVS_TAB)
|
|
579
571
|
|
|
580
572
|
# TVS适配数据
|
|
581
|
-
dic_tvs_adapt_param =
|
|
582
|
-
pos = pos +
|
|
573
|
+
dic_tvs_adapt_param = _unpack_from_buf(buf, pos, TVS_ADAPTATION_DATA)
|
|
574
|
+
pos = pos + _structure_size(TVS_ADAPTATION_DATA)
|
|
583
575
|
|
|
584
576
|
|
|
585
577
|
# 将所有的方位角和距离转换成经纬度
|
|
@@ -616,50 +608,50 @@ class READ_ROSE(object):
|
|
|
616
608
|
pos = 0
|
|
617
609
|
|
|
618
610
|
# 获取通用信息头
|
|
619
|
-
dic_gh =
|
|
611
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
620
612
|
# pprint(dic_gh)
|
|
621
613
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
622
614
|
print('源数据格式错误!')
|
|
623
615
|
return None
|
|
624
|
-
pos = pos +
|
|
616
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
625
617
|
|
|
626
618
|
# 获取站点信息
|
|
627
|
-
dic_scfg =
|
|
628
|
-
pos = pos +
|
|
619
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
620
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
629
621
|
|
|
630
622
|
# 获取任务信息
|
|
631
|
-
dic_tcfg =
|
|
632
|
-
pos = pos +
|
|
623
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
624
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
633
625
|
|
|
634
626
|
# 获取扫描信息
|
|
635
627
|
cutinfo = []
|
|
636
628
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
637
|
-
dic_cutcfg =
|
|
629
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
638
630
|
cutinfo.append(dic_cutcfg)
|
|
639
|
-
pos = pos +
|
|
631
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
640
632
|
|
|
641
633
|
# 获取产品头信息
|
|
642
|
-
dic_prod_header =
|
|
643
|
-
pos = pos +
|
|
634
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
635
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
644
636
|
|
|
645
637
|
# 获取产品参数信息
|
|
646
|
-
prod_type =
|
|
647
|
-
dic_prod_param =
|
|
638
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
639
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
648
640
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
649
641
|
|
|
650
642
|
# 读取产品径向头信息
|
|
651
|
-
dic_radial_header =
|
|
652
|
-
pos = pos +
|
|
643
|
+
dic_radial_header = _unpack_from_buf(buf, pos, RADIAL_HEADER)
|
|
644
|
+
pos = pos + _structure_size(RADIAL_HEADER)
|
|
653
645
|
|
|
654
|
-
print('数据类型: %d-%s'%(dic_radial_header['data_type'],
|
|
646
|
+
print('数据类型: %d-%s'%(dic_radial_header['data_type'],PRODUCT_DATA_TYPE[dic_radial_header['data_type']]))
|
|
655
647
|
# Value=(Code-Offset)/Scale
|
|
656
648
|
# 读取径向数据RADIAL_DATA
|
|
657
649
|
data=[]
|
|
658
650
|
data_azi=[]
|
|
659
651
|
binnum = None
|
|
660
652
|
for nn in np.arange(dic_radial_header['radial_number']):
|
|
661
|
-
radial_data_info =
|
|
662
|
-
pos = pos +
|
|
653
|
+
radial_data_info = _unpack_from_buf(buf, pos, RADIAL_DATA)
|
|
654
|
+
pos = pos + _structure_size(RADIAL_DATA)
|
|
663
655
|
binnum = radial_data_info['num_bins']
|
|
664
656
|
rdata = buf[pos:pos+dic_radial_header['bin_length']*radial_data_info['num_bins']]
|
|
665
657
|
data.extend(rdata)
|
|
@@ -677,11 +669,11 @@ class READ_ROSE(object):
|
|
|
677
669
|
print(nx,ny)
|
|
678
670
|
# 将data转成numpy数组
|
|
679
671
|
data = data.reshape((nx,ny))
|
|
680
|
-
|
|
672
|
+
|
|
673
|
+
|
|
681
674
|
# decode data
|
|
682
675
|
# ppiarray = (ppiarray - dic_radial_header['offset']) / dic_radial_header['scale']
|
|
683
676
|
|
|
684
|
-
|
|
685
677
|
# 将方位角坐标转换成经纬度坐标
|
|
686
678
|
sweep_azimuths =np.array(data_azi)
|
|
687
679
|
ele = dic_prod_param['ele']
|
|
@@ -795,42 +787,42 @@ class READ_ROSE(object):
|
|
|
795
787
|
pos = 0
|
|
796
788
|
|
|
797
789
|
# 获取通用信息头
|
|
798
|
-
dic_gh =
|
|
790
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
799
791
|
# pprint(dic_gh)
|
|
800
792
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
801
793
|
print('源数据格式错误!')
|
|
802
794
|
return None
|
|
803
|
-
pos = pos +
|
|
795
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
804
796
|
|
|
805
797
|
# 获取站点信息
|
|
806
|
-
dic_scfg =
|
|
807
|
-
pos = pos +
|
|
798
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
799
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
808
800
|
|
|
809
801
|
# 获取任务信息
|
|
810
|
-
dic_tcfg =
|
|
811
|
-
pos = pos +
|
|
802
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
803
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
812
804
|
|
|
813
805
|
# 获取扫描信息
|
|
814
806
|
cutinfo = []
|
|
815
807
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
816
|
-
dic_cutcfg =
|
|
808
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
817
809
|
cutinfo.append(dic_cutcfg)
|
|
818
|
-
pos = pos +
|
|
810
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
819
811
|
|
|
820
812
|
# 获取产品头信息
|
|
821
|
-
dic_prod_header =
|
|
822
|
-
pos = pos +
|
|
813
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
814
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
823
815
|
|
|
824
816
|
# 获取产品参数信息
|
|
825
|
-
prod_type =
|
|
826
|
-
dic_prod_param =
|
|
817
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
818
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
827
819
|
print('产品类型: %d-%s'%(dic_prod_header['product_type'],prod_type))
|
|
828
820
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
829
821
|
|
|
830
822
|
# 读取产品径向头信息
|
|
831
|
-
dic_grid_header =
|
|
832
|
-
pos = pos +
|
|
833
|
-
print('数据类型: %d-%s'%(dic_grid_header['data_type'],
|
|
823
|
+
dic_grid_header = _unpack_from_buf(buf, pos, GRID_HEADER)
|
|
824
|
+
pos = pos + _structure_size(GRID_HEADER)
|
|
825
|
+
print('数据类型: %d-%s'%(dic_grid_header['data_type'],PRODUCT_DATA_TYPE[dic_grid_header['data_type']]))
|
|
834
826
|
# Value=(Code-Offset)/Scale
|
|
835
827
|
# 读取栅格数据GRID_DATA
|
|
836
828
|
|
|
@@ -907,41 +899,41 @@ class READ_ROSE(object):
|
|
|
907
899
|
pos = 0
|
|
908
900
|
|
|
909
901
|
# 获取通用信息头
|
|
910
|
-
dic_gh =
|
|
902
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
911
903
|
# pprint(dic_gh)
|
|
912
904
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
913
905
|
print('源数据格式错误!')
|
|
914
|
-
pos = pos +
|
|
906
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
915
907
|
|
|
916
908
|
# 获取站点信息
|
|
917
|
-
dic_scfg =
|
|
918
|
-
pos = pos +
|
|
909
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
910
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
919
911
|
|
|
920
912
|
# 获取任务信息
|
|
921
|
-
dic_tcfg =
|
|
922
|
-
pos = pos +
|
|
913
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
914
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
923
915
|
|
|
924
916
|
# 获取扫描信息
|
|
925
917
|
cutinfo = []
|
|
926
918
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
927
|
-
dic_cutcfg =
|
|
919
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
928
920
|
cutinfo.append(dic_cutcfg)
|
|
929
|
-
pos = pos +
|
|
921
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
930
922
|
|
|
931
923
|
# 获取产品头信息
|
|
932
|
-
dic_prod_header =
|
|
933
|
-
pos = pos +
|
|
924
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
925
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
934
926
|
|
|
935
927
|
# 获取产品参数信息
|
|
936
|
-
prod_type =
|
|
937
|
-
dic_prod_param =
|
|
928
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
929
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
938
930
|
print('产品类型: %d-%s'%(dic_prod_header['product_type'],prod_type))
|
|
939
931
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
940
932
|
|
|
941
933
|
# 读取产品径向头信息
|
|
942
|
-
dic_grid_header =
|
|
943
|
-
pos = pos +
|
|
944
|
-
print('数据类型: %d-%s'%(dic_grid_header['data_type'],
|
|
934
|
+
dic_grid_header = _unpack_from_buf(buf, pos, GRID_HEADER)
|
|
935
|
+
pos = pos + _structure_size(GRID_HEADER)
|
|
936
|
+
print('数据类型: %d-%s'%(dic_grid_header['data_type'],PRODUCT_DATA_TYPE[dic_grid_header['data_type']]))
|
|
945
937
|
# Value=(Code-Offset)/Scale
|
|
946
938
|
# 读取栅格数据GRID_DATA
|
|
947
939
|
|
|
@@ -1018,41 +1010,41 @@ class READ_ROSE(object):
|
|
|
1018
1010
|
pos = 0
|
|
1019
1011
|
|
|
1020
1012
|
# 获取通用信息头
|
|
1021
|
-
dic_gh =
|
|
1013
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
1022
1014
|
# pprint(dic_gh)
|
|
1023
1015
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
1024
1016
|
print('源数据格式错误!')
|
|
1025
|
-
pos = pos +
|
|
1017
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
1026
1018
|
|
|
1027
1019
|
# 获取站点信息
|
|
1028
|
-
dic_scfg =
|
|
1029
|
-
pos = pos +
|
|
1020
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
1021
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
1030
1022
|
|
|
1031
1023
|
# 获取任务信息
|
|
1032
|
-
dic_tcfg =
|
|
1033
|
-
pos = pos +
|
|
1024
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
1025
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
1034
1026
|
|
|
1035
1027
|
# 获取扫描信息
|
|
1036
1028
|
cutinfo = []
|
|
1037
1029
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
1038
|
-
dic_cutcfg =
|
|
1030
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
1039
1031
|
cutinfo.append(dic_cutcfg)
|
|
1040
|
-
pos = pos +
|
|
1032
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
1041
1033
|
|
|
1042
1034
|
# 获取产品头信息
|
|
1043
|
-
dic_prod_header =
|
|
1044
|
-
pos = pos +
|
|
1035
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
1036
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
1045
1037
|
|
|
1046
1038
|
# 获取产品参数信息
|
|
1047
|
-
prod_type =
|
|
1048
|
-
dic_prod_param =
|
|
1039
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
1040
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
1049
1041
|
print('产品类型: %d-%s'%(dic_prod_header['product_type'],prod_type))
|
|
1050
1042
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
1051
1043
|
|
|
1052
1044
|
# 读取产品径向头信息
|
|
1053
|
-
dic_grid_header =
|
|
1054
|
-
pos = pos +
|
|
1055
|
-
print('数据类型: %d-%s'%(dic_grid_header['data_type'],
|
|
1045
|
+
dic_grid_header = _unpack_from_buf(buf, pos, GRID_HEADER)
|
|
1046
|
+
pos = pos + _structure_size(GRID_HEADER)
|
|
1047
|
+
print('数据类型: %d-%s'%(dic_grid_header['data_type'],PRODUCT_DATA_TYPE[dic_grid_header['data_type']]))
|
|
1056
1048
|
# Value=(Code-Offset)/Scale
|
|
1057
1049
|
# 读取栅格数据GRID_DATA
|
|
1058
1050
|
|
|
@@ -1135,49 +1127,49 @@ class READ_ROSE(object):
|
|
|
1135
1127
|
pos = 0
|
|
1136
1128
|
|
|
1137
1129
|
# 获取通用信息头
|
|
1138
|
-
dic_gh =
|
|
1130
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
1139
1131
|
# pprint(dic_gh)
|
|
1140
1132
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
1141
1133
|
print('源数据格式错误!')
|
|
1142
|
-
pos = pos +
|
|
1134
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
1143
1135
|
|
|
1144
1136
|
# 获取站点信息
|
|
1145
|
-
dic_scfg =
|
|
1146
|
-
pos = pos +
|
|
1137
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
1138
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
1147
1139
|
|
|
1148
1140
|
# 获取任务信息
|
|
1149
|
-
dic_tcfg =
|
|
1150
|
-
pos = pos +
|
|
1141
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
1142
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
1151
1143
|
|
|
1152
1144
|
# 获取扫描信息
|
|
1153
1145
|
cutinfo = []
|
|
1154
1146
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
1155
|
-
dic_cutcfg =
|
|
1147
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
1156
1148
|
cutinfo.append(dic_cutcfg)
|
|
1157
|
-
pos = pos +
|
|
1149
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
1158
1150
|
|
|
1159
1151
|
# 获取产品头信息
|
|
1160
|
-
dic_prod_header =
|
|
1161
|
-
pos = pos +
|
|
1152
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
1153
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
1162
1154
|
|
|
1163
1155
|
# 获取产品参数信息
|
|
1164
|
-
prod_type =
|
|
1165
|
-
dic_prod_param =
|
|
1156
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
1157
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
1166
1158
|
print('产品类型: %d-%s'%(dic_prod_header['product_type'],prod_type))
|
|
1167
1159
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
1168
1160
|
|
|
1169
1161
|
# 读取产品径向头信息
|
|
1170
|
-
dic_radial_header =
|
|
1171
|
-
pos = pos +
|
|
1172
|
-
print('数据类型: %d-%s'%(dic_radial_header['data_type'],
|
|
1162
|
+
dic_radial_header = _unpack_from_buf(buf, pos, RADIAL_HEADER)
|
|
1163
|
+
pos = pos + _structure_size(RADIAL_HEADER)
|
|
1164
|
+
print('数据类型: %d-%s'%(dic_radial_header['data_type'],PRODUCT_DATA_TYPE[dic_radial_header['data_type']]))
|
|
1173
1165
|
# Value=(Code-Offset)/Scale
|
|
1174
1166
|
# 读取径向数据RADIAL_DATA
|
|
1175
1167
|
data=[]
|
|
1176
1168
|
data_azi=[]
|
|
1177
1169
|
binnum = None
|
|
1178
1170
|
for nn in np.arange(dic_radial_header['radial_number']):
|
|
1179
|
-
radial_data_info =
|
|
1180
|
-
pos = pos +
|
|
1171
|
+
radial_data_info = _unpack_from_buf(buf, pos, RADIAL_DATA)
|
|
1172
|
+
pos = pos + _structure_size(RADIAL_DATA)
|
|
1181
1173
|
binnum = radial_data_info['num_bins']
|
|
1182
1174
|
# rdata = buf[pos:pos+dic_radial_header['bin_length']*radial_data_info['num_bins']]
|
|
1183
1175
|
rdata = np.frombuffer(buf[pos:pos+dic_radial_header['bin_length']*radial_data_info['num_bins']], '<u2')
|
|
@@ -1290,50 +1282,50 @@ class READ_ROSE(object):
|
|
|
1290
1282
|
pos = 0
|
|
1291
1283
|
|
|
1292
1284
|
# 获取通用信息头
|
|
1293
|
-
dic_gh =
|
|
1285
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
1294
1286
|
# pprint(dic_gh)
|
|
1295
1287
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
1296
1288
|
print('源数据格式错误!')
|
|
1297
1289
|
return None
|
|
1298
|
-
pos = pos +
|
|
1290
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
1299
1291
|
|
|
1300
1292
|
# 获取站点信息
|
|
1301
|
-
dic_scfg =
|
|
1302
|
-
pos = pos +
|
|
1293
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
1294
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
1303
1295
|
|
|
1304
1296
|
# 获取任务信息
|
|
1305
|
-
dic_tcfg =
|
|
1306
|
-
pos = pos +
|
|
1297
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
1298
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
1307
1299
|
|
|
1308
1300
|
# 获取扫描信息
|
|
1309
1301
|
cutinfo = []
|
|
1310
1302
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
1311
|
-
dic_cutcfg =
|
|
1303
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
1312
1304
|
cutinfo.append(dic_cutcfg)
|
|
1313
|
-
pos = pos +
|
|
1305
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
1314
1306
|
|
|
1315
1307
|
# 获取产品头信息
|
|
1316
|
-
dic_prod_header =
|
|
1317
|
-
pos = pos +
|
|
1308
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
1309
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
1318
1310
|
|
|
1319
1311
|
# 获取产品参数信息
|
|
1320
|
-
prod_type =
|
|
1321
|
-
dic_prod_param =
|
|
1312
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
1313
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
1322
1314
|
print('产品类型: %d-%s'%(dic_prod_header['product_type'],prod_type))
|
|
1323
1315
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
1324
1316
|
|
|
1325
1317
|
# 读取产品径向头信息
|
|
1326
|
-
dic_radial_header =
|
|
1327
|
-
pos = pos +
|
|
1328
|
-
print('数据类型: %d-%s'%(dic_radial_header['data_type'],
|
|
1318
|
+
dic_radial_header = _unpack_from_buf(buf, pos, RADIAL_HEADER)
|
|
1319
|
+
pos = pos + _structure_size(RADIAL_HEADER)
|
|
1320
|
+
print('数据类型: %d-%s'%(dic_radial_header['data_type'],PRODUCT_DATA_TYPE[dic_radial_header['data_type']]))
|
|
1329
1321
|
# Value=(Code-Offset)/Scale
|
|
1330
1322
|
# 读取径向数据RADIAL_DATA
|
|
1331
1323
|
data=[]
|
|
1332
1324
|
data_azi=[]
|
|
1333
1325
|
binnum = None
|
|
1334
1326
|
for nn in np.arange(dic_radial_header['radial_number']):
|
|
1335
|
-
radial_data_info =
|
|
1336
|
-
pos = pos +
|
|
1327
|
+
radial_data_info = _unpack_from_buf(buf, pos, RADIAL_DATA)
|
|
1328
|
+
pos = pos + _structure_size(RADIAL_DATA)
|
|
1337
1329
|
binnum = radial_data_info['num_bins']
|
|
1338
1330
|
# rdata = buf[pos:pos+dic_radial_header['bin_length']*radial_data_info['num_bins']]
|
|
1339
1331
|
rdata = np.frombuffer(buf[pos:pos+dic_radial_header['bin_length']*radial_data_info['num_bins']], '<u2')
|
|
@@ -1450,51 +1442,51 @@ class READ_ROSE(object):
|
|
|
1450
1442
|
pos = 0
|
|
1451
1443
|
|
|
1452
1444
|
# 获取通用信息头
|
|
1453
|
-
dic_gh =
|
|
1445
|
+
dic_gh = _unpack_from_buf(buf, pos, GENERIC_HEADER)
|
|
1454
1446
|
# pprint(dic_gh)
|
|
1455
1447
|
if dic_gh['magic_number'] != 0x4D545352:
|
|
1456
1448
|
print('源数据格式错误!')
|
|
1457
|
-
pos = pos +
|
|
1449
|
+
pos = pos + _structure_size(GENERIC_HEADER)
|
|
1458
1450
|
|
|
1459
1451
|
# 获取站点信息
|
|
1460
|
-
dic_scfg =
|
|
1461
|
-
pos = pos +
|
|
1452
|
+
dic_scfg = _unpack_from_buf(buf, pos, SITE_CONFIG)
|
|
1453
|
+
pos = pos + _structure_size(SITE_CONFIG)
|
|
1462
1454
|
|
|
1463
1455
|
# 获取任务信息
|
|
1464
|
-
dic_tcfg =
|
|
1465
|
-
pos = pos +
|
|
1456
|
+
dic_tcfg = _unpack_from_buf(buf, pos, TASK_CONFIG)
|
|
1457
|
+
pos = pos + _structure_size(TASK_CONFIG)
|
|
1466
1458
|
|
|
1467
1459
|
# 获取扫描信息
|
|
1468
1460
|
cutinfo = []
|
|
1469
1461
|
for im in np.arange(dic_tcfg['cut_number']):
|
|
1470
|
-
dic_cutcfg =
|
|
1462
|
+
dic_cutcfg = _unpack_from_buf(buf, pos, SCAN_CONFIG)
|
|
1471
1463
|
cutinfo.append(dic_cutcfg)
|
|
1472
|
-
pos = pos +
|
|
1464
|
+
pos = pos + _structure_size(SCAN_CONFIG)
|
|
1473
1465
|
|
|
1474
1466
|
# 获取产品头信息
|
|
1475
|
-
dic_prod_header =
|
|
1476
|
-
pos = pos +
|
|
1467
|
+
dic_prod_header = _unpack_from_buf(buf, pos, PRODUCT_HEADER_BLOCK)
|
|
1468
|
+
pos = pos + _structure_size(PRODUCT_HEADER_BLOCK)
|
|
1477
1469
|
|
|
1478
1470
|
# 获取产品参数信息
|
|
1479
|
-
prod_type =
|
|
1471
|
+
prod_type = PRODUCT_ID_NAME_MAP[dic_prod_header['product_type']]
|
|
1480
1472
|
# pprint(prod_type)
|
|
1481
|
-
dic_prod_param =
|
|
1473
|
+
dic_prod_param = _unpack_from_buf(buf, pos, PRODUCT_DEPENDENT_PARAMETER[prod_type])
|
|
1482
1474
|
pos = pos + 64 # 产品参数长度固定为64个
|
|
1483
1475
|
|
|
1484
1476
|
# 获取产品数据块
|
|
1485
1477
|
# 冰雹个数
|
|
1486
|
-
hail_number =
|
|
1487
|
-
pos = pos +
|
|
1478
|
+
hail_number = _unpack_from_buf(buf, pos, HAIL_NUMBER)
|
|
1479
|
+
pos = pos + _structure_size(HAIL_NUMBER)
|
|
1488
1480
|
|
|
1489
1481
|
# TVS表块
|
|
1490
1482
|
hail_tab=[]
|
|
1491
1483
|
for nn in np.arange(hail_number['hail_number']):
|
|
1492
|
-
hail_tab.append(
|
|
1493
|
-
pos = pos +
|
|
1484
|
+
hail_tab.append(_unpack_from_buf(buf, pos, HAIL_TAB))
|
|
1485
|
+
pos = pos + _structure_size(HAIL_TAB)
|
|
1494
1486
|
|
|
1495
1487
|
# TVS适配数据
|
|
1496
|
-
dic_hail_adapt_param =
|
|
1497
|
-
pos = pos +
|
|
1488
|
+
dic_hail_adapt_param = _unpack_from_buf(buf, pos, HAIL_ADAPTATION_DATA)
|
|
1489
|
+
pos = pos + _structure_size(HAIL_ADAPTATION_DATA)
|
|
1498
1490
|
|
|
1499
1491
|
# 将所有的方位角和距离转换成经纬度
|
|
1500
1492
|
for nn in np.arange(hail_number['hail_number']):
|
|
@@ -1514,440 +1506,10 @@ class READ_ROSE(object):
|
|
|
1514
1506
|
self.hailinfo = allresult
|
|
1515
1507
|
return allresult
|
|
1516
1508
|
|
|
1517
|
-
# 将风暴追踪产品转换为gr2格式
|
|
1518
|
-
def trans_sti_gr2(self,outpath_gr2=None,outname_gr2=None,m_pret=None,time_type='UTC',bhistory=False,bdebug=False):
|
|
1519
|
-
|
|
1520
|
-
if self.stiinfo is None:
|
|
1521
|
-
print('mesoinfo is None, please run read_sti first!')
|
|
1522
|
-
return False
|
|
1523
|
-
|
|
1524
|
-
# try:
|
|
1525
|
-
# duration 代表该时次产品的可视时间段
|
|
1526
|
-
if not os.path.exists(outpath_gr2):
|
|
1527
|
-
os.makedirs(outpath_gr2)
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
if outpath_gr2 is None or outname_gr2 is None:
|
|
1531
|
-
print('outpath_gr2 and outname_gr2 params should be set')
|
|
1532
|
-
return False
|
|
1533
|
-
|
|
1534
|
-
if not os.path.exists(outpath_gr2):
|
|
1535
|
-
try:
|
|
1536
|
-
os.makedirs(outpath_gr2)
|
|
1537
|
-
except:
|
|
1538
|
-
print(outpath_gr2 + ' not exist, and fail to create this path!')
|
|
1539
|
-
return False
|
|
1540
|
-
|
|
1541
|
-
of = open(outpath_gr2 + os.sep + outname_gr2,'wt',encoding='GBK')
|
|
1542
|
-
|
|
1543
|
-
# 单个文件就不用信息头了
|
|
1544
|
-
if bdebug and not bhistory:
|
|
1545
|
-
of.write('Title: ROSE2风暴追踪信息\n')
|
|
1546
|
-
of.write('Refreshseconds: 30\n')
|
|
1547
|
-
of.write('Threshold: 500\n')
|
|
1548
|
-
of.write('Font: 1, 20, 1, "Courier New"\n')
|
|
1549
|
-
# of.write('IconFile: 1, 18, 18, 9, 9, 2016_144dpi.png\n')
|
|
1550
|
-
of.write('IconFile: 1, 24, 24, 12, 12, 2016_192dpi.png\n')
|
|
1551
|
-
|
|
1552
|
-
# 这里直接用m_pret 可以保证不会出现重叠的记录
|
|
1553
|
-
if not bdebug:
|
|
1554
|
-
if not m_pret is None and bhistory:
|
|
1555
|
-
pre_time = m_pret + timedelta(minutes=-1*int(6/2))
|
|
1556
|
-
endtime = m_pret + timedelta(minutes=1*int(6/2))
|
|
1557
|
-
elif not bhistory:
|
|
1558
|
-
pre_time = m_pret + timedelta(minutes=-1*int(6/2))
|
|
1559
|
-
endtime = m_pret + timedelta(minutes=30)
|
|
1560
|
-
pass
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
timerangestr = 'TimeRange: ' + pre_time.strftime('%Y-%m-%dT%H:%M:%S') + ' ' + endtime.strftime('%Y-%m-%dT%H:%M:%S')
|
|
1564
|
-
|
|
1565
|
-
# 实时模式下,改时间一定要放到timerange后面
|
|
1566
|
-
if time_type == "BJT":
|
|
1567
|
-
pre_time = pre_time + timedelta(hours=8)
|
|
1568
|
-
endtime = endtime + timedelta(hours=8)
|
|
1569
|
-
|
|
1570
|
-
if bhistory:
|
|
1571
|
-
timerangestr = 'TimeRange: ' + pre_time.strftime('%Y-%m-%dT%H:%M:%S') + ' ' + endtime.strftime('%Y-%m-%dT%H:%M:%S')
|
|
1572
|
-
|
|
1573
|
-
of.write(timerangestr + '\n')
|
|
1574
|
-
|
|
1575
|
-
for dd in self.stiinfo['track']:
|
|
1576
|
-
if len(dd) > 1:
|
|
1577
|
-
of.write('Line: 2,0\n')
|
|
1578
|
-
for nn in dd:
|
|
1579
|
-
of.write('%.4f,%.4f\n'%(nn[0],nn[1]))
|
|
1580
|
-
of.write('End:\n\n')
|
|
1581
|
-
|
|
1582
|
-
for dd in self.stiinfo['marker_past']:
|
|
1583
|
-
of.write('Icon: %.4f,%.4f,0,1,88\n'%(dd[0],dd[1]))
|
|
1584
|
-
for dd in self.stiinfo['marker_fst']:
|
|
1585
|
-
of.write('Icon: %.4f,%.4f,0,1,91\n'%(dd[0],dd[1]))
|
|
1586
|
-
|
|
1587
|
-
for nn in np.arange(len(self.stiinfo['all_storm_prop'])):
|
|
1588
|
-
|
|
1589
|
-
curstorm = self.stiinfo['all_storm_prop'][nn]
|
|
1590
|
-
clon = curstorm['lon']
|
|
1591
|
-
clat = curstorm['lat']
|
|
1592
|
-
|
|
1593
|
-
lbstr=r'数据来源: ROSE风暴识别产品\n'
|
|
1594
|
-
lbstr += r'风暴编号: %s\n'%curstorm['id_char']
|
|
1595
|
-
lbstr += r'方位角/距离: %.1f度/%.1f公里\n'%(curstorm['azi'],curstorm['range']/1000.0)
|
|
1596
|
-
lbstr += r'风暴移动方向 : %s\n'%(self.get_wind_dir_name((curstorm['mv_dir']+180)%360))
|
|
1597
|
-
lbstr += r'风暴移动速度 : %.1f 公里/小时\n'%(curstorm['mv_spd']*3.6)
|
|
1598
|
-
|
|
1599
|
-
lbstr += r'风暴低高: %.1f 公里\n'%(curstorm['base_height']/1000)
|
|
1600
|
-
lbstr += r'风暴顶高: %.1f 公里\n'%(curstorm['top_height']/1000)
|
|
1601
|
-
lbstr += r'风暴体VIL: %.1f 千克/平方米\n'%(curstorm['vil'])
|
|
1602
|
-
lbstr += r'最大反射率: %d dBZ\n'%(curstorm['max_ref'])
|
|
1603
|
-
lbstr += r'最大反射率高度 : %.1f 公里\n'%(curstorm['max_ref_height']/1000)
|
|
1604
|
-
|
|
1605
|
-
of.write('Icon: %.4f,%.4f,0,1,40,"%s"\n'%(clat,clon,lbstr))
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
of.write('End:\n\n')
|
|
1609
|
-
|
|
1610
|
-
of.close()
|
|
1611
|
-
print(outpath_gr2 + os.sep + outname_gr2 + ' saved!')
|
|
1612
|
-
return outpath_gr2 + os.sep + outname_gr2
|
|
1613
|
-
# except:
|
|
1614
|
-
# return False
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
# 将中气旋的信息转换为gr2格式
|
|
1618
|
-
def trans_mda_gr2(self,outpath_gr2=None,outname_gr2=None,m_pret=None,time_type='UTC',bhistory=False,bdebug=False):
|
|
1619
|
-
if self.mesoinfo is None:
|
|
1620
|
-
print('mesoinfo is None, please run read_mda first!')
|
|
1621
|
-
return False
|
|
1622
|
-
try:
|
|
1623
|
-
# duration 代表该时次产品的可视时间段
|
|
1624
|
-
if not os.path.exists(outpath_gr2):
|
|
1625
|
-
os.makedirs(outpath_gr2)
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
if outpath_gr2 is None or outname_gr2 is None:
|
|
1629
|
-
print('outpath_gr2 and outname_gr2 params should be set')
|
|
1630
|
-
return False
|
|
1631
|
-
|
|
1632
|
-
if not os.path.exists(outpath_gr2):
|
|
1633
|
-
try:
|
|
1634
|
-
os.makedirs(outpath_gr2)
|
|
1635
|
-
except:
|
|
1636
|
-
print(outpath_gr2 + ' not exist, and fail to create this path!')
|
|
1637
|
-
return False
|
|
1638
|
-
|
|
1639
|
-
of = open(outpath_gr2 + os.sep + outname_gr2,'wt',encoding='GBK')
|
|
1640
|
-
|
|
1641
|
-
# 单个文件就不用信息头了
|
|
1642
|
-
if bdebug and not bhistory:
|
|
1643
|
-
of.write('Title: ROSE2中气旋识别产品\n')
|
|
1644
|
-
of.write('Refreshseconds: 30\n')
|
|
1645
|
-
of.write('Threshold: 500\n')
|
|
1646
|
-
of.write('Font: 1, 20, 1, "Courier New"\n')
|
|
1647
|
-
# of.write('IconFile: 1, 47, 47, 23, 23, mda_icons_144.png\n')
|
|
1648
|
-
of.write('IconFile: 1, 63, 63, 31, 31, mda_icons_192.png\n')
|
|
1649
|
-
|
|
1650
|
-
# 这里直接用m_pret 可以保证不会出现重叠的记录
|
|
1651
|
-
if not bdebug:
|
|
1652
|
-
if not m_pret is None and bhistory:
|
|
1653
|
-
pre_time = m_pret + timedelta(minutes=-1*int(6/2))
|
|
1654
|
-
endtime = m_pret + timedelta(minutes=1*int(6/2))
|
|
1655
|
-
elif not bhistory:
|
|
1656
|
-
pre_time = m_pret + timedelta(minutes=-1*int(6/2))
|
|
1657
|
-
endtime = m_pret + timedelta(minutes=30)
|
|
1658
|
-
pass
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
timerangestr = 'TimeRange: ' + pre_time.strftime('%Y-%m-%dT%H:%M:%S') + ' ' + endtime.strftime('%Y-%m-%dT%H:%M:%S')
|
|
1662
|
-
|
|
1663
|
-
# 实时模式下,改时间一定要放到timerange后面
|
|
1664
|
-
if time_type == "BJT":
|
|
1665
|
-
pre_time = pre_time + timedelta(hours=8)
|
|
1666
|
-
endtime = endtime + timedelta(hours=8)
|
|
1667
|
-
|
|
1668
|
-
if bhistory:
|
|
1669
|
-
timerangestr = 'TimeRange: ' + pre_time.strftime('%Y-%m-%dT%H:%M:%S') + ' ' + endtime.strftime('%Y-%m-%dT%H:%M:%S')
|
|
1670
|
-
|
|
1671
|
-
of.write(timerangestr + '\n')
|
|
1672
|
-
|
|
1673
|
-
for nn in range(len(self.mesoinfo['meso'])):
|
|
1674
|
-
curitem = self.mesoinfo['meso'][nn]
|
|
1675
|
-
clon = curitem['lon']
|
|
1676
|
-
clat = curitem['lat']
|
|
1677
|
-
lbstr=''
|
|
1678
|
-
icon_index=0
|
|
1679
|
-
baseindex=0
|
|
1680
|
-
if curitem['base'] > 1500: # 米
|
|
1681
|
-
baseindex = 0
|
|
1682
|
-
else:
|
|
1683
|
-
baseindex = 1*4
|
|
1684
|
-
'''
|
|
1685
|
-
关于风切变的单位换算问题
|
|
1686
|
-
https://www.theweatherprediction.com/habyhints/193/
|
|
1687
|
-
The wind speed is 20 knots at 850 mb while the wind speed is 30 knots at 700 mb. The distance between 850 and 700 mb is 1,600 meters. What is the value of wind shear?
|
|
1688
|
-
|
|
1689
|
-
The change in wind speed is 30 - 20 = 10 knots = 5 m/s
|
|
1690
|
-
The change is distance is 1,600 m
|
|
1691
|
-
|
|
1692
|
-
The change in wind speed over distance = 5/1,600 s^-1 = 0.003125 s^-1
|
|
1693
|
-
|
|
1694
|
-
'''
|
|
1695
|
-
shear_ms = curitem['ave_shear'] * (curitem['azi_diam'] + curitem['radial_diam'])/2/1000.0/2
|
|
1696
|
-
mrank = self.get_mda_rank(curitem['range']/1000,shear_ms)
|
|
1697
|
-
|
|
1698
|
-
if mrank is None:
|
|
1699
|
-
continue
|
|
1700
|
-
else:
|
|
1701
|
-
icon_index = baseindex + mrank
|
|
1702
|
-
|
|
1703
|
-
mlevel =''
|
|
1704
|
-
if mrank==1:
|
|
1705
|
-
mlevel = '弱切变'
|
|
1706
|
-
elif mrank == 2:
|
|
1707
|
-
mlevel = '弱中气旋'
|
|
1708
|
-
elif mrank == 3:
|
|
1709
|
-
mlevel = '中等强度中气旋'
|
|
1710
|
-
elif mrank == 4:
|
|
1711
|
-
mlevel = '强中气旋'
|
|
1712
|
-
|
|
1713
|
-
mtype='未知'
|
|
1714
|
-
if curitem['feature_type'] == 1:
|
|
1715
|
-
mtype = '中气旋'
|
|
1716
|
-
elif curitem['feature_type'] == 2:
|
|
1717
|
-
mtype = '3D相关切变'
|
|
1718
|
-
elif curitem['feature_type'] == 3:
|
|
1719
|
-
mtype = '非相关切变'
|
|
1720
|
-
|
|
1721
|
-
lbstr=''
|
|
1722
|
-
lbstr += r'数据来源: ROSE2中气旋识别产品\n'
|
|
1723
|
-
lbstr += r'所属风暴编号: %s\n'%curitem['storm_id_char']
|
|
1724
|
-
lbstr += r'中气旋编号: %s\n'%curitem['feature_id_char']
|
|
1725
|
-
lbstr += r'类型: %s\n'%mtype
|
|
1726
|
-
lbstr += r'中气旋所在方位/距离: %.1f度 / %.1f 公里\n'%(curitem['azi'],curitem['range']/1000.0)
|
|
1727
|
-
lbstr += r'强度等级: %s\n'%mlevel
|
|
1728
|
-
lbstr += r'中气旋底高: %.1f 公里\n'%(curitem['base']/1000.0)
|
|
1729
|
-
lbstr += r'中气旋顶高: %.1f 公里\n'%(curitem['top']/1000.0)
|
|
1730
|
-
lbstr += r'中气旋沿径向直径: %.1f 公里\n'%(curitem['radial_diam']/1000.0)
|
|
1731
|
-
lbstr += r'中气旋沿方位直径: %.1f 公里\n'%(curitem['azi_diam']/1000.0)
|
|
1732
|
-
lbstr += r'平均切变值: %.1f (E-3/S)\n'%(curitem['ave_shear'])
|
|
1733
|
-
|
|
1734
|
-
if shear_ms > 25:
|
|
1735
|
-
lbstr += r'===============提醒============\n换算后的切变值超过了25米/秒\n可能是很强的中气旋或者是错误数据\n可能是存在速度模糊对PUP算法的影响。\n'
|
|
1736
|
-
|
|
1737
|
-
of.write('Icon: %.4f,%.4f,0,1,%d,"%s"\n'%(clat,clon,icon_index, lbstr))
|
|
1738
|
-
pass
|
|
1739
|
-
of.write('End:\n\n')
|
|
1740
|
-
|
|
1741
|
-
of.close()
|
|
1742
|
-
print(outpath_gr2 + os.sep + outname_gr2 + ' saved!')
|
|
1743
|
-
return outpath_gr2 + os.sep + outname_gr2
|
|
1744
|
-
except:
|
|
1745
|
-
return False
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
# 将tvs的信息转换为gr2格式
|
|
1749
|
-
def trans_tvs_gr2(self,outpath_gr2=None,outname_gr2=None,m_pret=None,time_type='UTC',bhistory=False,bdebug=False):
|
|
1750
|
-
|
|
1751
|
-
if self.tvsinfo is None:
|
|
1752
|
-
print('tvsinfo is None, please run read_tvs first')
|
|
1753
|
-
return False
|
|
1754
|
-
|
|
1755
|
-
try:
|
|
1756
|
-
# duration 代表该时次产品的可视时间段
|
|
1757
|
-
if not os.path.exists(outpath_gr2):
|
|
1758
|
-
os.makedirs(outpath_gr2)
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
if outpath_gr2 is None or outname_gr2 is None:
|
|
1762
|
-
print('outpath_gr2 and outname_gr2 params should be set')
|
|
1763
|
-
return False
|
|
1764
|
-
|
|
1765
|
-
if not os.path.exists(outpath_gr2):
|
|
1766
|
-
try:
|
|
1767
|
-
os.makedirs(outpath_gr2)
|
|
1768
|
-
except:
|
|
1769
|
-
print(outpath_gr2 + ' not exist, and fail to create this path!')
|
|
1770
|
-
return False
|
|
1771
|
-
|
|
1772
|
-
of = open(outpath_gr2 + os.sep + outname_gr2,'wt',encoding='GBK')
|
|
1773
|
-
|
|
1774
|
-
# 单个文件就不用信息头了
|
|
1775
|
-
if bdebug and not bhistory:
|
|
1776
|
-
of.write('Title: ROSE2龙卷涡旋特征识别产品\n')
|
|
1777
|
-
of.write('Refreshseconds: 30\n')
|
|
1778
|
-
of.write('Threshold: 500\n')
|
|
1779
|
-
of.write('Font: 1, 20, 1, "Courier New"\n')
|
|
1780
|
-
of.write('IconFile: 1, 51, 51, 26, 26, lsr_icons_192.png\n')
|
|
1781
|
-
|
|
1782
|
-
# 这里直接用m_pret 可以保证不会出现重叠的记录
|
|
1783
|
-
if not bdebug:
|
|
1784
|
-
if not m_pret is None and bhistory:
|
|
1785
|
-
pre_time = m_pret + timedelta(minutes=-1*int(6/2))
|
|
1786
|
-
endtime = m_pret + timedelta(minutes=1*int(6/2))
|
|
1787
|
-
elif not bhistory:
|
|
1788
|
-
pre_time = m_pret + timedelta(minutes=-1*int(6/2))
|
|
1789
|
-
endtime = m_pret + timedelta(minutes=30)
|
|
1790
|
-
pass
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
timerangestr = 'TimeRange: ' + pre_time.strftime('%Y-%m-%dT%H:%M:%S') + ' ' + endtime.strftime('%Y-%m-%dT%H:%M:%S')
|
|
1794
|
-
|
|
1795
|
-
# 实时模式下,改时间一定要放到timerange后面
|
|
1796
|
-
if time_type == "BJT":
|
|
1797
|
-
pre_time = pre_time + timedelta(hours=8)
|
|
1798
|
-
endtime = endtime + timedelta(hours=8)
|
|
1799
|
-
|
|
1800
|
-
if bhistory:
|
|
1801
|
-
timerangestr = 'TimeRange: ' + pre_time.strftime('%Y-%m-%dT%H:%M:%S') + ' ' + endtime.strftime('%Y-%m-%dT%H:%M:%S')
|
|
1802
|
-
|
|
1803
|
-
of.write(timerangestr + '\n')
|
|
1804
|
-
|
|
1805
|
-
for nn in range(len(self.tvsinfo['tvs'])):
|
|
1806
|
-
curitem = self.tvsinfo['tvs'][nn]
|
|
1807
|
-
clon = curitem['lon']
|
|
1808
|
-
clat = curitem['lat']
|
|
1809
|
-
curtype = '未知'
|
|
1810
|
-
if curitem['type'] == 1:
|
|
1811
|
-
curtype = 'TVS'
|
|
1812
|
-
elif curitem['type'] == 2:
|
|
1813
|
-
curtype = 'ETVS'
|
|
1814
|
-
icon_index=1
|
|
1815
|
-
|
|
1816
|
-
lbstr=''
|
|
1817
|
-
lbstr += r'数据来源: ROSE2龙卷涡旋识别产品\n'
|
|
1818
|
-
lbstr += r'所属风暴编号: %s\n'%curitem['storm_id_char']
|
|
1819
|
-
lbstr += r'类型: %s\n'%curtype
|
|
1820
|
-
lbstr += r'TVS所在方位/距离: %.1f度 / %.1f 公里\n'%(curitem['azi'],curitem['range']/1000.0)
|
|
1821
|
-
|
|
1822
|
-
lbstr += r'TVS底高: %.1f 公里\n'%(curitem['base']/1000.0)
|
|
1823
|
-
lbstr += r'TVS顶高: %.1f 公里\n'%(curitem['top']/1000.0)
|
|
1824
|
-
lbstr += r'TVS厚度: %.1f 公里\n'%(curitem['depth']/1000.0)
|
|
1825
|
-
lbstr += r'低层速度差LLDV: %.1f 米/秒\n'%(curitem['lldv']) # *1.609344/3.6
|
|
1826
|
-
lbstr += r'最大速度差MXDV: %.1f 米/秒\n'%(curitem['mxdv']) # *1.609344/3.6
|
|
1827
|
-
lbstr += r'最大速度差所在高度: %.1f 公里\n'%(curitem['hmdv']/1000.0)
|
|
1828
|
-
|
|
1829
|
-
lbstr += r'最大切变值MASHR: %.1f (E-3/S)\n'%(curitem['max_shear'])
|
|
1830
|
-
lbstr += r'最大切变值所在高度: %.1f 公里\n'%(curitem['h_max_shear']/1000.0)
|
|
1831
|
-
|
|
1832
|
-
if curtype=='ETVS':
|
|
1833
|
-
icon_index=20
|
|
1834
|
-
of.write('Icon: %.4f,%.4f,0,1,%d,"%s"\n'%(clat,clon,icon_index, lbstr))
|
|
1835
|
-
else:
|
|
1836
|
-
icon_index=11
|
|
1837
|
-
of.write('Icon: %.4f,%.4f,0,1,%d,"%s"\n'%(clat,clon,icon_index, lbstr))
|
|
1838
|
-
|
|
1839
|
-
of.write('End:\n\n')
|
|
1840
|
-
|
|
1841
|
-
of.close()
|
|
1842
|
-
print(outpath_gr2 + os.sep + outname_gr2 + ' saved!')
|
|
1843
|
-
return outpath_gr2 + os.sep + outname_gr2
|
|
1844
|
-
except:
|
|
1845
|
-
return False
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
# 将hail的信息转换为gr2格式
|
|
1849
|
-
def trans_hda_gr2(self,outpath_gr2=None,outname_gr2=None,m_pret=None,time_type='UTC',bhistory=False,bdebug=False):
|
|
1850
|
-
|
|
1851
|
-
if self.hailinfo is None:
|
|
1852
|
-
print('hailinfo is None, please run read_hda first!')
|
|
1853
|
-
return False
|
|
1854
|
-
|
|
1855
|
-
try:
|
|
1856
|
-
# duration 代表该时次产品的可视时间段
|
|
1857
|
-
if not os.path.exists(outpath_gr2):
|
|
1858
|
-
os.makedirs(outpath_gr2)
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
if outpath_gr2 is None or outname_gr2 is None:
|
|
1862
|
-
print('outpath_gr2 and outname_gr2 params should be set')
|
|
1863
|
-
return False
|
|
1864
|
-
|
|
1865
|
-
if not os.path.exists(outpath_gr2):
|
|
1866
|
-
try:
|
|
1867
|
-
os.makedirs(outpath_gr2)
|
|
1868
|
-
except:
|
|
1869
|
-
print(outpath_gr2 + ' not exist, and fail to create this path!')
|
|
1870
|
-
return False
|
|
1871
|
-
|
|
1872
|
-
of = open(outpath_gr2 + os.sep + outname_gr2,'wt',encoding='GBK')
|
|
1873
|
-
|
|
1874
|
-
# 单个文件就不用信息头了
|
|
1875
|
-
if bdebug and not bhistory:
|
|
1876
|
-
of.write('Title: ROSE2冰雹指数产品\n')
|
|
1877
|
-
of.write('Refreshseconds: 30\n')
|
|
1878
|
-
of.write('Threshold: 500\n')
|
|
1879
|
-
of.write('Font: 1, 20, 1, "Courier New"\n')
|
|
1880
|
-
# of.write('IconFile: 1, 37, 37, 18, 18, hail_icons_144.png\n')
|
|
1881
|
-
of.write('IconFile: 1, 51, 51, 26, 26, hail_icons_192.png\n')
|
|
1882
|
-
|
|
1883
|
-
# 这里直接用m_pret 可以保证不会出现重叠的记录
|
|
1884
|
-
if not bdebug:
|
|
1885
|
-
if not m_pret is None and bhistory:
|
|
1886
|
-
pre_time = m_pret + timedelta(minutes=-1*int(6/2))
|
|
1887
|
-
endtime = m_pret + timedelta(minutes=1*int(6/2))
|
|
1888
|
-
elif not bhistory:
|
|
1889
|
-
pre_time = m_pret + timedelta(minutes=-1*int(6/2))
|
|
1890
|
-
endtime = m_pret + timedelta(minutes=30)
|
|
1891
|
-
pass
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
timerangestr = 'TimeRange: ' + pre_time.strftime('%Y-%m-%dT%H:%M:%S') + ' ' + endtime.strftime('%Y-%m-%dT%H:%M:%S')
|
|
1895
|
-
|
|
1896
|
-
# 实时模式下,改时间一定要放到timerange后面
|
|
1897
|
-
if time_type == "BJT":
|
|
1898
|
-
pre_time = pre_time + timedelta(hours=8)
|
|
1899
|
-
endtime = endtime + timedelta(hours=8)
|
|
1900
|
-
|
|
1901
|
-
if bhistory:
|
|
1902
|
-
timerangestr = 'TimeRange: ' + pre_time.strftime('%Y-%m-%dT%H:%M:%S') + ' ' + endtime.strftime('%Y-%m-%dT%H:%M:%S')
|
|
1903
|
-
|
|
1904
|
-
of.write(timerangestr + '\n')
|
|
1905
|
-
|
|
1906
|
-
for nn in range(len(self.hailinfo['hail'])):
|
|
1907
|
-
curitem = self.hailinfo['hail'][nn]
|
|
1908
|
-
clon = curitem['lon']
|
|
1909
|
-
clat = curitem['lat']
|
|
1910
|
-
|
|
1911
|
-
lbstr=''
|
|
1912
|
-
lbstr=r'数据来源: ROSE2冰雹指数产品\n'
|
|
1913
|
-
lbstr += r'冰雹编号: %s\n'%curitem['hail_id_char']
|
|
1914
|
-
lbstr += r'大冰雹概率: %d%%\n'%curitem['psh']
|
|
1915
|
-
lbstr += r'冰雹概率: %d%%\n'%curitem['ph']
|
|
1916
|
-
lbstr += r'最大冰雹尺寸估计: %.1f 厘米 或 %.1f 英寸\n'%(curitem['hsize'],curitem['hsize']/2.54,)
|
|
1917
|
-
|
|
1918
|
-
icon_index=0
|
|
1919
|
-
hsize_inch = curitem['hsize']/2.54
|
|
1920
|
-
|
|
1921
|
-
if hsize_inch < 1:
|
|
1922
|
-
icon_index = 1
|
|
1923
|
-
elif hsize_inch < 2:
|
|
1924
|
-
icon_index = 5
|
|
1925
|
-
elif hsize_inch < 3:
|
|
1926
|
-
icon_index = 9
|
|
1927
|
-
elif hsize_inch < 4:
|
|
1928
|
-
icon_index = 13
|
|
1929
|
-
elif hsize_inch >= 4:
|
|
1930
|
-
icon_index = 17
|
|
1931
|
-
else:
|
|
1932
|
-
icon_index = 1
|
|
1933
|
-
if curitem['ph'] >= 30:
|
|
1934
|
-
of.write('Icon: %.4f,%.4f,0,1,%d,"%s"\n'%(clat,clon,icon_index, lbstr))
|
|
1935
|
-
|
|
1936
|
-
of.write('End:\n\n')
|
|
1937
|
-
|
|
1938
|
-
of.close()
|
|
1939
|
-
print(outpath_gr2 + os.sep + outname_gr2 + ' saved!')
|
|
1940
|
-
return outpath_gr2 + os.sep + outname_gr2
|
|
1941
|
-
except:
|
|
1942
|
-
return False
|
|
1943
1509
|
|
|
1944
1510
|
if __name__ == "__main__":
|
|
1945
|
-
rootpath = '
|
|
1511
|
+
rootpath = 'testdata/rose_product'
|
|
1946
1512
|
staid = 'Z9852'
|
|
1947
|
-
# filepath = 'D:\Downloads\CMADAAS\pup\Z9852\STI'
|
|
1948
|
-
outpath_gr2 = 'output/gr2data/sti' + os.sep + staid
|
|
1949
|
-
if not os.path.exists(outpath_gr2):
|
|
1950
|
-
os.makedirs(outpath_gr2)
|
|
1951
1513
|
|
|
1952
1514
|
decoder = READ_ROSE()
|
|
1953
1515
|
|
|
@@ -1961,33 +1523,28 @@ if __name__ == "__main__":
|
|
|
1961
1523
|
|
|
1962
1524
|
|
|
1963
1525
|
# sti
|
|
1964
|
-
filepath_sti = rootpath + os.sep + staid + os.sep + 'STI'
|
|
1965
|
-
filename_sti = 'Z_RADR_I_Z9852_20230421164954_P_DOR_CDD_STI_NUL_300_NUL_FMT.bin'
|
|
1966
|
-
allresult_sti = decoder.read_sti(filepath_sti, filename_sti)
|
|
1967
|
-
outname_sti = 'pls_sti.txt'
|
|
1968
|
-
decoder.trans_sti_gr2(outpath_gr2,outname_sti,time_type='BJT',bdebug = True)
|
|
1526
|
+
# filepath_sti = rootpath + os.sep + staid + os.sep + 'STI'
|
|
1527
|
+
# filename_sti = 'Z_RADR_I_Z9852_20230421164954_P_DOR_CDD_STI_NUL_300_NUL_FMT.bin'
|
|
1528
|
+
# allresult_sti = decoder.read_sti(filepath_sti, filename_sti)
|
|
1969
1529
|
|
|
1970
1530
|
|
|
1971
|
-
# meso
|
|
1972
|
-
filepath_meso = rootpath + os.sep + staid + os.sep + 'M'
|
|
1973
|
-
filename_meso = 'Z_RADR_I_Z9852_20230421135042_P_DOR_CDD_M_NUL_200_NUL_FMT.bin'
|
|
1974
|
-
allresult_meso = decoder.read_mda(filepath_meso, filename_meso)
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
#
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
#
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
allresult_hail = decoder.read_hda(filepath_hail, filename_hail)
|
|
1990
|
-
outname_hail = 'pls_hail.txt'
|
|
1991
|
-
decoder.trans_hda_gr2(outpath_gr2,outname_hail,time_type='BJT',bdebug = True)
|
|
1531
|
+
# # meso
|
|
1532
|
+
# filepath_meso = rootpath + os.sep + staid + os.sep + 'M'
|
|
1533
|
+
# filename_meso = 'Z_RADR_I_Z9852_20230421135042_P_DOR_CDD_M_NUL_200_NUL_FMT.bin'
|
|
1534
|
+
# allresult_meso = decoder.read_mda(filepath_meso, filename_meso)
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
# # tvs
|
|
1538
|
+
# filepath_tvs = rootpath + os.sep + staid + os.sep + 'TVS'
|
|
1539
|
+
# filename_tvs = 'Z_RADR_I_Z9852_20230421201451_P_DOR_CDD_TVS_NUL_200_NUL_FMT.bin'
|
|
1540
|
+
# allresult_tvs = decoder.read_tvs(filepath_tvs, filename_tvs)
|
|
1541
|
+
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
# # hail
|
|
1545
|
+
# filepath_hail = rootpath + os.sep + staid + os.sep + 'HI'
|
|
1546
|
+
# filename_hail = 'Z_RADR_I_Z9852_20230421181642_P_DOR_CDD_HI_NUL_200_NUL_FMT.bin'
|
|
1547
|
+
# allresult_hail = decoder.read_hda(filepath_hail, filename_hail)
|
|
1548
|
+
|
|
1992
1549
|
|
|
1993
1550
|
# %%
|