metradar 0.1.3__py3-none-any.whl → 0.1.5__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-0.1.3.dist-info → metradar-0.1.5.dist-info}/METADATA +1 -1
- {metradar-0.1.3.dist-info → metradar-0.1.5.dist-info}/RECORD +4 -12
- {metradar-0.1.3.dist-info → metradar-0.1.5.dist-info}/top_level.txt +0 -0
- metradar/construct_aws_refvpr_mainprog.py +0 -515
- metradar/construct_aws_refvpr_mainprog_cams.py +0 -310
- metradar/construct_aws_refvpr_mainprog_datan3d.py +0 -386
- metradar/construct_aws_refvpr_mainprog_swan.py +0 -306
- metradar/draw_radar_aws_jilin_new.py +0 -206
- metradar/nowcast_by_pysteps.py +0 -219
- metradar/prepare_for_radar_draw.py +0 -197
- metradar/trans_polor2grid_func.py +0 -203
- {metradar-0.1.3.dist-info → metradar-0.1.5.dist-info}/WHEEL +0 -0
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
'''
|
|
2
|
-
将雷达和自动站叠加绘图
|
|
3
|
-
朱文剑
|
|
4
|
-
'''
|
|
5
|
-
|
|
6
|
-
# %%
|
|
7
|
-
import pandas as pd
|
|
8
|
-
import warnings
|
|
9
|
-
warnings.filterwarnings('ignore')
|
|
10
|
-
|
|
11
|
-
from draw_radar_comp_func import DRAW_RADAR_OTHER,ini_params
|
|
12
|
-
from multiprocessing import cpu_count, Pool,freeze_support
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def draw_all(params):
|
|
16
|
-
# sourcepath,outpath,filename,start_lat,end_lat,start_lon,end_lon
|
|
17
|
-
# 河南北部区域
|
|
18
|
-
sourcepath = params['sourcepath']
|
|
19
|
-
outpath = params['outpath']
|
|
20
|
-
radfilename = params['radfilename']
|
|
21
|
-
slat = params['slat']
|
|
22
|
-
nlat = params['nlat']
|
|
23
|
-
wlon = params['wlon']
|
|
24
|
-
elon = params['elon']
|
|
25
|
-
|
|
26
|
-
timestr = radfilename[5:13] + '.' + radfilename[14:20]
|
|
27
|
-
|
|
28
|
-
fontname='resources/fonts/msyhbd.ttc'
|
|
29
|
-
|
|
30
|
-
# 添加中文地名
|
|
31
|
-
|
|
32
|
-
filename = 'resources/中文地理信息原始文件/吉林省所有站点信息.xls'
|
|
33
|
-
|
|
34
|
-
data_guojia = pd.read_excel(filename, sheet_name = '国家站55',header=0,skiprows=0,index_col=None,)
|
|
35
|
-
for jj in range(data_guojia.shape[0]):
|
|
36
|
-
curidx = data_guojia['站名'][jj].find('国家')
|
|
37
|
-
data_guojia['站名'][jj] = data_guojia['站名'][jj].replace( data_guojia['站名'][jj][curidx:],'')
|
|
38
|
-
data_guojia['站名'][jj] = data_guojia['站名'][jj].replace( data_guojia['组织机构'][jj],'')
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
data_guojiatianqi = pd.read_excel(filename, sheet_name = '国家天气站333',header=0,skiprows=0,index_col=None,)
|
|
42
|
-
|
|
43
|
-
for jj in range(data_guojiatianqi.shape[0]):
|
|
44
|
-
data_guojiatianqi['站名'][jj] = data_guojiatianqi['站名'][jj].replace('国家气象观测站','')
|
|
45
|
-
data_guojiatianqi['站名'][jj] = data_guojiatianqi['站名'][jj].replace( data_guojiatianqi['组织机构'][jj],'')
|
|
46
|
-
if data_guojiatianqi['站名'][jj].find('尔罗斯')>=0:
|
|
47
|
-
data_guojiatianqi['站名'][jj] = data_guojiatianqi['站名'][jj].replace('尔罗斯','')
|
|
48
|
-
|
|
49
|
-
data_quyuzhan = pd.read_excel(filename, sheet_name = '区域站1048',header=0,skiprows=0,index_col=None,)
|
|
50
|
-
for jj in range(data_quyuzhan.shape[0]):
|
|
51
|
-
data_quyuzhan['站名'][jj] = data_quyuzhan['站名'][jj].replace('气象观测站','')
|
|
52
|
-
|
|
53
|
-
data_quyuzhan['站名'][jj] = data_quyuzhan['站名'][jj].replace(data_quyuzhan['组织机构'][jj],'')
|
|
54
|
-
if data_quyuzhan['站名'][jj].find('尔罗斯')>=0:
|
|
55
|
-
data_quyuzhan['站名'][jj] = data_quyuzhan['站名'][jj].replace('尔罗斯','')
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
lat=[]
|
|
60
|
-
lon=[]
|
|
61
|
-
staname=[]
|
|
62
|
-
for ng in range(len(data_guojia['经度'])):
|
|
63
|
-
lon.append(data_guojia['经度'][ng])
|
|
64
|
-
lat.append(data_guojia['纬度'][ng])
|
|
65
|
-
staname.append(data_guojia['站名'][ng])
|
|
66
|
-
|
|
67
|
-
for ng in range(len(data_guojiatianqi['经度'])):
|
|
68
|
-
lon.append(data_guojiatianqi['经度'][ng])
|
|
69
|
-
lat.append(data_guojiatianqi['纬度'][ng])
|
|
70
|
-
staname.append(data_guojiatianqi['站名'][ng])
|
|
71
|
-
|
|
72
|
-
# for ng in range(len(data_quyuzhan['经度'])):
|
|
73
|
-
# lon.append(data_quyuzhan['经度'][ng])
|
|
74
|
-
# lat.append(data_quyuzhan['纬度'][ng])
|
|
75
|
-
# staname.append(data_quyuzhan['站名'][ng])
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
# radfilepath='/Users/wenjianzhu/Downloads/ZZHN'
|
|
80
|
-
radfilepath = sourcepath
|
|
81
|
-
params['radarfile_path'] = radfilepath
|
|
82
|
-
params['radarfile_name'] = radfilename
|
|
83
|
-
params['pic_path'] = outpath
|
|
84
|
-
params['timestr'] = timestr
|
|
85
|
-
params['slat'] = slat
|
|
86
|
-
params['nlat'] = nlat
|
|
87
|
-
params['wlon'] = wlon
|
|
88
|
-
params['elon'] = elon
|
|
89
|
-
params['fontfile'] = fontname
|
|
90
|
-
params['gis_lats'] = lat
|
|
91
|
-
params['gis_lons'] = lon
|
|
92
|
-
params['gis_name'] = staname
|
|
93
|
-
params['breplace'] = True
|
|
94
|
-
params['bdraw_crs'] = True
|
|
95
|
-
params['ref_colorfile'] = '../common/gr2_colors/default_BR_PUP2.pal'
|
|
96
|
-
params['vel_colorfile'] = '../common/gr2_colors/default_BV_PUP2.pal'
|
|
97
|
-
params['figsize_width'] = 4
|
|
98
|
-
params['fontsize_gis'] = 5
|
|
99
|
-
params['fontsize_colorbar'] = 5
|
|
100
|
-
params['fontsize_title'] = 6
|
|
101
|
-
params['mapcolor'] = [0/255,0/255,0/255]
|
|
102
|
-
params['dpi'] = 800
|
|
103
|
-
params['pic_format'] = 'jpg'
|
|
104
|
-
params['bdraw_title_ppi'] = False
|
|
105
|
-
|
|
106
|
-
# params={'radarfile_path':radfilepath,
|
|
107
|
-
# 'radarfile_name':radfilename,
|
|
108
|
-
# 'mosaicfile_path':'',
|
|
109
|
-
# 'mosaicfile_name':'',
|
|
110
|
-
# 'pic_path':outpath,
|
|
111
|
-
# 'timestr':timestr,
|
|
112
|
-
# 'aws_min_file_path':'',
|
|
113
|
-
# 'aws_min_file_name':'',
|
|
114
|
-
# 'aws_hour_file_path':'',
|
|
115
|
-
# 'aws_hour_file_name':'',
|
|
116
|
-
# 'gis_name':staname,
|
|
117
|
-
# 'gis_lats':lat,
|
|
118
|
-
# 'gis_lons':lon,
|
|
119
|
-
# 'slat':slat,
|
|
120
|
-
# 'nlat':nlat,
|
|
121
|
-
# 'wlon':wlon,
|
|
122
|
-
# 'elon':elon,
|
|
123
|
-
# 'ref_colorfile':'../common/gr2_colors/default_BR_PUP2.pal',
|
|
124
|
-
# 'vel_colorfile':'../common/gr2_colors/default_BV_PUP2.pal',
|
|
125
|
-
# 'fontfile':fontname,
|
|
126
|
-
# 'dpi':800,
|
|
127
|
-
# 'pic_format':'png',
|
|
128
|
-
# 'figsize_width':4,
|
|
129
|
-
# 'fontsize_gis':5,
|
|
130
|
-
# 'fontsize_colorbar':5,
|
|
131
|
-
# 'fontsize_title':6,
|
|
132
|
-
# 'mapcolor':[0/255,0/255,0/255],
|
|
133
|
-
# 'breplace':True, #如果图片文件已存在,是否重新绘制
|
|
134
|
-
# 'bdraw_crs':False
|
|
135
|
-
# }
|
|
136
|
-
|
|
137
|
-
_draw_radar_other = DRAW_RADAR_OTHER(params)
|
|
138
|
-
|
|
139
|
-
_draw_radar_other.read_vol_data()
|
|
140
|
-
|
|
141
|
-
# _draw_radar_other.draw_ref_alone(subdir='回波强度',tilt=0,thred=-5)
|
|
142
|
-
_draw_radar_other.draw_ref_alone(subdir='回波强度',tilt=1,thred=-5)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
# _draw_radar_other.draw_vel_alone(subdir='径向速度',tilt=0)
|
|
146
|
-
# _draw_radar_other.draw_vel_alone(subdir='径向速度',tilt=1)
|
|
147
|
-
# _draw_radar_other.draw_vel_alone(subdir='径向速度',tilt=2)
|
|
148
|
-
|
|
149
|
-
# _draw_radar_other.draw_vel_pre()
|
|
150
|
-
# _draw_radar_other.draw_vel_wind_barb()
|
|
151
|
-
# _draw_radar_other.draw_vel_wind_quiver()
|
|
152
|
-
# _draw_radar_other.draw_ref_pre()
|
|
153
|
-
# _draw_radar_other.draw_ref_pre_wind_barb()
|
|
154
|
-
|
|
155
|
-
# _draw_radar_other.get_cref_from_radar([_draw_radar_other.g_rad_lat,_draw_radar_other.g_rad_lon])
|
|
156
|
-
# _draw_radar_other.get_cref_from_mosaicfile()
|
|
157
|
-
# _draw_radar_other.get_cref_from_radar([35.6,114.0])
|
|
158
|
-
# _draw_radar_other.draw_cref_pre()
|
|
159
|
-
# _draw_radar_other.draw_cref_wind_barb()
|
|
160
|
-
# _draw_radar_other.draw_cref_wind_quiver()
|
|
161
|
-
# _draw_radar_other.draw_cref_pre_wind_barb()
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
# %%
|
|
165
|
-
import os
|
|
166
|
-
if __name__ == '__main__':
|
|
167
|
-
pass
|
|
168
|
-
freeze_support()
|
|
169
|
-
# Pool不支持跨CPU的虚拟服务器,会出现页面不足的错误提示
|
|
170
|
-
|
|
171
|
-
paramfilepath = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/绘图参数/回波强度'
|
|
172
|
-
# paramfilepath = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/绘图参数/径向速度'
|
|
173
|
-
# drawinfo = pd.read_csv(paramfilepath + os.sep + 'radardrawlist_20120612.csv',encoding='gb18030')
|
|
174
|
-
# drawinfo = pd.read_csv(paramfilepath + os.sep + 'radardrawlist_20120701.csv',encoding='gb18030')
|
|
175
|
-
# drawinfo = pd.read_csv(paramfilepath + os.sep + 'radardrawlist_20150608.csv',encoding='gb18030')
|
|
176
|
-
# drawinfo = pd.read_csv(paramfilepath + os.sep + 'radardrawlist_20170905.csv',encoding='gb18030')
|
|
177
|
-
drawinfo = pd.read_csv(paramfilepath + os.sep + 'radardrawlist_20210909.csv',encoding='gb18030')
|
|
178
|
-
# drawinfo = pd.read_csv(paramfilepath + os.sep + 'radardrawlist_20190602.csv',encoding='gb18030')
|
|
179
|
-
|
|
180
|
-
params = []
|
|
181
|
-
nums=drawinfo.shape[0]
|
|
182
|
-
# nums=1
|
|
183
|
-
for nn in range(nums):
|
|
184
|
-
pass
|
|
185
|
-
curparam=ini_params()
|
|
186
|
-
curparam['sourcepath'] = drawinfo['sourcepath'].iloc[nn]
|
|
187
|
-
curparam['outpath'] = drawinfo['outpath'].iloc[nn]
|
|
188
|
-
curparam['radfilename'] = drawinfo['filename'].iloc[nn]
|
|
189
|
-
curparam['slat'] = drawinfo['start_lat'].iloc[nn]
|
|
190
|
-
curparam['nlat'] = drawinfo['end_lat'].iloc[nn]
|
|
191
|
-
curparam['wlon'] = drawinfo['start_lon'].iloc[nn]
|
|
192
|
-
curparam['elon'] = drawinfo['end_lon'].iloc[nn]
|
|
193
|
-
# aws_min_delta_t_file_path
|
|
194
|
-
params.append(curparam)
|
|
195
|
-
|
|
196
|
-
# MAXP = int(cpu_count()*0.5)
|
|
197
|
-
MAXP=1#nums
|
|
198
|
-
pools = Pool(MAXP)
|
|
199
|
-
|
|
200
|
-
pools.map(draw_all, params)
|
|
201
|
-
pools.close()
|
|
202
|
-
pools.join()
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
metradar/nowcast_by_pysteps.py
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
#!/bin/env python
|
|
2
|
-
"""
|
|
3
|
-
Extrapolation nowcast
|
|
4
|
-
=====================
|
|
5
|
-
|
|
6
|
-
This tutorial shows how to compute and plot an extrapolation nowcast using
|
|
7
|
-
Finnish radar data.
|
|
8
|
-
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
from datetime import datetime
|
|
12
|
-
import matplotlib.pyplot as plt
|
|
13
|
-
import numpy as np
|
|
14
|
-
from pprint import pprint
|
|
15
|
-
from pysteps import io, motion, nowcasts, rcparams, verification
|
|
16
|
-
from pysteps.utils import conversion, transformation
|
|
17
|
-
from pysteps.visualization import plot_precip_field, quiver
|
|
18
|
-
import os
|
|
19
|
-
import xarray as xr
|
|
20
|
-
from draw_mosaic_new import draw_mosaic
|
|
21
|
-
from datetime import datetime, timedelta
|
|
22
|
-
import matplotlib
|
|
23
|
-
matplotlib.use('MacOSX')
|
|
24
|
-
###############################################################################
|
|
25
|
-
# Read the radar input images
|
|
26
|
-
# ---------------------------
|
|
27
|
-
#
|
|
28
|
-
# First, we will import the sequence of radar composites.
|
|
29
|
-
# You need the pysteps-data archive downloaded and the pystepsrc file
|
|
30
|
-
# configured with the data_source paths pointing to data folders.
|
|
31
|
-
|
|
32
|
-
# Selected case
|
|
33
|
-
# date = datetime.strptime("201609281600", "%Y%m%d%H%M")
|
|
34
|
-
date = datetime.strptime("202304211800", "%Y%m%d%H%M")
|
|
35
|
-
data_source = rcparams.data_sources["fmi"]
|
|
36
|
-
n_leadtimes = 12
|
|
37
|
-
|
|
38
|
-
###############################################################################
|
|
39
|
-
# Load the data from the archive
|
|
40
|
-
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
41
|
-
|
|
42
|
-
root_path = data_source["root_path"]
|
|
43
|
-
path_fmt = data_source["path_fmt"]
|
|
44
|
-
fn_pattern = data_source["fn_pattern"]
|
|
45
|
-
fn_ext = data_source["fn_ext"]
|
|
46
|
-
importer_name = data_source["importer"]
|
|
47
|
-
importer_kwargs = data_source["importer_kwargs"]
|
|
48
|
-
timestep = data_source["timestep"]
|
|
49
|
-
|
|
50
|
-
# Find the input files from the archive
|
|
51
|
-
fns = io.archive.find_by_date(
|
|
52
|
-
date, root_path, path_fmt, fn_pattern, fn_ext, timestep, num_prev_files=2
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
# Read the radar composites
|
|
56
|
-
importer = io.get_method(importer_name, "importer")
|
|
57
|
-
Z, _, metadata = io.read_timeseries(fns, importer, **importer_kwargs)
|
|
58
|
-
|
|
59
|
-
# write Z to ds
|
|
60
|
-
# set longitude and latitude coordinates
|
|
61
|
-
slat = 33
|
|
62
|
-
nlat = 37
|
|
63
|
-
wlon = 109
|
|
64
|
-
elon = 117
|
|
65
|
-
lat = np.linspace(slat,nlat,Z.shape[1])
|
|
66
|
-
lon = np.linspace(wlon,elon,Z.shape[2])
|
|
67
|
-
|
|
68
|
-
# set time coordinates
|
|
69
|
-
curtime = metadata['timestamps'][-1]
|
|
70
|
-
curtime = np.array([curtime], dtype='datetime64[m]')
|
|
71
|
-
# data = np.expand_dims(data, axis=0)
|
|
72
|
-
|
|
73
|
-
# define coordinates
|
|
74
|
-
time_coord = ('time', curtime)
|
|
75
|
-
lon_coord = ('lon', lon, {
|
|
76
|
-
'long_name':'longitude', 'units':'degrees_east', '_CoordinateAxisType':'Lon'})
|
|
77
|
-
lat_coord = ('lat', lat, {
|
|
78
|
-
'long_name':'latitude', 'units':'degrees_north', '_CoordinateAxisType':'Lat'})
|
|
79
|
-
|
|
80
|
-
# create xarray
|
|
81
|
-
varattrs = {'long_name': 'Composite Refelectivity',
|
|
82
|
-
'short_name': 'cref', 'units': 'dBZ',
|
|
83
|
-
'maxv':80,
|
|
84
|
-
'minv':0}
|
|
85
|
-
data = xr.Dataset({'cref':(['lat', 'lon'], np.flipud(Z[-1]), varattrs)},
|
|
86
|
-
coords={ 'lat':lat_coord, 'lon':lon_coord})
|
|
87
|
-
|
|
88
|
-
outpath = 'pic'
|
|
89
|
-
|
|
90
|
-
tstr = metadata['timestamps'][-1].strftime('%Y%m%d%H%M')
|
|
91
|
-
outname = '%s_obs.png'%tstr
|
|
92
|
-
dpi = 600
|
|
93
|
-
thred=10
|
|
94
|
-
# draw_mosaic(data.cref,data.lat.data,data.lon.data,slat,nlat,wlon,elon,outpath,outname,tstr,subtitle='实况',titlecolor='k',dpi=dpi,thred=thred)
|
|
95
|
-
# print(outpath + os.sep + outname + ' done!')
|
|
96
|
-
# Convert to rain rate
|
|
97
|
-
# R, metadata = conversion.to_rainrate(Z, metadata)
|
|
98
|
-
|
|
99
|
-
# # Plot the rainfall field
|
|
100
|
-
# fig1 = plt.figure(figsize=(6, 6))
|
|
101
|
-
# plot_precip_field(Z[-1, :, :], geodata=metadata)
|
|
102
|
-
# # plt.show()
|
|
103
|
-
|
|
104
|
-
# Store the last frame for plotting it later later
|
|
105
|
-
# R_ = R[-1, :, :].copy()
|
|
106
|
-
|
|
107
|
-
# Log-transform the data to unit of dBR, set the threshold to 0.1 mm/h,
|
|
108
|
-
# set the fill value to -15 dBR
|
|
109
|
-
# R, metadata = transformation.dB_transform(R, metadata, threshold=0.1, zerovalue=-15.0)
|
|
110
|
-
|
|
111
|
-
# Nicely print the metadata
|
|
112
|
-
# pprint(metadata)
|
|
113
|
-
|
|
114
|
-
###############################################################################
|
|
115
|
-
# Compute the nowcast
|
|
116
|
-
# -------------------
|
|
117
|
-
#
|
|
118
|
-
# The extrapolation nowcast is based on the estimation of the motion field,
|
|
119
|
-
# which is here performed using a local tracking approach (Lucas-Kanade).
|
|
120
|
-
# The most recent radar rainfall field is then simply advected along this motion
|
|
121
|
-
# field in oder to produce an extrapolation forecast.
|
|
122
|
-
|
|
123
|
-
# Estimate the motion field with Lucas-Kanade
|
|
124
|
-
# st = time.time()
|
|
125
|
-
oflow_method = motion.get_method("LK")
|
|
126
|
-
V = oflow_method(Z[-3:, :, :])
|
|
127
|
-
|
|
128
|
-
# Extrapolate the last radar observation
|
|
129
|
-
extrapolate = nowcasts.get_method("extrapolation")
|
|
130
|
-
# R[~np.isfinite(R)] = metadata["zerovalue"]
|
|
131
|
-
Z_f = extrapolate(Z[-1, :, :], V, n_leadtimes)
|
|
132
|
-
for nn in range(len(Z_f)):
|
|
133
|
-
fsttime = metadata['timestamps'][-1] + timedelta(minutes=10*(nn+1))
|
|
134
|
-
tstr = fsttime.strftime('%Y%m%d%H%M')
|
|
135
|
-
# set time coordinates
|
|
136
|
-
fsttime = np.array([fsttime], dtype='datetime64[m]')
|
|
137
|
-
# data = np.expand_dims(data, axis=0)
|
|
138
|
-
|
|
139
|
-
# define coordinates
|
|
140
|
-
time_coord = ('time', fsttime)
|
|
141
|
-
lon_coord = ('lon', lon, {
|
|
142
|
-
'long_name':'longitude', 'units':'degrees_east', '_CoordinateAxisType':'Lon'})
|
|
143
|
-
lat_coord = ('lat', lat, {
|
|
144
|
-
'long_name':'latitude', 'units':'degrees_north', '_CoordinateAxisType':'Lat'})
|
|
145
|
-
|
|
146
|
-
# create xarray
|
|
147
|
-
varattrs = {'long_name': 'Composite Refelectivity',
|
|
148
|
-
'short_name': 'cref', 'units': 'dBZ',
|
|
149
|
-
'maxv':80,
|
|
150
|
-
'minv':0}
|
|
151
|
-
data = xr.Dataset({'cref':(['lat', 'lon'], np.flipud(Z_f[nn]), varattrs)},
|
|
152
|
-
coords={ 'lat':lat_coord, 'lon':lon_coord})
|
|
153
|
-
|
|
154
|
-
outpath = 'pic'
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
outname = '%s_fst.png'%tstr
|
|
158
|
-
dpi = 600
|
|
159
|
-
thred=10
|
|
160
|
-
draw_mosaic(data.cref,data.lat.data,data.lon.data,slat,nlat,wlon,elon,outpath,outname,tstr,subtitle='预报',titlecolor='r',dpi=dpi,thred=thred,add_title=1,prefix_title='雷达组合反射率拼图')
|
|
161
|
-
# print(outpath + os.sep + outname + ' done!')
|
|
162
|
-
|
|
163
|
-
pass
|
|
164
|
-
# Back-transform to rain rate
|
|
165
|
-
# R_f = transformation.dB_transform(R_f, threshold=-10.0, inverse=True)[0]
|
|
166
|
-
|
|
167
|
-
# et = time.time()
|
|
168
|
-
# print("Execution time(s): ", et - st)
|
|
169
|
-
# Plot the motion field
|
|
170
|
-
# fig2 = plt.figure(figsize=(6, 6))
|
|
171
|
-
# plot_precip_field(Z_f[-1,:,:], geodata=metadata)
|
|
172
|
-
# quiver(V, geodata=metadata, step=50)
|
|
173
|
-
# plt.show()
|
|
174
|
-
|
|
175
|
-
###############################################################################
|
|
176
|
-
# Verify with FSS
|
|
177
|
-
# ---------------
|
|
178
|
-
#
|
|
179
|
-
# The fractions skill score (FSS) provides an intuitive assessment of the
|
|
180
|
-
# dependency of skill on spatial scale and intensity, which makes it an ideal
|
|
181
|
-
# skill score for high-resolution precipitation forecasts.
|
|
182
|
-
|
|
183
|
-
# Find observations in the data archive
|
|
184
|
-
fns = io.archive.find_by_date(
|
|
185
|
-
date,
|
|
186
|
-
root_path,
|
|
187
|
-
path_fmt,
|
|
188
|
-
fn_pattern,
|
|
189
|
-
fn_ext,
|
|
190
|
-
timestep,
|
|
191
|
-
num_prev_files=0,
|
|
192
|
-
num_next_files=n_leadtimes,
|
|
193
|
-
)
|
|
194
|
-
# Read the radar composites
|
|
195
|
-
Z_o, _, metadata_o = io.read_timeseries(fns, importer, **importer_kwargs)
|
|
196
|
-
# R_o, metadata_o = conversion.to_rainrate(R_o, metadata_o, 223.0, 1.53)
|
|
197
|
-
|
|
198
|
-
# Compute fractions skill score (FSS) for all lead times, a set of scales and 1 mm/h
|
|
199
|
-
fss = verification.get_method("FSS")
|
|
200
|
-
scales = [2, 4, 8, 16, 32, 64, 128]
|
|
201
|
-
thr = 5.0
|
|
202
|
-
score = []
|
|
203
|
-
for i in range(n_leadtimes):
|
|
204
|
-
score_ = []
|
|
205
|
-
for scale in scales:
|
|
206
|
-
score_.append(fss(Z_f[i, :, :], Z_o[i + 1, :, :], thr, scale))
|
|
207
|
-
score.append(score_)
|
|
208
|
-
|
|
209
|
-
# plt.figure()
|
|
210
|
-
# fig3 = plt.figure(figsize=(6, 6))
|
|
211
|
-
# x = np.arange(1, n_leadtimes + 1) * timestep
|
|
212
|
-
# plt.plot(x, score)
|
|
213
|
-
# plt.legend(scales, title="Scale [km]")
|
|
214
|
-
# plt.xlabel("Lead time [min]")
|
|
215
|
-
# plt.ylabel("FSS ( > 5 dBZ ) ")
|
|
216
|
-
# plt.title("Fractions skill score")
|
|
217
|
-
# plt.show()
|
|
218
|
-
|
|
219
|
-
# sphinx_gallery_thumbnail_number = 3
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
'''
|
|
2
|
-
prepare for radar_draw_aws.py
|
|
3
|
-
|
|
4
|
-
'''
|
|
5
|
-
|
|
6
|
-
import os
|
|
7
|
-
import sys
|
|
8
|
-
import pandas as pd
|
|
9
|
-
|
|
10
|
-
#递归查找
|
|
11
|
-
def show_files(path, all_files,allpaths):
|
|
12
|
-
# 首先遍历当前目录所有文件及文件夹
|
|
13
|
-
file_list = os.listdir(path)
|
|
14
|
-
# 准备循环判断每个元素是否是文件夹还是文件,是文件的话,把名称传入list,是文件夹的话,递归
|
|
15
|
-
for file in file_list:
|
|
16
|
-
# 利用os.path.join()方法取得路径全名,并存入cur_path变量,否则每次只能遍历一层目录
|
|
17
|
-
cur_path = os.path.join(path, file)
|
|
18
|
-
|
|
19
|
-
if file.startswith('.') or file.startswith('..'):
|
|
20
|
-
continue
|
|
21
|
-
|
|
22
|
-
# 判断是否是文件夹
|
|
23
|
-
if os.path.isdir(cur_path):
|
|
24
|
-
show_files(cur_path, all_files,allpaths)
|
|
25
|
-
else:
|
|
26
|
-
all_files.append(file)
|
|
27
|
-
allpaths.append(path)
|
|
28
|
-
|
|
29
|
-
return all_files
|
|
30
|
-
|
|
31
|
-
def mainfunc(dic_param):
|
|
32
|
-
|
|
33
|
-
allfiles = []
|
|
34
|
-
allpaths = []
|
|
35
|
-
show_files(dic_param['filepath'],allfiles,allpaths)
|
|
36
|
-
|
|
37
|
-
start_lat=[]
|
|
38
|
-
end_lat=[]
|
|
39
|
-
start_lon=[]
|
|
40
|
-
end_lon=[]
|
|
41
|
-
alloutpaths=[]
|
|
42
|
-
|
|
43
|
-
for nn in range(len(allfiles)):
|
|
44
|
-
curout = dic_param['rootout'] + os.sep + allpaths[nn].split(os.sep)[-1]
|
|
45
|
-
# print(curout)
|
|
46
|
-
|
|
47
|
-
# alloutpaths.append(curout)
|
|
48
|
-
# start_lat.append('')
|
|
49
|
-
# end_lat.append('')
|
|
50
|
-
# start_lon.append('')
|
|
51
|
-
# end_lon.append('')
|
|
52
|
-
|
|
53
|
-
alloutpaths.append(curout)
|
|
54
|
-
start_lat.append(dic_param['startlat'])
|
|
55
|
-
end_lat.append(dic_param['endlat'])
|
|
56
|
-
start_lon.append(dic_param['startlon'])
|
|
57
|
-
end_lon.append(dic_param['endlon'])
|
|
58
|
-
|
|
59
|
-
outdic = {
|
|
60
|
-
'sourcepath':allpaths,
|
|
61
|
-
'outpath':alloutpaths,
|
|
62
|
-
'filename':allfiles,
|
|
63
|
-
'start_lat':start_lat,
|
|
64
|
-
'end_lat':end_lat,
|
|
65
|
-
'start_lon':start_lon,
|
|
66
|
-
'end_lon':end_lon,
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
outpd = pd.DataFrame(outdic)
|
|
70
|
-
newpd = outpd.sort_values(by='filename')
|
|
71
|
-
newpd.to_csv(dic_param['outname'],encoding='gb18030')
|
|
72
|
-
print(dic_param['outname'] + ' done!')
|
|
73
|
-
|
|
74
|
-
if __name__ == "__main__":
|
|
75
|
-
|
|
76
|
-
# dic_param={}
|
|
77
|
-
# dic_param['filepath'] = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/ar2v/20190602-辽源'
|
|
78
|
-
# dic_param['rootout']='/Users/wenjianzhu/Downloads/雷达数据-王婷婷/pic'
|
|
79
|
-
# dic_param['outname'] = 'radardrawlist_20190602.csv'
|
|
80
|
-
|
|
81
|
-
# dic_param['startlon'] = 124.2
|
|
82
|
-
# dic_param['endlon'] = 126
|
|
83
|
-
# dic_param['startlat'] = 43.5
|
|
84
|
-
# dic_param['endlat'] = 44.4
|
|
85
|
-
|
|
86
|
-
# mainfunc(dic_param=dic_param)
|
|
87
|
-
|
|
88
|
-
type = '强度'
|
|
89
|
-
|
|
90
|
-
if type == '强度':
|
|
91
|
-
outpath = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/绘图参数/回波强度'
|
|
92
|
-
elif type == '速度':
|
|
93
|
-
outpath = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/绘图参数/径向速度'
|
|
94
|
-
|
|
95
|
-
if not os.path.exists(outpath):
|
|
96
|
-
os.makedirs(outpath)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
#==================================================================================
|
|
100
|
-
# dic_param={}
|
|
101
|
-
# dic_param['filepath'] = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/ar2v/20120612-白城'
|
|
102
|
-
# dic_param['rootout']='/Users/wenjianzhu/Downloads/雷达数据-王婷婷/pic'
|
|
103
|
-
# dic_param['outname'] = outpath + os.sep + 'radardrawlist_20120612.csv'
|
|
104
|
-
|
|
105
|
-
# if type == '强度':
|
|
106
|
-
# dic_param['startlon'] = 122.37
|
|
107
|
-
# dic_param['endlon'] = 122.97
|
|
108
|
-
# dic_param['startlat'] = 45.34
|
|
109
|
-
# dic_param['endlat'] = 45.89
|
|
110
|
-
# elif type == '速度':
|
|
111
|
-
# dic_param['startlon'] = 122.6
|
|
112
|
-
# dic_param['endlon'] = 122.83
|
|
113
|
-
# dic_param['startlat'] = 45.58
|
|
114
|
-
# dic_param['endlat'] = 45.76
|
|
115
|
-
|
|
116
|
-
# mainfunc(dic_param=dic_param)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
# dic_param={}
|
|
120
|
-
# dic_param['filepath'] = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/ar2v/20120701-白城'
|
|
121
|
-
# dic_param['rootout']='/Users/wenjianzhu/Downloads/雷达数据-王婷婷/pic'
|
|
122
|
-
# dic_param['outname'] = outpath + os.sep + 'radardrawlist_20120701.csv'
|
|
123
|
-
|
|
124
|
-
# if type == '强度':
|
|
125
|
-
# dic_param['startlon'] = 123.1
|
|
126
|
-
# dic_param['endlon'] = 124.32
|
|
127
|
-
# dic_param['startlat'] = 45.11
|
|
128
|
-
# dic_param['endlat'] = 45.97
|
|
129
|
-
# elif type == '速度':
|
|
130
|
-
# dic_param['startlon'] = 123.65
|
|
131
|
-
# dic_param['endlon'] = 124.32
|
|
132
|
-
# dic_param['startlat'] = 45.45
|
|
133
|
-
# dic_param['endlat'] = 45.97
|
|
134
|
-
|
|
135
|
-
# mainfunc(dic_param=dic_param)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
# dic_param={}
|
|
139
|
-
# dic_param['filepath'] = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/ar2v/20150608-白城'
|
|
140
|
-
# dic_param['rootout']='/Users/wenjianzhu/Downloads/雷达数据-王婷婷/pic'
|
|
141
|
-
# dic_param['outname'] = outpath + os.sep + 'radardrawlist_20150608.csv'
|
|
142
|
-
|
|
143
|
-
# if type == '强度':
|
|
144
|
-
# dic_param['startlon'] = 122.3
|
|
145
|
-
# dic_param['endlon'] = 124.3
|
|
146
|
-
# dic_param['startlat'] = 44.2
|
|
147
|
-
# dic_param['endlat'] = 45.5
|
|
148
|
-
# elif type == '速度':
|
|
149
|
-
# dic_param['startlon'] = 122.7
|
|
150
|
-
# dic_param['endlon'] = 123.5
|
|
151
|
-
# dic_param['startlat'] = 44.3
|
|
152
|
-
# dic_param['endlat'] = 44.95
|
|
153
|
-
|
|
154
|
-
# mainfunc(dic_param=dic_param)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# dic_param={}
|
|
158
|
-
# dic_param['filepath'] = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/ar2v/20170905-松原'
|
|
159
|
-
# dic_param['rootout']='/Users/wenjianzhu/Downloads/雷达数据-王婷婷/pic'
|
|
160
|
-
# dic_param['outname'] = outpath + os.sep + 'radardrawlist_20170905.csv'
|
|
161
|
-
|
|
162
|
-
# if type == '强度':
|
|
163
|
-
# dic_param['startlon'] = 125.2
|
|
164
|
-
# dic_param['endlon'] = 126.2
|
|
165
|
-
# dic_param['startlat'] = 44.9
|
|
166
|
-
# dic_param['endlat'] = 45.7
|
|
167
|
-
# elif type == '速度':
|
|
168
|
-
# dic_param['startlon'] = 125.4
|
|
169
|
-
# dic_param['endlon'] = 126.2
|
|
170
|
-
# dic_param['startlat'] = 45
|
|
171
|
-
# dic_param['endlat'] = 45.5
|
|
172
|
-
|
|
173
|
-
# mainfunc(dic_param=dic_param)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
dic_param={}
|
|
177
|
-
dic_param['filepath'] = '/Users/wenjianzhu/Downloads/雷达数据-王婷婷/ar2v/20210909-长春'
|
|
178
|
-
dic_param['rootout']='/Users/wenjianzhu/Downloads/雷达数据-王婷婷/pic'
|
|
179
|
-
dic_param['outname'] = outpath + os.sep + 'radardrawlist_20210909.csv'
|
|
180
|
-
|
|
181
|
-
if type == '强度':
|
|
182
|
-
# dic_param['startlon'] = 124.5
|
|
183
|
-
# dic_param['endlon'] = 125.8
|
|
184
|
-
# dic_param['startlat'] = 43.3
|
|
185
|
-
# dic_param['endlat'] = 44.2
|
|
186
|
-
|
|
187
|
-
dic_param['startlon'] = 124.9
|
|
188
|
-
dic_param['endlon'] = 125.6
|
|
189
|
-
dic_param['startlat'] = 43.6
|
|
190
|
-
dic_param['endlat'] = 44.1
|
|
191
|
-
elif type == '速度':
|
|
192
|
-
dic_param['startlon'] = 124.9
|
|
193
|
-
dic_param['endlon'] = 125.6
|
|
194
|
-
dic_param['startlat'] = 43.6
|
|
195
|
-
dic_param['endlat'] = 44.1
|
|
196
|
-
|
|
197
|
-
mainfunc(dic_param=dic_param)
|