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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
'''
|
|
5
5
|
多普勒雷达三维风场反演脚本
|
|
6
6
|
朱文剑
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
'''
|
|
9
9
|
# %%
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ import pydda
|
|
|
13
13
|
import os
|
|
14
14
|
import matplotlib.pyplot as plt
|
|
15
15
|
import matplotlib
|
|
16
|
-
from get_tlogp_from_sharppy import get_profile
|
|
16
|
+
from metradar.util.get_tlogp_from_sharppy import get_profile
|
|
17
17
|
import numpy as np
|
|
18
18
|
import configparser
|
|
19
19
|
from datetime import datetime
|
|
@@ -21,7 +21,8 @@ import math
|
|
|
21
21
|
import argparse
|
|
22
22
|
import shutil
|
|
23
23
|
import sys
|
|
24
|
-
from decode_fmt_pyart import read_cnrad_fmt
|
|
24
|
+
from metradar.io.decode_fmt_pyart import read_cnrad_fmt
|
|
25
|
+
import xarray as xr
|
|
25
26
|
# import warnings
|
|
26
27
|
# warnings.filterwarnings("ignore")
|
|
27
28
|
|
|
@@ -165,8 +166,6 @@ class GET_WIND_3D:
|
|
|
165
166
|
self.g_numy = int(len(range(self.ylims[0],self.ylims[1]))*1000/self.yreso+1) # y方向格点数
|
|
166
167
|
self.g_numz = int(len(range(self.zlims[0],self.zlims[1]))*1000/self.zreso+1) # z方向格点数
|
|
167
168
|
|
|
168
|
-
|
|
169
|
-
|
|
170
169
|
def draw_all_pic(self,bdrawhori=True,):
|
|
171
170
|
resultnames = []
|
|
172
171
|
files = os.listdir(self.outpath)
|
|
@@ -187,8 +186,7 @@ class GET_WIND_3D:
|
|
|
187
186
|
resultnames.append(self.outpath + os.sep + ff)
|
|
188
187
|
self.myprint(ff)
|
|
189
188
|
|
|
190
|
-
|
|
191
|
-
# ana_lon = 119.376
|
|
189
|
+
|
|
192
190
|
s_x = self.getDistance(self.ana_lat,self.ana_lon,self.ana_lat,self.standard_lon)
|
|
193
191
|
s_y = self.getDistance(self.ana_lat,self.ana_lon,self.standard_lat,self.ana_lon)
|
|
194
192
|
self.myprint('拼图中心经度为:%.3f'%self.standard_lon)
|
|
@@ -198,26 +196,22 @@ class GET_WIND_3D:
|
|
|
198
196
|
self.myprint('X方向偏移量为:%d'%s_x)
|
|
199
197
|
self.myprint('Y方向偏移量为:%d'%s_y)
|
|
200
198
|
|
|
201
|
-
# lev_xz = 55
|
|
202
|
-
# lev_yz = 51
|
|
203
199
|
lev_yz = int((self.xlims[0] - s_x)/(self.xreso/1e3))
|
|
204
200
|
lev_xz = int((s_y- self.ylims[0])/(self.yreso/1e3))
|
|
205
201
|
self.myprint('X方向层次为:%d'%lev_xz)
|
|
206
202
|
self.myprint('Y方向层次为:%d'%lev_yz)
|
|
207
203
|
|
|
208
204
|
|
|
209
|
-
Grids = [
|
|
205
|
+
Grids = [xr.open_dataset(resultname) for resultname in resultnames]
|
|
210
206
|
|
|
211
|
-
x=Grids[0].x
|
|
212
|
-
y=Grids[0].y
|
|
213
|
-
z=Grids[0].z
|
|
207
|
+
x=Grids[0].x.values
|
|
208
|
+
y=Grids[0].y.values
|
|
209
|
+
z=Grids[0].z.values
|
|
214
210
|
|
|
215
|
-
uwind=Grids[0]
|
|
216
|
-
vwind=Grids[0]
|
|
217
|
-
wwind=Grids[0]
|
|
211
|
+
uwind=Grids[0]['u'].values
|
|
212
|
+
vwind=Grids[0]['v'].values
|
|
213
|
+
wwind=Grids[0]['w'].values
|
|
218
214
|
|
|
219
|
-
# vor_stretch = Grids[0].fields['vor_stretch']['data']
|
|
220
|
-
# vor_tilt = Grids[0].fields['vor_tilt']['data']
|
|
221
215
|
|
|
222
216
|
picpath_horiz_bar = self.picpath + os.sep + '水平风场'
|
|
223
217
|
picpath_horiz_stream = self.picpath + os.sep + '水平流场'
|
|
@@ -254,7 +248,7 @@ class GET_WIND_3D:
|
|
|
254
248
|
fig, ax = plt.subplots(figsize=(8, 6))
|
|
255
249
|
pydda.vis.plot_horiz_xsection_barbs(Grids, ax, 'reflectivity', level=ll,
|
|
256
250
|
# w_vel_contours=[3, 5,],
|
|
257
|
-
cmap='
|
|
251
|
+
cmap='NWSRef', vmin=0, vmax=70,
|
|
258
252
|
barb_spacing_x_km=5,
|
|
259
253
|
barb_spacing_y_km=5,
|
|
260
254
|
show_lobes=False)
|
|
@@ -273,7 +267,7 @@ class GET_WIND_3D:
|
|
|
273
267
|
|
|
274
268
|
fig, ax = plt.subplots(figsize=(8, 6))
|
|
275
269
|
pydda.vis.plot_horiz_xsection_streamlines(Grids, ax, 'reflectivity', level=ll,
|
|
276
|
-
cmap='
|
|
270
|
+
cmap='NWSRef', vmin=0, vmax=70,
|
|
277
271
|
# w_vel_contours=[3, 5,],
|
|
278
272
|
show_lobes=False,
|
|
279
273
|
)
|
|
@@ -287,71 +281,13 @@ class GET_WIND_3D:
|
|
|
287
281
|
self.myprint(picpath_horiz_stream + os.sep + picfilename + ' saved!')
|
|
288
282
|
|
|
289
283
|
plt.close(fig)
|
|
290
|
-
|
|
291
|
-
# # draw stretch vortex pic
|
|
292
|
-
# for ll in range(self.g_numz):
|
|
293
|
-
|
|
294
|
-
# fig, axes = plt.subplots(figsize=(8, 6))
|
|
295
|
-
|
|
296
|
-
# # DPI = fig.get_dpi()
|
|
297
|
-
# # fig.set_size_inches(1200.0/float(DPI),900.0/float(DPI))
|
|
298
|
-
# plt.tight_layout(pad=0, h_pad=0, w_pad=0, rect=(0.035,0.01,0.91,0.9))
|
|
299
|
-
# ax = plt.axes()
|
|
300
|
-
# #ax.set_extent([-5000, 5000, -2500, 7500])
|
|
301
|
-
# levels=np.arange(-10,12, 2)
|
|
302
|
-
# colors = [(1, 0, 1),(0.23,0.58,0.96),(1, 1, 1),(1,0.75,0.24),(1,0,0)]
|
|
303
|
-
# cm = LinearSegmentedColormap.from_list("wbyr", colors, N=100)
|
|
304
|
-
# cset1=ax.contourf(x, y,vor_stretch[ll,:,:],cmap=cm,levels=levels, extend='both', origin='image')
|
|
305
|
-
# ax1 = fig.add_axes([0.912, 0.3, 0.03, 0.55])
|
|
306
|
-
# cbar=fig.colorbar(cset1,cax=ax1,orientation='vertical',ticks=levels)
|
|
307
|
-
|
|
308
|
-
# ax.barbs(x[::3],y[::3],uwind[ll,::3,::3], vwind[ll,::3,::3],flagcolor=(0.1,0.2,0.1,0),length=4.5,linewidth=0.6,
|
|
309
|
-
# barb_increments=dict(half=2, full=4, flag=20),sizes=dict(emptybarb=0.0), barbcolor=['k'],rounding=True,flip_barb=False)
|
|
310
|
-
|
|
311
|
-
# picfilename = 'vor_stretch_%02d_%s.png'%(ll+1,self.time_files)
|
|
312
|
-
# if self.bsavepic:
|
|
313
|
-
# fig.savefig(picpath_vor_stretch + os.sep + picfilename,
|
|
314
|
-
# format='png', transparent=False, dpi=300, pad_inches = 0)
|
|
315
|
-
# self.myprint(picpath_vor_stretch + os.sep + picfilename + ' saved!')
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
# plt.close(fig)
|
|
319
|
-
|
|
320
|
-
# # draw tilt vortex pic
|
|
321
|
-
# for ll in range(self.g_numz):
|
|
322
|
-
|
|
323
|
-
# fig, axes = plt.subplots(figsize=(8, 6))
|
|
324
|
-
|
|
325
|
-
# # DPI = fig.get_dpi()
|
|
326
|
-
# # fig.set_size_inches(1200.0/float(DPI),900.0/float(DPI))
|
|
327
|
-
# plt.tight_layout(pad=0, h_pad=0, w_pad=0, rect=(0.035,0.01,0.91,0.9))
|
|
328
|
-
# ax = plt.axes()
|
|
329
|
-
# #ax.set_extent([-5000, 5000, -2500, 7500])
|
|
330
|
-
# levels=np.arange(-10,12, 2)
|
|
331
|
-
# colors = [(1, 0, 1),(0.23,0.58,0.96),(1, 1, 1),(1,0.75,0.24),(1,0,0)]
|
|
332
|
-
# cm = LinearSegmentedColormap.from_list("wbyr", colors, N=100)
|
|
333
|
-
# cset1=ax.contourf(x, y,vor_tilt[ll,:,:],cmap=cm,levels=levels, extend='both', origin='image')
|
|
334
|
-
# ax1 = fig.add_axes([0.912, 0.3, 0.03, 0.55])
|
|
335
|
-
# cbar=fig.colorbar(cset1,cax=ax1,orientation='vertical',ticks=levels)
|
|
336
|
-
|
|
337
|
-
# ax.barbs(x[::3],y[::3],uwind[ll,::3,::3], vwind[ll,::3,::3],flagcolor=(0.1,0.2,0.1,0),length=4.5,linewidth=0.6,
|
|
338
|
-
# barb_increments=dict(half=2, full=4, flag=20),sizes=dict(emptybarb=0.0), barbcolor=['k'],rounding=True,flip_barb=False)
|
|
339
|
-
|
|
340
|
-
# picfilename = 'vor_tilt_%02d_%s.png'%(ll+1,self.time_files)
|
|
341
|
-
# if self.bsavepic:
|
|
342
|
-
# fig.savefig(picpath_vor_tilt + os.sep + picfilename,
|
|
343
|
-
# format='png', transparent=False, dpi=300, pad_inches = 0)
|
|
344
|
-
# self.myprint(picpath_vor_tilt + os.sep + picfilename + ' saved!')
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
# plt.close(fig)
|
|
348
284
|
|
|
349
285
|
try:
|
|
350
286
|
#=================
|
|
351
287
|
fig, ax = plt.subplots(figsize=(8, 4))
|
|
352
288
|
pydda.vis.plot_xz_xsection_barbs(Grids, ax, 'reflectivity', level=lev_xz,
|
|
353
289
|
# w_vel_contours=[3, 5,],
|
|
354
|
-
cmap='
|
|
290
|
+
cmap='NWSRef', vmin=0, vmax=70,
|
|
355
291
|
barb_spacing_x_km=2.0,
|
|
356
292
|
barb_spacing_z_km=1.0)
|
|
357
293
|
ax.set_xlim(self.xlims.tolist())
|
|
@@ -370,7 +306,7 @@ class GET_WIND_3D:
|
|
|
370
306
|
try:
|
|
371
307
|
fig, ax = plt.subplots(figsize=(8, 4))
|
|
372
308
|
pydda.vis.plot_xz_xsection_streamlines(Grids, None, 'reflectivity', level=lev_xz,
|
|
373
|
-
cmap='
|
|
309
|
+
cmap='NWSRef', vmin=0, vmax=70,
|
|
374
310
|
# w_vel_contours=[3, 5,],
|
|
375
311
|
)
|
|
376
312
|
ax.set_xlim(self.xlims.tolist())
|
|
@@ -389,7 +325,7 @@ class GET_WIND_3D:
|
|
|
389
325
|
fig, ax = plt.subplots(figsize=(8, 4))
|
|
390
326
|
pydda.vis.plot_yz_xsection_barbs(Grids, None, 'reflectivity', level=lev_yz,
|
|
391
327
|
# w_vel_contours=[ 3, 5, ],
|
|
392
|
-
cmap='
|
|
328
|
+
cmap='NWSRef', vmin=0, vmax=70,
|
|
393
329
|
barb_spacing_y_km=2,
|
|
394
330
|
barb_spacing_z_km=1)
|
|
395
331
|
ax.set_xlim(self.ylims.tolist())
|
|
@@ -407,7 +343,7 @@ class GET_WIND_3D:
|
|
|
407
343
|
try:
|
|
408
344
|
fig, ax = plt.subplots(figsize=(8, 4))
|
|
409
345
|
pydda.vis.plot_yz_xsection_streamlines(Grids, None, 'reflectivity', level=lev_yz,
|
|
410
|
-
cmap='
|
|
346
|
+
cmap='NWSRef', vmin=0, vmax=70,
|
|
411
347
|
# w_vel_contours=[3, 5, ],
|
|
412
348
|
)
|
|
413
349
|
ax.set_xlim(self.ylims.tolist())
|
|
@@ -429,8 +365,7 @@ class GET_WIND_3D:
|
|
|
429
365
|
|
|
430
366
|
filepaths = []
|
|
431
367
|
filenames = []
|
|
432
|
-
|
|
433
|
-
# import pdb; pdb.set_trace()
|
|
368
|
+
|
|
434
369
|
for rd in self.radars:
|
|
435
370
|
curpath = self.radarfilepath + os.sep + rd
|
|
436
371
|
filepaths.append(curpath)
|
|
@@ -440,8 +375,6 @@ class GET_WIND_3D:
|
|
|
440
375
|
files = [ff for ff in files if ff.find('Z_RADR')>=0]
|
|
441
376
|
times = [datetime.strptime(ff[15:29], '%Y%m%d%H%M%S').timestamp() for ff in files]
|
|
442
377
|
|
|
443
|
-
# files = [ff for ff in files if ff.find('ar2v')>=0]
|
|
444
|
-
# times = [datetime.strptime(ff[5:13]+ff[14:20], '%Y%m%d%H%M%S').timestamp() for ff in files]
|
|
445
378
|
|
|
446
379
|
if len(times) == 0:
|
|
447
380
|
self.myprint('未找到 %s 雷达站的有效数据文件,请检查!'%rd)
|
|
@@ -458,22 +391,22 @@ class GET_WIND_3D:
|
|
|
458
391
|
self.write_to_progress_main(5)
|
|
459
392
|
|
|
460
393
|
|
|
461
|
-
# filename1 = 'HAJS.20200612.053920.ar2v'
|
|
462
|
-
# filename2 = 'NJJS.20200612.054229.ar2v'
|
|
463
|
-
# filename3 = 'TZJS.20200612.054032.ar2v'
|
|
464
394
|
radar_objs=[]
|
|
465
395
|
grid_objs=[]
|
|
466
396
|
self.outname_grid=[]
|
|
467
397
|
self.valid_radars=len(filenames)
|
|
468
398
|
for nn in range(self.valid_radars):
|
|
469
399
|
outname = filenames[nn].split('.')
|
|
470
|
-
self.outname_grid.append(filenames[nn].replace(outname[-1],'
|
|
400
|
+
self.outname_grid.append(filenames[nn].replace(outname[-1],'wind.nc'))
|
|
471
401
|
|
|
472
402
|
for nn in range(self.valid_radars):
|
|
473
403
|
pass
|
|
474
404
|
|
|
475
|
-
|
|
476
|
-
|
|
405
|
+
radar = read_cnrad_fmt(filepaths[nn] + os.sep + filenames[nn])
|
|
406
|
+
# 退速速模糊
|
|
407
|
+
newvel = pyart.correct.dealias_region_based(radar, vel_field='velocity')
|
|
408
|
+
radar.add_field('corrected_velocity', newvel, replace_existing=True)
|
|
409
|
+
radar_objs.append(radar)
|
|
477
410
|
|
|
478
411
|
self.myprint('read %s over!'%filenames[nn])
|
|
479
412
|
|
|
@@ -483,15 +416,42 @@ class GET_WIND_3D:
|
|
|
483
416
|
weighting_function = 'BARNES2',
|
|
484
417
|
grid_shape=(self.g_numz, self.g_numy, self.g_numx),
|
|
485
418
|
grid_limits=(self.g_zlim, self.g_ylim, self.g_xlim),
|
|
486
|
-
fields=['reflectivity','velocity']))
|
|
419
|
+
fields=['reflectivity','velocity','corrected_velocity']).to_xarray())
|
|
487
420
|
self.myprint('grid over!')
|
|
488
421
|
|
|
489
|
-
# radar1 = pyart.io.read_nexrad_archive(filepath1 + os.sep + filename1)
|
|
490
|
-
# print('read %s over!'%filename1)
|
|
491
422
|
self.write_to_progress_main(20)
|
|
492
423
|
|
|
493
424
|
# step 2=============风场反演
|
|
494
|
-
|
|
425
|
+
|
|
426
|
+
# 给grid对象添加部分属性point_x, point_y, point_z, AZ, EL, point_altitude
|
|
427
|
+
# 按z,y,x的顺序,进行meshgrid
|
|
428
|
+
point_z,point_y,point_x = np.mgrid[
|
|
429
|
+
self.g_zlim[0]:self.g_zlim[1]+self.zreso:self.zreso,
|
|
430
|
+
self.g_ylim[0]:self.g_ylim[1]+self.yreso:self.yreso,
|
|
431
|
+
self.g_xlim[0]:self.g_xlim[1]+self.xreso:self.xreso
|
|
432
|
+
]
|
|
433
|
+
|
|
434
|
+
# 将point_x, point_y, point_z添加到grid对象中
|
|
435
|
+
for nn in range(len(grid_objs)):
|
|
436
|
+
grid_objs[nn]['point_x'] = (('z','y','x'), point_x)
|
|
437
|
+
grid_objs[nn]['point_y'] = (('z','y','x'), point_y)
|
|
438
|
+
grid_objs[nn]['point_z'] = (('z','y','x'), point_z)
|
|
439
|
+
|
|
440
|
+
# 根据z,y,x坐标,计算对应的方位角和仰角,并存储在AZ变量和EL变量中
|
|
441
|
+
for nn in range(len(grid_objs)):
|
|
442
|
+
grid_objs[nn]['AZ'] = (('z','y','x'), pyart.core.cartesian_to_antenna(
|
|
443
|
+
grid_objs[nn]['point_x'].data,
|
|
444
|
+
grid_objs[nn]['point_y'].data,
|
|
445
|
+
grid_objs[nn]['point_z'].data)[1])
|
|
446
|
+
grid_objs[nn]['EL'] = (('z','y','x'), pyart.core.cartesian_to_antenna(
|
|
447
|
+
grid_objs[nn]['point_x'].data,
|
|
448
|
+
grid_objs[nn]['point_y'].data,
|
|
449
|
+
grid_objs[nn]['point_z'].data)[2])
|
|
450
|
+
# 将高度信息存储在point_altitude变量中,直接采用z坐标值
|
|
451
|
+
for nn in range(len(grid_objs)):
|
|
452
|
+
grid_objs[nn]['point_altitude'] = (('z','y','x'), grid_objs[nn]['point_z'].data)
|
|
453
|
+
|
|
454
|
+
|
|
495
455
|
# 添加探空数据
|
|
496
456
|
if not os.path.exists(self.tlogp_filepath + os.sep + self.tlogp_filename):
|
|
497
457
|
self.myprint(self.tlogp_filepath + os.sep + self.tlogp_filename + ' not exists! please check!')
|
|
@@ -499,8 +459,9 @@ class GET_WIND_3D:
|
|
|
499
459
|
return False
|
|
500
460
|
|
|
501
461
|
profile = get_profile(self.tlogp_filepath,self.tlogp_filename)
|
|
502
|
-
|
|
503
|
-
grid_objs[0], profile, vel_field='
|
|
462
|
+
grid_objs[0]= pydda.initialization.make_wind_field_from_profile(
|
|
463
|
+
grid_objs[0], profile, vel_field='corrected_velocity')
|
|
464
|
+
|
|
504
465
|
# u_init, v_init, w_init = None,None,None
|
|
505
466
|
self.myprint('探空数据 %s 加载完毕!'%self.tlogp_filename)
|
|
506
467
|
# 速度退模糊暂时空缺,后期补上
|
|
@@ -508,19 +469,38 @@ class GET_WIND_3D:
|
|
|
508
469
|
|
|
509
470
|
#进行多雷达三维风场反演
|
|
510
471
|
# try:
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
472
|
+
|
|
473
|
+
print('=================================')
|
|
474
|
+
# return new_grid_list, parameters
|
|
475
|
+
Grids, _ = pydda.retrieval.get_dd_wind_field(
|
|
476
|
+
grid_objs,
|
|
477
|
+
Co=100.0,
|
|
478
|
+
Cm=1500.0,
|
|
479
|
+
Cx=1e-2,
|
|
480
|
+
Cy=1e-2,
|
|
481
|
+
Cz=1e-2,
|
|
482
|
+
vel_name="corrected_velocity",
|
|
483
|
+
refl_field="reflectivity",
|
|
484
|
+
frz=5000.0,
|
|
485
|
+
engine="tensorflow", # 有GPU就用tensorflow,没有就用scipy或jax
|
|
486
|
+
mask_outside_opt=True,
|
|
487
|
+
upper_bc=1,
|
|
488
|
+
)
|
|
516
489
|
# except:
|
|
517
490
|
# self.myprint('get_dd_wind_field error!')
|
|
518
491
|
# self.write_to_progress_main(100)
|
|
519
492
|
# return False
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
493
|
+
|
|
494
|
+
# 计算拉伸涡度和倾斜涡度
|
|
495
|
+
Grids = self.calc_vortex(Grids)
|
|
496
|
+
|
|
497
|
+
for nn in range(len(Grids)):
|
|
498
|
+
# 将reflectivity小于10的格点设置为缺省值
|
|
499
|
+
Grids[nn]['reflectivity'] = Grids[nn]['reflectivity'].where(Grids[nn]['reflectivity']>=10)
|
|
500
|
+
outname = filenames[nn].split('.')
|
|
501
|
+
|
|
502
|
+
Grids[nn].to_netcdf(self.outpath + os.sep + filenames[nn].replace(outname[-1],'wind.nc'))
|
|
503
|
+
|
|
524
504
|
|
|
525
505
|
# exclude masked gates from the gridding
|
|
526
506
|
# gatefilter = pyart.filters.GateFilter(Grids)
|
|
@@ -530,9 +510,6 @@ class GET_WIND_3D:
|
|
|
530
510
|
self.write_to_progress_main(80)
|
|
531
511
|
# print('All levels = %d'%g_numz)
|
|
532
512
|
|
|
533
|
-
# 计算拉伸涡度和倾斜涡度
|
|
534
|
-
# self.calc_vortex(Grids)
|
|
535
|
-
|
|
536
513
|
# self.draw_all_pic()
|
|
537
514
|
|
|
538
515
|
self.write_to_progress_main(100)
|
|
@@ -545,55 +522,76 @@ class GET_WIND_3D:
|
|
|
545
522
|
#计算拉伸涡度和倾斜涡度
|
|
546
523
|
def calc_vortex(self,Grids):
|
|
547
524
|
self.myprint('starting calc_vortex......')
|
|
548
|
-
files = os.listdir(self.outpath)
|
|
549
|
-
if len(files)==0:
|
|
550
|
-
self.myprint('no files in output path!')
|
|
551
|
-
return False
|
|
552
|
-
filename = files[0]
|
|
553
|
-
|
|
554
|
-
# Grids = pyart.io.read_grid(self.outpath + os.sep + filename)
|
|
555
|
-
# dataset = nc.Dataset(self.outpath + os.sep + filename)
|
|
556
525
|
|
|
557
|
-
|
|
558
|
-
vwind=Grids[0].fields['v']['data']
|
|
559
|
-
wwind=Grids[0].fields['w']['data']
|
|
526
|
+
|
|
560
527
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
528
|
+
if isinstance(Grids, list):
|
|
529
|
+
uwind=Grids[0]['u'].values
|
|
530
|
+
vwind=Grids[0]['v'].values
|
|
531
|
+
wwind=Grids[0]['w'].values
|
|
532
|
+
else:
|
|
533
|
+
uwind=Grids['u'].values
|
|
534
|
+
vwind=Grids['v'].values
|
|
535
|
+
wwind=Grids['w'].values
|
|
536
|
+
# 检查uwind的维度是否是四维
|
|
537
|
+
if uwind.ndim != 4:
|
|
538
|
+
raise ValueError("Expected uwind to be a 4D array with dimensions (time, z, y, x)")
|
|
564
539
|
|
|
565
540
|
vor_stretch_data = np.zeros(uwind.shape,dtype=float)
|
|
566
541
|
vor_tilt_data = np.zeros(uwind.shape,dtype=float)
|
|
567
|
-
for
|
|
568
|
-
|
|
569
|
-
|
|
542
|
+
for tt in range(uwind.shape[0]):
|
|
543
|
+
dudz,dudy,dudx = np.gradient(uwind[tt,:,:,:])
|
|
544
|
+
dvdz,dvdy,dvdx = np.gradient(vwind[tt,:,:,:])
|
|
545
|
+
dwdz,dwdy,dwdx = np.gradient(wwind[tt,:,:,:])
|
|
570
546
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
547
|
+
for lev in range(uwind.shape[1]):
|
|
548
|
+
# picname="stretch_%03d.png"%lev
|
|
549
|
+
# print(lev)
|
|
550
|
+
|
|
551
|
+
div=dudx[lev,:,:] + dvdy[lev,:,:]
|
|
552
|
+
vor=dvdx[lev,:,:] - dudy[lev,:,:]
|
|
553
|
+
|
|
554
|
+
u=uwind[tt,lev,:,:]
|
|
555
|
+
v=vwind[tt,lev,:,:]
|
|
556
|
+
#dw
|
|
557
|
+
|
|
558
|
+
#拉伸项
|
|
559
|
+
vor_stretch_data[tt,lev,:,:]=vor*div
|
|
580
560
|
|
|
581
|
-
|
|
582
|
-
|
|
561
|
+
#倾斜项
|
|
562
|
+
vor_tilt_data[tt,lev,:,:]=dwdy[lev,:,:]*dudz[lev,:,:]-dwdx[lev,:,:]*dvdz[lev,:,:]
|
|
583
563
|
|
|
584
|
-
|
|
585
|
-
vor_stretch = {'data':vor_stretch_data,'_FillValue':-9999.0,'long_name':'stretch vortex','units':'m-2/s-2','coordinates':'z,y,x'}
|
|
586
|
-
vor_tilt = {'data':vor_tilt_data,'_FillValue':-9999.0,'long_name':'tilting vortex','units':'m-2/s-2','coordinates':'z,y,x'}
|
|
587
564
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
565
|
+
if isinstance(Grids, list):
|
|
566
|
+
for nn in range(len(Grids)):
|
|
567
|
+
Grids[nn]['vor_stretch'] = (('time','z','y','x'), vor_stretch_data)
|
|
568
|
+
Grids[nn]['vor_tilt'] = (('time','z','y','x'), vor_tilt_data)
|
|
569
|
+
|
|
570
|
+
# add attrs
|
|
571
|
+
|
|
572
|
+
Grids[nn]['vor_stretch'].attrs['long_name'] = 'stretch vortex'
|
|
573
|
+
Grids[nn]['vor_stretch'].attrs['units'] = 'm-2/s-2'
|
|
574
|
+
Grids[nn]['vor_stretch'].attrs['coordinates'] = 't,z,y,x'
|
|
575
|
+
|
|
576
|
+
Grids[nn]['vor_tilt'].attrs['long_name'] = 'tilting vortex'
|
|
577
|
+
Grids[nn]['vor_tilt'].attrs['units'] = 'm-2/s-2'
|
|
578
|
+
Grids[nn]['vor_tilt'].attrs['coordinates'] = 't,z,y,x'
|
|
592
579
|
|
|
580
|
+
else:
|
|
581
|
+
Grids['vor_stretch'] = (('time','z','y','x'), vor_stretch_data)
|
|
582
|
+
Grids['vor_tilt'] = (('time','z','y','x'), vor_tilt_data)
|
|
583
|
+
Grids['vor_stretch'].attrs['long_name'] = 'stretch vortex'
|
|
584
|
+
Grids['vor_stretch'].attrs['units'] = 'm-2/s-2'
|
|
585
|
+
Grids['vor_stretch'].attrs['coordinates'] = 't,z,y,x'
|
|
586
|
+
|
|
587
|
+
Grids['vor_tilt'].attrs['long_name'] = 'tilting vortex'
|
|
588
|
+
Grids['vor_tilt'].attrs['units'] = 'm-2/s-2'
|
|
589
|
+
Grids['vor_tilt'].attrs['coordinates'] = 't,z,y,x'
|
|
590
|
+
|
|
593
591
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
592
|
+
return Grids
|
|
593
|
+
|
|
594
|
+
|
|
597
595
|
|
|
598
596
|
|
|
599
597
|
if __name__ == "__main__":
|
|
@@ -635,11 +633,16 @@ if __name__ == "__main__":
|
|
|
635
633
|
parser.add_argument('--drawcross', dest='drawpic_cross', action='store_const',
|
|
636
634
|
const=drawpic_cross,
|
|
637
635
|
help='draw XZ and YZ pic')
|
|
636
|
+
#是否为debug模式
|
|
638
637
|
BDEBUG=True
|
|
639
638
|
|
|
640
639
|
if BDEBUG:
|
|
641
640
|
print('当前为debug模式,所以直接读取主目录下的config.ini, 请注意!')
|
|
642
|
-
|
|
641
|
+
config_path = '/home/wjzhu/OneDrive/PythonCode/MyWork/metradar/metradar/project/wind_retrieval/config_3dwind.ini'
|
|
642
|
+
if not os.path.exists(config_path):
|
|
643
|
+
print('%s not exists! please check!'%config_path)
|
|
644
|
+
sys.exit(-1)
|
|
645
|
+
mainprog(config_path)
|
|
643
646
|
|
|
644
647
|
else:
|
|
645
648
|
args = parser.parse_args()
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
|
-
# from metpy.calc import wind_direction as metpy_wind_direction,geopotential_to_height
|
|
5
|
-
# from metpy.units import units
|
|
6
|
-
|
|
7
4
|
def calc_td(temperature,relative_humidity):
|
|
8
5
|
# temperature C degree
|
|
9
6
|
# relative_humidity 0~1
|
|
@@ -86,41 +83,6 @@ def geopotential_to_height(geopotential):
|
|
|
86
83
|
`pint.Quantity`
|
|
87
84
|
Corresponding value(s) of height above sea level
|
|
88
85
|
|
|
89
|
-
Examples
|
|
90
|
-
--------
|
|
91
|
-
>>> import metpy.calc
|
|
92
|
-
>>> from metpy.units import units
|
|
93
|
-
>>> height = np.linspace(0, 10000, num=11) * units.m
|
|
94
|
-
>>> geopot = metpy.calc.height_to_geopotential(height)
|
|
95
|
-
>>> geopot
|
|
96
|
-
<Quantity([ 0. 9805.11097983 19607.1448853 29406.10316465
|
|
97
|
-
39201.98726524 48994.79863351 58784.53871501 68571.20895435
|
|
98
|
-
78354.81079527 88135.34568058 97912.81505219], 'meter ** 2 / second ** 2')>
|
|
99
|
-
>>> height = metpy.calc.geopotential_to_height(geopot)
|
|
100
|
-
>>> height
|
|
101
|
-
<Quantity([ 0. 1000. 2000. 3000. 4000. 5000. 6000. 7000. 8000.
|
|
102
|
-
9000. 10000.], 'meter')>
|
|
103
|
-
|
|
104
|
-
See Also
|
|
105
|
-
--------
|
|
106
|
-
height_to_geopotential
|
|
107
|
-
|
|
108
|
-
Notes
|
|
109
|
-
-----
|
|
110
|
-
This calculation approximates :math:`g(z)` as
|
|
111
|
-
|
|
112
|
-
.. math:: g(z) = g_0 \left( \frac{R_e}{R_e + z} \right)^2
|
|
113
|
-
|
|
114
|
-
where :math:`g_0` is standard gravity. It thereby accounts for the average effects of
|
|
115
|
-
centrifugal force on apparent gravity, but neglects latitudinal variations due to
|
|
116
|
-
centrifugal force and Earth's eccentricity.
|
|
117
|
-
|
|
118
|
-
(Prior to MetPy v0.11, this formula instead calculated :math:`g(z)` from Newton's Law of
|
|
119
|
-
Gravitation assuming a spherical Earth and no centrifugal force effects.)
|
|
120
|
-
|
|
121
|
-
.. versionchanged:: 1.0
|
|
122
|
-
Renamed ``geopot`` parameter to ``geopotential``
|
|
123
|
-
|
|
124
86
|
"""
|
|
125
87
|
Re = 6371008.7714
|
|
126
88
|
g = 9.80665
|
|
@@ -128,8 +90,6 @@ def geopotential_to_height(geopotential):
|
|
|
128
90
|
|
|
129
91
|
if __name__ == "__main__":
|
|
130
92
|
pass
|
|
131
|
-
|
|
132
|
-
# print(wind_direction(-3,5))
|
|
133
|
-
# print(metpy_wind_direction(-3*units('m/s'),5*units('m/s')))
|
|
93
|
+
|
|
134
94
|
g = 9.80665
|
|
135
95
|
print(geopotential_to_height(5884*g))
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Custom Py-ART exceptions.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import warnings
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MissingOptionalDependency(Exception):
|
|
10
|
+
""" Exception raised when a optional dependency is needed by not found. """
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class DeprecatedAttribute(DeprecationWarning):
|
|
15
|
+
""" Warning category for an attribute which has been renamed/moved. """
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DeprecatedFunctionName(DeprecationWarning):
|
|
20
|
+
""" Warning category for a function which has been renamed/moved. """
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _deprecated_alias(func, old_name, new_name):
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
A function for creating an alias to a renamed or moved function.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
func : func
|
|
32
|
+
The function which has been renamed or moved.
|
|
33
|
+
old_name, new_name : str
|
|
34
|
+
Name of the function before and after it was moved or renamed
|
|
35
|
+
(with namespace if changed).
|
|
36
|
+
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
wrapper : func
|
|
40
|
+
A wrapper version of func, which issues a DeprecatedFunctionName
|
|
41
|
+
warning when the called.
|
|
42
|
+
|
|
43
|
+
"""
|
|
44
|
+
def wrapper(*args, **kwargs):
|
|
45
|
+
warnings.warn(
|
|
46
|
+
("{0} has been deprecated and will be removed in future " +
|
|
47
|
+
"versions of Py-ART, pleases use {1}. ").format(
|
|
48
|
+
old_name, new_name), category=DeprecatedFunctionName)
|
|
49
|
+
return func(*args, **kwargs)
|
|
50
|
+
return wrapper
|