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.
Files changed (78) 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} +20 -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/make_vpr_aws/make_mosaic_20230731_daxing.ini +29 -0
  30. metradar/project/make_vpr_aws/make_mosaic_basefile.ini +29 -0
  31. metradar/project/nowcasting/__init__.py +9 -0
  32. metradar/project/nowcasting/nowcast_by_pysteps.py +214 -0
  33. metradar/{trans_nc_pgmb.py → project/nowcasting/trans_mosaic_pgmb.py} +19 -17
  34. metradar/project/qpe/Archive /346/250/241/345/274/217/350/257/264/346/230/216.txt" +2 -0
  35. metradar/project/qpe/__init__.py +9 -0
  36. metradar/project/qpe/archive_main_qpe_cfg.ini +91 -0
  37. metradar/project/qpe/do_s1.sh +6 -0
  38. metradar/project/qpe/do_s2.sh +6 -0
  39. metradar/project/qpe/do_s3.sh +6 -0
  40. metradar/project/qpe/do_s4.sh +6 -0
  41. metradar/project/qpe/do_s5.sh +6 -0
  42. metradar/project/qpe/exec_all.sh +11 -0
  43. metradar/project/qpe/get_rainrate_func.py +80 -0
  44. metradar/project/qpe/main_qpe_cfg.ini +85 -0
  45. metradar/project/qpe/s1_download_radar_region_cmadaas.py +123 -0
  46. metradar/project/qpe/s2_pre_process_single_radar.py +183 -0
  47. metradar/project/qpe/s3_trans_rainrate_to_qpe.py +499 -0
  48. metradar/project/qpe/s4_mosaic_qpe.py +523 -0
  49. metradar/project/qpe/s5_draw_qpe_mosaic.py +308 -0
  50. metradar/project/wind_retrieval/__init__.py +9 -0
  51. metradar/project/wind_retrieval/config_3dwind.ini +45 -0
  52. metradar/{main_pydda.py → project/wind_retrieval/main_pydda.py} +152 -149
  53. metradar/util/__init__.py +9 -0
  54. metradar/{comm_func.py → util/comm_func.py} +1 -41
  55. metradar/util/exceptions.py +50 -0
  56. metradar/util/geo_transforms_pyart.py +627 -0
  57. metradar/{get_tlogp_from_sharppy.py → util/get_tlogp_from_sharppy.py} +16 -5
  58. metradar/{parse_pal.py → util/parse_pal.py} +147 -147
  59. metradar/util/radar_common.py +16 -0
  60. metradar/{trans_new_mosaic_nc.py → util/trans_new_mosaic_nc.py} +1 -1
  61. metradar-0.1.8.2.dist-info/METADATA +90 -0
  62. metradar-0.1.8.2.dist-info/RECORD +69 -0
  63. {metradar-0.1.6.dist-info → metradar-0.1.8.2.dist-info}/WHEEL +1 -1
  64. metradar-0.1.8.2.dist-info/licenses/LICENSE +21 -0
  65. {metradar-0.1.6.dist-info → metradar-0.1.8.2.dist-info}/top_level.txt +0 -1
  66. cfg/config.py +0 -90
  67. metradar/grid.py +0 -281
  68. metradar/grid_data.py +0 -64
  69. metradar/oa_couhua.py +0 -166
  70. metradar/read_new_mosaic.py +0 -33
  71. metradar/retrieve_cmadaas.py +0 -3126
  72. metradar/retrieve_micaps_server.py +0 -2061
  73. metradar-0.1.6.dist-info/METADATA +0 -37
  74. metradar-0.1.6.dist-info/RECORD +0 -34
  75. /metradar/{pgmb_io.py → io/pgmb_io.py} +0 -0
  76. /metradar/{exceptions.py → project/make_vpr_aws/exceptions.py} +0 -0
  77. /metradar/{geo_transforms_pyart.py → project/make_vpr_aws/geo_transforms_pyart.py} +0 -0
  78. /metradar/{make_gif.py → util/make_gif.py} +0 -0
@@ -0,0 +1,157 @@
1
+
2
+ # _*_ coding: utf-8 _*_
3
+
4
+ '''
5
+ 专门用来解析色标文件的脚本
6
+ '''
7
+
8
+
9
+
10
+ import numpy as np
11
+ from matplotlib.colors import LinearSegmentedColormap, Normalize
12
+ import matplotlib.pyplot as plt
13
+ from matplotlib.colorbar import ColorbarBase
14
+ import re
15
+
16
+ # 请将色标文件中的solidcolor字段替换为color
17
+ def parse(file):
18
+ lines = []
19
+ vals = []
20
+ red = []
21
+ green = []
22
+ blue = []
23
+ last_color = None
24
+ transit_flag = False
25
+ with open(file, 'r',encoding='gb18030') as f:
26
+ for line in f:
27
+ if not line.lower().startswith('color:'):
28
+ continue
29
+ l = line.lower().lstrip('color: ').strip()
30
+ lines.append(l)
31
+ lines.sort(key=lambda x: float(x.split(' ')[0]))
32
+ color_len = len(lines)
33
+ for idx, l in enumerate(lines):
34
+ segs = [i for i in l.split(' ') if i]
35
+ vals.append(float(segs[0]))
36
+ current_color = tuple(int(i) / 255 for i in segs[1:4])
37
+ if color_len - idx == 2:
38
+ transit_flag = transit_flag if transit_flag else False
39
+ if not isinstance(last_color, tuple) and len(segs) == 3:
40
+ red.append((0, current_color[0]))
41
+ green.append((0, current_color[1]))
42
+ blue.append((0, current_color[2]))
43
+ last_color = current_color
44
+ else:
45
+ if len(segs) == 7 or color_len - idx == 2:
46
+ transit_color = tuple(int(i) / 255 for i in segs[4:7])
47
+ if transit_flag:
48
+ red.append((last_color[0], current_color[0]))
49
+ green.append((last_color[1], current_color[1]))
50
+ blue.append((last_color[2], current_color[2]))
51
+ else:
52
+ red.append((current_color[0], current_color[0]))
53
+ green.append((current_color[1], current_color[1]))
54
+ blue.append((current_color[2], current_color[2]))
55
+ last_color = transit_color
56
+ transit_flag = True
57
+ else:
58
+ red.append((current_color[0], current_color[0]))
59
+ green.append((current_color[1], current_color[1]))
60
+ blue.append((current_color[2], current_color[2]))
61
+ last_color = current_color
62
+ transit_flag = False
63
+ norm_array = (np.array(vals) - vals[0]) / (vals[-1] - vals[0])
64
+ cdict = {'red':[], 'green':[], 'blue':[]}
65
+ for idx in range(len(norm_array)):
66
+ cdict['red'].append((norm_array[idx],) + red[idx])
67
+ cdict['green'].append((norm_array[idx],) + green[idx])
68
+ cdict['blue'].append((norm_array[idx],) + blue[idx])
69
+ return LinearSegmentedColormap('cmap', cdict), Normalize(vals[0], vals[-1])
70
+
71
+ # 可以支持alpha,朱文剑,20210831
72
+ def parse_pro(file):
73
+ lines = []
74
+ vals = []
75
+ red = []
76
+ green = []
77
+ blue = []
78
+ alpha=[]
79
+ last_color = None
80
+ transit_flag = False
81
+ units=''
82
+ with open(file, 'r') as f:
83
+ for line in f:
84
+ if line.lower().startswith('units'):
85
+ units = re.split(r"[ ]+",line)[1].strip()
86
+ if not line.lower().startswith('color'):
87
+ continue
88
+ lines.append(line.strip())
89
+ lines.sort(key=lambda x: float(re.split(r"[ ]+",x)[1]))
90
+ color_len = len(lines)
91
+ for idx, l in enumerate(lines):
92
+ segs = [i for i in l.split(' ') if i]
93
+ vals.append(float(segs[1]))
94
+
95
+ current_color = tuple(int(i) / 255 for i in segs[2::])
96
+
97
+ if color_len - idx == 2:
98
+ transit_flag = transit_flag if transit_flag else False
99
+
100
+ if len(segs) >=8 or color_len - idx == 2:
101
+ if len(segs) == 10:
102
+ transit_color = tuple(int(i) / 255 for i in segs[6:10])
103
+ elif len(segs)==8:
104
+ transit_color = tuple(int(i) / 255 for i in segs[5:8])
105
+
106
+ if transit_flag:
107
+ red.append((last_color[0], current_color[0]))
108
+ green.append((last_color[1], current_color[1]))
109
+ blue.append((last_color[2], current_color[2]))
110
+ if segs[0]=='Color4:':
111
+ alpha.append((last_color[3], current_color[3]))
112
+ else:
113
+ alpha.append((1, 1))
114
+ else:
115
+ red.append((current_color[0], current_color[0]))
116
+ green.append((current_color[1], current_color[1]))
117
+ blue.append((current_color[2], current_color[2]))
118
+ if segs[0]=='Color4:':
119
+ alpha.append((current_color[3], current_color[3]))
120
+ else:
121
+ alpha.append((1.0, 1.0))
122
+ if len(segs) == 10 or len(segs) == 8:
123
+ last_color = transit_color
124
+ transit_flag = True
125
+ else:
126
+ red.append((current_color[0], current_color[0]))
127
+ green.append((current_color[1], current_color[1]))
128
+ blue.append((current_color[2], current_color[2]))
129
+ if segs[0]=='Color4:':
130
+ alpha.append((current_color[3], current_color[3]))
131
+ else:
132
+ alpha.append((1.0, 1.0))
133
+ last_color = current_color
134
+ transit_flag = False
135
+
136
+ norm_array = (np.array(vals) - vals[0]) / (vals[-1] - vals[0])
137
+ cdict = {'red':[], 'green':[], 'blue':[], 'alpha':[]}
138
+
139
+ for idx in range(len(norm_array)):
140
+ cdict['red'].append((norm_array[idx],) + red[idx])
141
+ cdict['green'].append((norm_array[idx],) + green[idx])
142
+ cdict['blue'].append((norm_array[idx],) + blue[idx])
143
+ cdict['alpha'].append((norm_array[idx],) + alpha[idx])
144
+
145
+ outdic=dict()
146
+ outdic['cmap'] = LinearSegmentedColormap('cmap', cdict)
147
+ outdic['norm'] = Normalize(vals[0], vals[-1])
148
+ outdic['units'] = units
149
+ return outdic
150
+
151
+ if __name__ == "__main__":
152
+
153
+ outdic = parse_pro('gr2_colors/IR_dark_alpha.pal')
154
+ fig = plt.figure(figsize=(3, 11))
155
+ ax = plt.gca()
156
+ cbar = ColorbarBase(ax, orientation="vertical", cmap=outdic['cmap'], norm=outdic['norm'])
157
+ plt.show()
@@ -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,3 +1,6 @@
1
+
2
+ # _*_ coding: utf-8 _*_
3
+
1
4
  """
2
5
  Functions for reading CINRAD level 2 files.
3
6
  some functions are based on pyart
@@ -770,9 +773,10 @@ class CNRADLevel2File(object):
770
773
  else:
771
774
  outdic_vol['height'] = int(self.dic_stcfg['grd_height'])
772
775
  if self.dic_stcfg['ana_height'] > 8000:
773
- outdic_vol['feedhorn_height'] = int(self.dic_stcfg['ana_height']/1000)
776
+ # 这里馈源高度减去地基高度,才是天线相对地基的高度
777
+ outdic_vol['feedhorn_height'] = int(self.dic_stcfg['ana_height']/1000) - outdic_vol['height']
774
778
  else:
775
- outdic_vol['feedhorn_height'] = int(self.dic_stcfg['ana_height'])
779
+ outdic_vol['feedhorn_height'] = int(self.dic_stcfg['ana_height']) - outdic_vol['height']
776
780
 
777
781
  outdic_vol['refl_calib'] = 1.0
778
782
  outdic_vol['power_h'] = 0.0
@@ -892,7 +896,46 @@ class CNRADLevel2File(object):
892
896
 
893
897
  return block_name, outdic,ptr
894
898
 
899
+ def get_beam_width_h(self):
900
+ """
901
+ Return the horizontal beam width in degrees.
902
+
903
+ Returns
904
+ -------
905
+ beam_width_h : float
906
+ Horizontal beam width in degrees.
907
+
908
+ """
909
+ return [self.dic_stcfg['beamwidth_h'],]
910
+
911
+ def get_beam_width_v(self):
912
+ """
913
+ Return the vertical beam width in degrees.
914
+
915
+ Returns
916
+ -------
917
+ beam_width_v : float
918
+ Vertical beam width in degrees.
919
+
920
+ """
921
+ return [self.dic_stcfg['beamwidth_v'],]
922
+
923
+ def get_antenna_gain(self):
924
+ """
925
+ Return the antenna gain in dBi.
926
+
927
+ Returns
928
+ -------
929
+ antenna_gain : float
930
+ Antenna gain in dBi.
895
931
 
932
+ """
933
+ return [45,] # db
934
+
935
+ def get_receiver_bandwidth(self):
936
+
937
+ return [1.5e6,] # Hz
938
+
896
939
  def _get_msg1_from_buf(self,buf, pos, dic):
897
940
  """ Retrieve and unpack a MSG1 record from a buffer. """
898
941
  msg_header_size = _structure_size(MSG_HEADER)
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
- # Copyright (c) 2022 NMC Developers.
4
- # Distributed under the terms of the GPL V3 License.
3
+
5
4
  # 将FMT格式数据直接解析为pyart的radar object格式
6
5
  # Wenjian Zhu
7
6
  #
@@ -16,6 +15,7 @@ from .cnrad_level2 import CNRADLevel2File
16
15
  import warnings
17
16
  import numpy as np
18
17
 
18
+
19
19
  mapping = {
20
20
  "REF": "reflectivity",
21
21
  "VEL": "velocity",
@@ -176,8 +176,25 @@ def read_cnrad_fmt(filename, field_names=None, additional_metadata=None,
176
176
  unambiguous_range['data'] = (
177
177
  nfile.get_unambigous_range(scans).astype('float32'))
178
178
 
179
+ radar_beam_width_h = filemetadata('radar_beam_width_h')
180
+ radar_beam_width_v = filemetadata('radar_beam_width_v')
181
+ radar_beam_width_h['data'] = nfile.get_beam_width_h()
182
+ radar_beam_width_v['data'] = nfile.get_beam_width_v()
183
+
184
+ radar_atenna_gain = filemetadata('radar_antenna_gain')
185
+ radar_receiver_bandwidth = filemetadata('radar_receiver_bandwidth')
186
+ radar_atenna_gain['data'] = nfile.get_antenna_gain()
187
+ radar_receiver_bandwidth['data'] = nfile.get_receiver_bandwidth()
188
+
189
+
179
190
  instrument_parameters = {'unambiguous_range': unambiguous_range,
180
- 'nyquist_velocity': nyquist_velocity, }
191
+ 'nyquist_velocity': nyquist_velocity,
192
+ 'radar_beam_width_h': radar_beam_width_h,
193
+ 'radar_beam_width_v': radar_beam_width_v,
194
+ 'radar_antenna_gain_h': radar_atenna_gain,
195
+ 'radar_antenna_gain_v': radar_atenna_gain,
196
+ 'radar_receiver_bandwidth': radar_receiver_bandwidth,
197
+ }
181
198
 
182
199
  nfile.close()
183
200
  return Radar(