metradar 0.1.5__py3-none-any.whl → 0.1.8__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.
Files changed (75) hide show
  1. metradar/__init__.py +4 -2
  2. metradar/config.py +53 -0
  3. metradar/core/__init__.py +9 -0
  4. metradar/{get_cross_section_from_pyart.py → core/get_cross_section.py} +5 -157
  5. metradar/{mosaic_merge.py → core/mosaic_merge.py} +3 -1
  6. metradar/{oa_dig_func.py → core/oa_dig_func.py} +83 -333
  7. metradar/graph/__init__.py +9 -0
  8. metradar/{mosaic_quickdraw.py → graph/draw_comp_mosaic.py} +71 -68
  9. metradar/{draw_mosaic_new.py → graph/draw_latlon_func.py} +177 -173
  10. metradar/graph/draw_radar_aws.py +212 -0
  11. metradar/{draw_radar_comp_func.py → graph/draw_radar_comp_func.py} +319 -248
  12. metradar/graph/parse_pal.py +157 -0
  13. metradar/io/__init__.py +9 -0
  14. metradar/{cnrad_level2.py → io/cnrad_level2.py} +45 -2
  15. metradar/{decode_fmt_pyart.py → io/decode_fmt_pyart.py} +19 -3
  16. metradar/{decode_pup_rose.py → io/decode_pup_rose.py} +241 -684
  17. metradar/{read_new_mosaic_func.py → io/read_new_mosaic_func.py} +30 -2
  18. metradar/io/read_swan.py +250 -0
  19. metradar/{rose_structer.py → io/rose_structer.py} +2 -0
  20. metradar/project/__init__.py +9 -0
  21. metradar/project/make_mosaic/__init__.py +9 -0
  22. metradar/project/make_mosaic/batch_draw_mosaic.py +32 -0
  23. metradar/{make_mosaic_mp_archive.py → project/make_mosaic/make_mosaic_func.py} +144 -175
  24. metradar/project/make_mosaic/make_mosaic_mp.ini +29 -0
  25. metradar/project/make_mosaic/make_mosaic_mp.py +70 -0
  26. metradar/project/make_vpr_aws/__init__.py +9 -0
  27. metradar/project/make_vpr_aws/construct_aws_refvpr_mainprog.ini +39 -0
  28. metradar/project/make_vpr_aws/construct_aws_refvpr_mainprog.py +565 -0
  29. metradar/project/nowcasting/__init__.py +9 -0
  30. metradar/project/nowcasting/nowcast_by_pysteps.py +214 -0
  31. metradar/{trans_nc_pgmb.py → project/nowcasting/trans_mosaic_pgmb.py} +19 -17
  32. metradar/project/qpe/Archive /346/250/241/345/274/217/350/257/264/346/230/216.txt" +2 -0
  33. metradar/project/qpe/__init__.py +9 -0
  34. metradar/project/qpe/archive_main_qpe_cfg.ini +91 -0
  35. metradar/project/qpe/do_s1.sh +6 -0
  36. metradar/project/qpe/do_s2.sh +6 -0
  37. metradar/project/qpe/do_s3.sh +6 -0
  38. metradar/project/qpe/do_s4.sh +6 -0
  39. metradar/project/qpe/do_s5.sh +6 -0
  40. metradar/project/qpe/exec_all.sh +11 -0
  41. metradar/project/qpe/get_rainrate_func.py +80 -0
  42. metradar/project/qpe/main_qpe_cfg.ini +85 -0
  43. metradar/project/qpe/s1_download_radar_region_cmadaas.py +123 -0
  44. metradar/project/qpe/s2_pre_process_single_radar.py +183 -0
  45. metradar/project/qpe/s3_trans_rainrate_to_qpe.py +499 -0
  46. metradar/project/qpe/s4_mosaic_qpe.py +523 -0
  47. metradar/project/qpe/s5_draw_qpe_mosaic.py +308 -0
  48. metradar/project/wind_retrieval/__init__.py +9 -0
  49. metradar/project/wind_retrieval/config_3dwind.ini +45 -0
  50. metradar/{main_pydda.py → project/wind_retrieval/main_pydda.py} +152 -149
  51. metradar/util/__init__.py +9 -0
  52. metradar/{comm_func.py → util/comm_func.py} +1 -41
  53. metradar/util/exceptions.py +50 -0
  54. metradar/util/geo_transforms_pyart.py +627 -0
  55. metradar/{get_tlogp_from_sharppy.py → util/get_tlogp_from_sharppy.py} +16 -5
  56. metradar/{parse_pal.py → util/parse_pal.py} +147 -147
  57. metradar/util/radar_common.py +16 -0
  58. metradar/{trans_new_mosaic_nc.py → util/trans_new_mosaic_nc.py} +1 -1
  59. metradar-0.1.8.dist-info/METADATA +91 -0
  60. metradar-0.1.8.dist-info/RECORD +67 -0
  61. {metradar-0.1.5.dist-info → metradar-0.1.8.dist-info}/WHEEL +1 -1
  62. metradar-0.1.8.dist-info/licenses/LICENSE +21 -0
  63. metradar/grid.py +0 -281
  64. metradar/grid_data.py +0 -64
  65. metradar/oa_couhua.py +0 -166
  66. metradar/read_new_mosaic.py +0 -33
  67. metradar/retrieve_cmadaas.py +0 -3126
  68. metradar/retrieve_micaps_server.py +0 -2061
  69. metradar-0.1.5.dist-info/METADATA +0 -37
  70. metradar-0.1.5.dist-info/RECORD +0 -33
  71. /metradar/{pgmb_io.py → io/pgmb_io.py} +0 -0
  72. /metradar/{exceptions.py → project/make_vpr_aws/exceptions.py} +0 -0
  73. /metradar/{geo_transforms_pyart.py → project/make_vpr_aws/geo_transforms_pyart.py} +0 -0
  74. /metradar/{make_gif.py → util/make_gif.py} +0 -0
  75. {metradar-0.1.5.dist-info → metradar-0.1.8.dist-info}/top_level.txt +0 -0
metradar/__init__.py CHANGED
@@ -1,7 +1,9 @@
1
1
  """
2
- NMC_MET_RADAR is a python package to read or retrieve radar data
2
+ metradar is a python package to read or retrieve radar data
3
3
 
4
4
  """
5
5
 
6
6
  __author__ = "The R & D Center for Weather Forecasting Technology in NMC, CMA"
7
- __version__ = '0.1.1'
7
+
8
+
9
+ __all__ = [s for s in dir() if not s.startswith('_')]
metradar/config.py ADDED
@@ -0,0 +1,53 @@
1
+ # _*_ coding: utf-8 _*_
2
+
3
+ # Copyright (c) 2026 NMC Developers.
4
+ # Distributed under the terms of the GPL V3 License.
5
+
6
+ """
7
+ Read configure file.
8
+ """
9
+
10
+
11
+
12
+ import os
13
+ import configparser
14
+ from pathlib import Path
15
+
16
+
17
+ def _get_config_dir():
18
+ """
19
+ Get default configuration directory.
20
+ """
21
+ config_dir = Path.home() / ".metradar"
22
+ config_dir.mkdir(parents=True, exist_ok=True)
23
+ return config_dir
24
+
25
+ # Global Variables
26
+ CONFIG_DIR = _get_config_dir()
27
+
28
+
29
+ def _ConfigFetchError(BaseException):
30
+ pass
31
+
32
+
33
+ def _get_config_from_rcfile(rc='config.ini'):
34
+ """
35
+ Get configure information from config_dk_met_io.ini file.
36
+ """
37
+
38
+ if not os.path.exists(rc):
39
+ print(rc + ' not exists!')
40
+ return None
41
+
42
+ try:
43
+ config = configparser.ConfigParser()
44
+ config.read(rc,encoding='utf-8')
45
+ except IOError as e:
46
+ raise _ConfigFetchError(str(e))
47
+ except BaseException as e:
48
+ raise _ConfigFetchError(str(e))
49
+
50
+ return config
51
+
52
+ # Global Variables
53
+ CONFIG = _get_config_from_rcfile(CONFIG_DIR / 'config.ini')
@@ -0,0 +1,9 @@
1
+ """
2
+ METRADAR is a python package to read or retrieve radar data
3
+
4
+ """
5
+
6
+ __author__ = "The R & D Center for Weather Forecasting Technology in NMC, CMA"
7
+
8
+
9
+ __all__ = [s for s in dir() if not s.startswith('_')]
@@ -1,13 +1,15 @@
1
+ # _*_ coding: utf-8 _*_
2
+
1
3
  '''
2
4
  从pyart的radar object中获取任意垂直剖面的数据
3
5
 
4
6
  朱文剑
5
- 2021.10.14
7
+
6
8
 
7
9
  '''
8
10
 
9
11
  import numpy as np
10
- from pyart.core import Radar
12
+ from pyart.core import Radar,antenna_to_cartesian
11
13
  import math
12
14
  # import time
13
15
 
@@ -164,6 +166,7 @@ def get_cross_radar(radar:Radar,params):
164
166
  #计算相对雷达的仰角
165
167
  # ele = math.degrees(math.atan2(curz,curx))
166
168
  # 这里必须用math.pow,如果直接用称号会有较大误差
169
+ # print('R=',R,' curz=',curz,' curx=',curx)
167
170
  ele = math.asin((math.pow((curz+R),2) - math.pow(curx,2) - math.pow(R,2))/2/curx/R)/np.pi*180
168
171
 
169
172
  if ele < baseel_R or ele > topel_R:
@@ -197,158 +200,3 @@ def get_cross_radar(radar:Radar,params):
197
200
  nflag+=1
198
201
 
199
202
  return outdic
200
-
201
- # main function
202
- def get_cross_radar_old(radar:Radar,params):
203
- # startangle=None,startrange=None,endangle=None,endrange=None
204
- # startangle = 8.5
205
- # startrange = 69.23 #km
206
-
207
- # endangle = 18.6;
208
- # endrange = 59.03 #km
209
- startangle = params['crs_start_azi']
210
- startrange = params['crs_start_range']
211
- endangle = params['crs_end_azi']
212
- endrange = params['crs_end_range']
213
- toph = params['top_height']
214
-
215
- startx = startrange*np.sin(np.radians(startangle))
216
- starty = startrange*np.cos(np.radians(startangle))
217
- endx = endrange*np.sin(np.radians(endangle))
218
- endy = endrange*np.cos(np.radians(endangle))
219
-
220
- baseh = 0; # km 垂直剖面的起始高度
221
- # toph = 20; # km 垂直剖面的上限高度
222
-
223
- validzlv=[]
224
- validvlv=[]
225
- validReles=[]
226
- validDeles=[]
227
- outdic=dict()
228
-
229
- for il in range(radar.nsweeps):
230
- # if sweep(il).RGates > 0
231
- # if il !=1 and il !=3:
232
- # validzlv.append(il)
233
- # validReles.append(radar.get_elevation(il).mean())
234
- # if il !=0 and il !=2:
235
- # validvlv.append(il)
236
- # validDeles.append(radar.get_elevation(il).mean())
237
- validzlv.append(il)
238
- validReles.append(round(radar.get_elevation(il).mean(),1))
239
- validvlv.append(il)
240
- validDeles.append(round(radar.get_elevation(il).mean(),1))
241
-
242
- tol_length = np.sqrt(np.power((endx-startx),2) + np.power((endy - starty),2))
243
-
244
- #求方程坐标,这里暂时没考虑X=0的情况,后面要完善这一点
245
- [a,b] = linefunc(startx,starty,endx,endy)
246
-
247
- # 获取反射率垂直剖面
248
-
249
- #构建变量,确定坐标维度
250
- xreso = 0.25#km
251
- if endx < startx:
252
- xreso = -1*xreso
253
-
254
- xnum = int(tol_length / abs(xreso))
255
- yreso = 0.25# km
256
- ynum = int((toph - baseh) / yreso)
257
-
258
-
259
-
260
- beamwidth = radar.get_azimuth(validzlv[-1])
261
- beamwidth = np.diff(beamwidth)
262
- beamwidth = np.mean(beamwidth[beamwidth>0])
263
- topel_R = max(validReles) + beamwidth / 2
264
- baseel_R = min(validReles) - beamwidth / 2
265
-
266
- topel_D = max(validDeles) + beamwidth / 2
267
- baseel_D = min(validDeles) - beamwidth / 2
268
-
269
- tmp=[]
270
- for nn in range(len(validReles)-1):
271
- tmp.append(np.mean([validReles[nn],validReles[nn+1]]))
272
-
273
- tmp_newRel = sorted(myconcat((tmp,validReles)))
274
-
275
- tmp=[]
276
- for nn in range(len(validDeles)-1):
277
- tmp.append(np.mean([validDeles[nn],validDeles[nn+1]]))
278
-
279
- tmp_newDel = sorted(tmp+validDeles)
280
-
281
- newRel = [baseel_R+tmp_newRel+topel_R]
282
- newDel = [baseel_D+tmp_newDel+topel_D]
283
-
284
- # for varkey in radar.fields.keys():
285
-
286
- nflag=0
287
- outdic=dict()
288
- outdic['vertical_km'] = toph - baseh
289
- outdic['horizontal_km'] = tol_length
290
- outdic['xreso'] = xreso
291
- outdic['yreso'] = yreso
292
-
293
- for varkey in radar.fields.keys():
294
- outdic[varkey]=[]
295
- outdic[varkey] = np.zeros([ynum,xnum],dtype='float')*np.nan
296
-
297
-
298
- # 纯 for 循环版本 =====================
299
- valideles=[]
300
- validlvl=[]
301
- for varkey in radar.fields.keys():
302
- print(varkey)
303
- if varkey == 'reflectivity' :
304
- valideles = validReles
305
- validlvl = validzlv
306
- elif varkey == 'velocity':
307
- valideles = validDeles
308
- validlvl = validvlv
309
- else:
310
- # print('暂时仅支持回波强度和径向速度')
311
- continue
312
-
313
- curfd = []
314
- for il in range(radar.nsweeps):
315
- curfd.append(radar.get_field(il,varkey))#sweep(targetsp).dbz(az,gates);
316
-
317
- for iy in range(ynum):
318
- for ix in range(xnum):
319
- tmpcurx = startx + (ix * xreso) * math.cos(math.atan(a))
320
-
321
- tmpcury = a * tmpcurx + b
322
- tmpaz = (90 - math.degrees(math.atan2(tmpcury,tmpcurx)) + 360)%360
323
-
324
- curx = math.sqrt(math.pow(tmpcurx,2) + math.pow(tmpcury,2))#startrange + xreso * ix
325
- cury = baseh + iy * yreso
326
-
327
- #计算相对雷达的仰角
328
- ele = math.degrees(math.atan2(cury,curx))
329
- # if ele < baseel_R: ele = baseel_R
330
- # if ele > topel_R: continue
331
- if ele < baseel_R or ele > topel_R:
332
- continue
333
-
334
- tmp = list(abs(np.array(valideles) - ele))
335
- idx = tmp.index(min(tmp))
336
- idx_el = idx
337
-
338
- targetsp = validlvl[idx_el]
339
-
340
- #获取方位角角标
341
- tmp = list(abs(radar.get_azimuth(targetsp) - tmpaz))
342
- idx = tmp.index(min(tmp))
343
- az = idx
344
-
345
- gates = math.ceil(curx/math.cos(math.radians(valideles[idx_el]))/(radar.range['meters_between_gates'] / 1000))
346
-
347
- if gates < radar.ngates:
348
- #disp(sweep(targetsp).dbz(az,gates));
349
- if curfd[targetsp].data[az,gates] > -30:
350
- outdic[varkey][iy,ix] = curfd[targetsp].data[az,gates]
351
- nflag+=1
352
-
353
- return outdic
354
-
@@ -1,5 +1,7 @@
1
+ # _*_ coding: utf-8 _*_
2
+
1
3
  '''
2
- 将不同层次的mosacdata stack在一起
4
+ 将不同层次的mosacdata stack在一起,主要用于多进程拼图时,提高效率
3
5
  ZhuWJ
4
6
 
5
7
  '''