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
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
|
|
2
|
+
# _*_ coding: utf-8 _*_
|
|
3
|
+
|
|
4
|
+
# 利用pysteps进行临近预报的框架程序
|
|
5
|
+
|
|
6
|
+
import matplotlib
|
|
7
|
+
matplotlib.use('agg')
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
import matplotlib.pyplot as plt
|
|
10
|
+
import numpy as np
|
|
11
|
+
from pprint import pprint
|
|
12
|
+
from pysteps import io, motion, nowcasts, rcparams, verification
|
|
13
|
+
from pysteps.utils import conversion, transformation
|
|
14
|
+
from pysteps.visualization import plot_precip_field, quiver
|
|
15
|
+
import os
|
|
16
|
+
import xarray as xr
|
|
17
|
+
from metradar.graph.draw_latlon_func import draw_mosaic
|
|
18
|
+
from datetime import datetime, timedelta
|
|
19
|
+
|
|
20
|
+
###############################################################################
|
|
21
|
+
# Read the radar input images
|
|
22
|
+
# ---------------------------
|
|
23
|
+
#
|
|
24
|
+
# First, we will import the sequence of radar composites.
|
|
25
|
+
# You need the pysteps-data archive downloaded and the pystepsrc file
|
|
26
|
+
# configured with the data_source paths pointing to data folders.
|
|
27
|
+
|
|
28
|
+
# Selected case
|
|
29
|
+
|
|
30
|
+
date = datetime.strptime("202506091100", "%Y%m%d%H%M")
|
|
31
|
+
data_source = rcparams.data_sources["fmi"]
|
|
32
|
+
n_leadtimes = 12
|
|
33
|
+
|
|
34
|
+
###############################################################################
|
|
35
|
+
# Load the data from the archive
|
|
36
|
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
37
|
+
|
|
38
|
+
root_path = data_source["root_path"]
|
|
39
|
+
path_fmt = data_source["path_fmt"]
|
|
40
|
+
fn_pattern = data_source["fn_pattern"]
|
|
41
|
+
fn_ext = data_source["fn_ext"]
|
|
42
|
+
importer_name = data_source["importer"]
|
|
43
|
+
importer_kwargs = data_source["importer_kwargs"]
|
|
44
|
+
timestep = data_source["timestep"]
|
|
45
|
+
|
|
46
|
+
# Find the input files from the archive
|
|
47
|
+
fns = io.archive.find_by_date(
|
|
48
|
+
date, root_path, path_fmt, fn_pattern, fn_ext, timestep, num_prev_files=2
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Read the radar composites
|
|
52
|
+
importer = io.get_method(importer_name, "importer")
|
|
53
|
+
Z, _, metadata = io.read_timeseries(fns, importer, **importer_kwargs)
|
|
54
|
+
|
|
55
|
+
# write Z to ds
|
|
56
|
+
# set longitude and latitude coordinates
|
|
57
|
+
slat = 35.5
|
|
58
|
+
nlat = 39.5
|
|
59
|
+
wlon = 115
|
|
60
|
+
elon = 120
|
|
61
|
+
lat = np.linspace(slat,nlat,Z.shape[1])
|
|
62
|
+
lon = np.linspace(wlon,elon,Z.shape[2])
|
|
63
|
+
|
|
64
|
+
# set time coordinates
|
|
65
|
+
curtime = metadata['timestamps'][-1]
|
|
66
|
+
curtime = np.array([curtime], dtype='datetime64[m]')
|
|
67
|
+
# data = np.expand_dims(data, axis=0)
|
|
68
|
+
|
|
69
|
+
# define coordinates
|
|
70
|
+
time_coord = ('time', curtime)
|
|
71
|
+
lon_coord = ('lon', lon, {
|
|
72
|
+
'long_name':'longitude', 'units':'degrees_east', '_CoordinateAxisType':'Lon'})
|
|
73
|
+
lat_coord = ('lat', lat, {
|
|
74
|
+
'long_name':'latitude', 'units':'degrees_north', '_CoordinateAxisType':'Lat'})
|
|
75
|
+
|
|
76
|
+
# create xarray
|
|
77
|
+
varattrs = {'long_name': 'Composite Refelectivity',
|
|
78
|
+
'short_name': 'cref', 'units': 'dBZ',
|
|
79
|
+
'maxv':80,
|
|
80
|
+
'minv':0}
|
|
81
|
+
data = xr.Dataset({'cref':(['lat', 'lon'], np.flipud(Z[-1]), varattrs)},
|
|
82
|
+
coords={ 'lat':lat_coord, 'lon':lon_coord})
|
|
83
|
+
|
|
84
|
+
outpath = '/mnt/e/metradar_test/pic/pysteps_nowcast/'
|
|
85
|
+
|
|
86
|
+
tstr = metadata['timestamps'][-1].strftime('%Y%m%d%H%M')
|
|
87
|
+
outname = '%s_obs.png'%tstr
|
|
88
|
+
dpi = 600
|
|
89
|
+
thred=10
|
|
90
|
+
draw_mosaic(data.cref,data.lat.data,data.lon.data,slat,nlat,wlon,elon,outpath,outname,tstr,subtitle='实况',titlecolor='k',dpi=dpi,thred=thred)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# print(outpath + os.sep + outname + ' done!')
|
|
95
|
+
# Convert to rain rate
|
|
96
|
+
# R, metadata = conversion.to_rainrate(Z, metadata)
|
|
97
|
+
|
|
98
|
+
# # Plot the rainfall field
|
|
99
|
+
# fig1 = plt.figure(figsize=(6, 6))
|
|
100
|
+
# plot_precip_field(Z[-1, :, :], geodata=metadata)
|
|
101
|
+
# # plt.show()
|
|
102
|
+
|
|
103
|
+
# Store the last frame for plotting it later later
|
|
104
|
+
# R_ = R[-1, :, :].copy()
|
|
105
|
+
|
|
106
|
+
# Log-transform the data to unit of dBR, set the threshold to 0.1 mm/h,
|
|
107
|
+
# set the fill value to -15 dBR
|
|
108
|
+
# R, metadata = transformation.dB_transform(R, metadata, threshold=0.1, zerovalue=-15.0)
|
|
109
|
+
|
|
110
|
+
# Nicely print the metadata
|
|
111
|
+
# pprint(metadata)
|
|
112
|
+
|
|
113
|
+
###############################################################################
|
|
114
|
+
# Compute the nowcast
|
|
115
|
+
# -------------------
|
|
116
|
+
#
|
|
117
|
+
# The extrapolation nowcast is based on the estimation of the motion field,
|
|
118
|
+
# which is here performed using a local tracking approach (Lucas-Kanade).
|
|
119
|
+
# The most recent radar rainfall field is then simply advected along this motion
|
|
120
|
+
# field in oder to produce an extrapolation forecast.
|
|
121
|
+
|
|
122
|
+
# Estimate the motion field with Lucas-Kanade
|
|
123
|
+
# st = time.time()
|
|
124
|
+
oflow_method = motion.get_method("LK")
|
|
125
|
+
V = oflow_method(Z[-3:, :, :])
|
|
126
|
+
|
|
127
|
+
# Extrapolate the last radar observation
|
|
128
|
+
extrapolate = nowcasts.get_method("extrapolation")
|
|
129
|
+
# R[~np.isfinite(R)] = metadata["zerovalue"]
|
|
130
|
+
Z_f = extrapolate(Z[-1, :, :], V, n_leadtimes)
|
|
131
|
+
for nn in range(len(Z_f)):
|
|
132
|
+
fsttime = metadata['timestamps'][-1] + timedelta(minutes=10*(nn+1))
|
|
133
|
+
tstr = fsttime.strftime('%Y%m%d%H%M')
|
|
134
|
+
# set time coordinates
|
|
135
|
+
fsttime = np.array([fsttime], dtype='datetime64[m]')
|
|
136
|
+
# data = np.expand_dims(data, axis=0)
|
|
137
|
+
|
|
138
|
+
# define coordinates
|
|
139
|
+
time_coord = ('time', fsttime)
|
|
140
|
+
lon_coord = ('lon', lon, {
|
|
141
|
+
'long_name':'longitude', 'units':'degrees_east', '_CoordinateAxisType':'Lon'})
|
|
142
|
+
lat_coord = ('lat', lat, {
|
|
143
|
+
'long_name':'latitude', 'units':'degrees_north', '_CoordinateAxisType':'Lat'})
|
|
144
|
+
|
|
145
|
+
# create xarray
|
|
146
|
+
varattrs = {'long_name': 'Composite Refelectivity',
|
|
147
|
+
'short_name': 'cref', 'units': 'dBZ',
|
|
148
|
+
'maxv':80,
|
|
149
|
+
'minv':0}
|
|
150
|
+
data = xr.Dataset({'cref':(['lat', 'lon'], np.flipud(Z_f[nn]), varattrs)},
|
|
151
|
+
coords={ 'lat':lat_coord, 'lon':lon_coord})
|
|
152
|
+
|
|
153
|
+
outname = '%s_fst.png'%tstr
|
|
154
|
+
dpi = 600
|
|
155
|
+
thred=10
|
|
156
|
+
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='雷达组合反射率拼图')
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# Back-transform to rain rate
|
|
160
|
+
# R_f = transformation.dB_transform(R_f, threshold=-10.0, inverse=True)[0]
|
|
161
|
+
|
|
162
|
+
# et = time.time()
|
|
163
|
+
# print("Execution time(s): ", et - st)
|
|
164
|
+
# Plot the motion field
|
|
165
|
+
# fig2 = plt.figure(figsize=(6, 6))
|
|
166
|
+
# plot_precip_field(Z_f[-1,:,:], geodata=metadata)
|
|
167
|
+
# quiver(V, geodata=metadata, step=50)
|
|
168
|
+
# plt.show()
|
|
169
|
+
|
|
170
|
+
###############################################################################
|
|
171
|
+
# Verify with FSS
|
|
172
|
+
# ---------------
|
|
173
|
+
#
|
|
174
|
+
# The fractions skill score (FSS) provides an intuitive assessment of the
|
|
175
|
+
# dependency of skill on spatial scale and intensity, which makes it an ideal
|
|
176
|
+
# skill score for high-resolution precipitation forecasts.
|
|
177
|
+
|
|
178
|
+
# Find observations in the data archive
|
|
179
|
+
fns = io.archive.find_by_date(
|
|
180
|
+
date,
|
|
181
|
+
root_path,
|
|
182
|
+
path_fmt,
|
|
183
|
+
fn_pattern,
|
|
184
|
+
fn_ext,
|
|
185
|
+
timestep,
|
|
186
|
+
num_prev_files=0,
|
|
187
|
+
num_next_files=n_leadtimes,
|
|
188
|
+
)
|
|
189
|
+
# Read the radar composites
|
|
190
|
+
Z_o, _, metadata_o = io.read_timeseries(fns, importer, **importer_kwargs)
|
|
191
|
+
# R_o, metadata_o = conversion.to_rainrate(R_o, metadata_o, 223.0, 1.53)
|
|
192
|
+
|
|
193
|
+
# Compute fractions skill score (FSS) for all lead times, a set of scales and 1 mm/h
|
|
194
|
+
fss = verification.get_method("FSS")
|
|
195
|
+
scales = [2, 4, 8, 16, 32, 64, 128]
|
|
196
|
+
thr = 5.0
|
|
197
|
+
score = []
|
|
198
|
+
for i in range(n_leadtimes):
|
|
199
|
+
score_ = []
|
|
200
|
+
for scale in scales:
|
|
201
|
+
score_.append(fss(Z_f[i, :, :], Z_o[i + 1, :, :], thr, scale))
|
|
202
|
+
score.append(score_)
|
|
203
|
+
|
|
204
|
+
# plt.figure()
|
|
205
|
+
# fig3 = plt.figure(figsize=(6, 6))
|
|
206
|
+
# x = np.arange(1, n_leadtimes + 1) * timestep
|
|
207
|
+
# plt.plot(x, score)
|
|
208
|
+
# plt.legend(scales, title="Scale [km]")
|
|
209
|
+
# plt.xlabel("Lead time [min]")
|
|
210
|
+
# plt.ylabel("FSS ( > 5 dBZ ) ")
|
|
211
|
+
# plt.title("Fractions skill score")
|
|
212
|
+
# plt.show()
|
|
213
|
+
|
|
214
|
+
# sphinx_gallery_thumbnail_number = 3
|
|
@@ -4,13 +4,16 @@
|
|
|
4
4
|
'''
|
|
5
5
|
|
|
6
6
|
# %%
|
|
7
|
-
|
|
7
|
+
import matplotlib
|
|
8
|
+
matplotlib.use('Agg') # 关键:禁用交互式后端
|
|
9
|
+
from metradar.io.pgmb_io import pgmb_write
|
|
8
10
|
import os
|
|
9
|
-
from
|
|
11
|
+
from metradar.io.read_new_mosaic_func import decode_mosaic
|
|
10
12
|
import xarray as xr
|
|
11
13
|
import numpy as np
|
|
12
14
|
import gzip
|
|
13
15
|
|
|
16
|
+
|
|
14
17
|
def zip_file(path, new_path):
|
|
15
18
|
with open(new_path, 'wb') as wf:
|
|
16
19
|
with open(path, 'rb') as rf:
|
|
@@ -20,36 +23,35 @@ def zip_file(path, new_path):
|
|
|
20
23
|
wf.write(data_comp)
|
|
21
24
|
|
|
22
25
|
|
|
23
|
-
filepath = '/
|
|
26
|
+
filepath = '/mnt/e/metradar_test/pysteps_data/mosaic_bin/2025/07/02/RADA_L3_MST_CREF_QC/'
|
|
24
27
|
for filename in os.listdir(filepath):
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
data = decode_mosaic(filepath,filename)
|
|
27
30
|
# filename = 'ACHN.CREF000.20230421.180009.nc'
|
|
28
|
-
obstimestr = filename.split('
|
|
29
|
-
outname =
|
|
30
|
-
outpath = '/
|
|
31
|
+
obstimestr = filename.split('_')[9]+filename.split('_')[10][0:4].split('.')[0]
|
|
32
|
+
outname = obstimestr + '_fmi.radar.composite.lowest_FIN_SUOMI1.pgm'
|
|
33
|
+
outpath = '/mnt/e/metradar_test/pysteps_data/radar/fmi/%s'%filename.split('_')[9]
|
|
31
34
|
if not os.path.exists(outpath):
|
|
32
35
|
os.makedirs(outpath)
|
|
33
36
|
|
|
34
37
|
file_name = outpath + os.sep + outname
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
data = org_data.sel(lat=slice(33, 37), lon=slice(109, 117))
|
|
39
|
+
data = data.sel(lat=slice(33, 37), lon=slice(109, 117))
|
|
38
40
|
|
|
39
|
-
width = data.
|
|
40
|
-
height = data.
|
|
41
|
+
width = data.CREF.shape[1]
|
|
42
|
+
height = data.CREF.shape[0]
|
|
41
43
|
maxval = 255
|
|
42
|
-
gray = data.
|
|
44
|
+
gray = data.CREF*2+66
|
|
43
45
|
|
|
44
46
|
aa = np.isnan(gray.data)
|
|
45
47
|
gray.data[aa]=255
|
|
46
48
|
cref = np.flipud(gray.data.astype(np.uint8))
|
|
47
49
|
params={}
|
|
48
50
|
params['obstimestr'] = obstimestr
|
|
49
|
-
params['left_lon'] =
|
|
50
|
-
params['right_lon'] =
|
|
51
|
-
params['bottom_lat'] =
|
|
52
|
-
params['upper_lat'] =
|
|
51
|
+
params['left_lon'] = 113
|
|
52
|
+
params['right_lon'] = 118
|
|
53
|
+
params['bottom_lat'] = 37
|
|
54
|
+
params['upper_lat'] = 41
|
|
53
55
|
|
|
54
56
|
pgmb_write ( file_name, params, width, height, maxval, cref )
|
|
55
57
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
;定量降水估测程序配置文件
|
|
2
|
+
;联系人:朱文剑 zhuwj@cma.gov.cn
|
|
3
|
+
;请不要使用txt文本进行编辑,否则会导致配置文件读取出错,推荐使用notepad++进行编辑
|
|
4
|
+
|
|
5
|
+
[COMMON]
|
|
6
|
+
;程序运行模式,0为实时模式;
|
|
7
|
+
;1为历史模式,对小时进行累计,关键字段ACC_HOURS;
|
|
8
|
+
;2也为历史模式,不过是输出分钟累积,关键字段ACC_MINUTES
|
|
9
|
+
RUN_MODE=2
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
;输出路径设置
|
|
13
|
+
[PATH_SETTING]
|
|
14
|
+
;根目录
|
|
15
|
+
;ROOT_PATH=/Users/wenjianzhu/Downloads/qpe_data
|
|
16
|
+
ROOT_PATH=/mnt/e/metradar_test/qpe
|
|
17
|
+
|
|
18
|
+
;雷达基数据存储路径,相对于根目录的路径, 路径下直接就是按站号存储的数据了
|
|
19
|
+
BASEDATA_PATH=radarbase
|
|
20
|
+
;PATH_RR 雨强文件存储路径,,相对于根目录,这是中间产品
|
|
21
|
+
PATH_RR=rain_rate
|
|
22
|
+
;QPE单站产品存储路径,相对于根目录,这是中间产品
|
|
23
|
+
PATH_QPE=out_qpe
|
|
24
|
+
;QPE拼图临时文件存储路径,,相对于根目录,这是中间产品
|
|
25
|
+
PATH_TMP=tmp
|
|
26
|
+
;QPE拼图产品存储路径,,相对于根目录,这是最终产品
|
|
27
|
+
PATH_QPE_MOSAIC=qpe_mosaic
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
;参与QPE的站点,用半角逗号分割,也是下载程序要用的参数
|
|
32
|
+
[RADAR_SITES]
|
|
33
|
+
RADARS=Z9941,Z9970,Z9971,Z9973,Z9974,ZX001,ZX201,ZX301,ZX701
|
|
34
|
+
|
|
35
|
+
;查询间隔-秒
|
|
36
|
+
[QUIRY_SETTING]
|
|
37
|
+
QUIRY_STEP=20
|
|
38
|
+
;查询最近多少分钟的数据,单位为分钟
|
|
39
|
+
QUIRY_RANGE=60
|
|
40
|
+
|
|
41
|
+
;数据保存时时长-小时
|
|
42
|
+
[DATA_SAVE_SETTING]
|
|
43
|
+
DATA_SAVE_HOURS=48
|
|
44
|
+
|
|
45
|
+
;天擎_API接口设置
|
|
46
|
+
[DAAS_API_SETTING]
|
|
47
|
+
RADAR_API=getRadaFileByTimeRangeAndStaId
|
|
48
|
+
;RADA_L2_ELEV_ST (逐仰角流数据) RADA_L2_FMT (新格式基数据)
|
|
49
|
+
DATA_CODE=RADA_L2_FMT
|
|
50
|
+
ELEMENTS=FILE_NAME
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
;其他计算参数
|
|
54
|
+
[PARAMS]
|
|
55
|
+
;单站数据转成格点后,x方向的格点数,y方向的格点数以及分辨率(米),一般不建议修改
|
|
56
|
+
GRID_XNUM=701
|
|
57
|
+
GRID_YNUM=701
|
|
58
|
+
GRID_RESO=500
|
|
59
|
+
|
|
60
|
+
;QPE拼图的格点分辨率,单位度
|
|
61
|
+
MOSAIC_RESO=0.005
|
|
62
|
+
|
|
63
|
+
;并行计算时,采用的cpu占总cpu资源的比例,0~1
|
|
64
|
+
CPU_RATE=0.6
|
|
65
|
+
|
|
66
|
+
;累计时段,单位:小时,用,分隔()半角
|
|
67
|
+
ACC_HOURS=1,3,6
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
;南纬,度
|
|
71
|
+
SOUTH_LAT=32.2
|
|
72
|
+
;北纬,度
|
|
73
|
+
NORTH_LAT=39.6
|
|
74
|
+
;西经,度
|
|
75
|
+
WEST_LON=96
|
|
76
|
+
;东经,度
|
|
77
|
+
EAST_LON=104
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
;拼图产品的时间间隔,分钟,建议设置为6分钟
|
|
81
|
+
MOSAIC_STEP=10
|
|
82
|
+
|
|
83
|
+
;每次循环处理时,重新计算过去多少分钟内的拼图,请设置为大于10分钟,建议设置为15或20
|
|
84
|
+
REDO_MINS=30
|
|
85
|
+
|
|
86
|
+
;绘图相关设置,存储为png格式
|
|
87
|
+
[GRAPH]
|
|
88
|
+
;图片存储路径,相对于根目录
|
|
89
|
+
PIC_PATH=pic
|
|
90
|
+
;图片分辨率,单位dpi,不建议太高,太高会降低出图效率,增加服务器负担
|
|
91
|
+
PIC_DPI=150
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
source ~/.bashrc
|
|
3
|
+
conda activate radar
|
|
4
|
+
cd /home/wjzhu/OneDrive/PythonCode/MyWork/MyProject/radar_qpe_v1
|
|
5
|
+
nohup python monitor_process_s1.py > myout1.file 2>&1 &
|
|
6
|
+
nohup python s2_pre_process_single_radar.py > myout2.file 2>&1 &
|
|
7
|
+
nohup python s3_trans_rainrate_to_qpe.py > myout3.file 2>&1 &
|
|
8
|
+
nohup python s4_mosaic_qpe.py > myout4.file 2>&1 &
|
|
9
|
+
nohup python s5_draw_qpe_mosaic.py > myout5.file 2>&1 &
|
|
10
|
+
echo start all!
|
|
11
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# _*_ coding: utf-8 _*_
|
|
2
|
+
|
|
3
|
+
'''
|
|
4
|
+
|
|
5
|
+
从单个基数据文件计算雨强
|
|
6
|
+
|
|
7
|
+
'''
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import pyart
|
|
11
|
+
import os
|
|
12
|
+
import numpy as np
|
|
13
|
+
|
|
14
|
+
from metradar.io.decode_fmt_pyart import read_cnrad_fmt
|
|
15
|
+
import datetime
|
|
16
|
+
|
|
17
|
+
def get_rainrate(inputfilepath,
|
|
18
|
+
inputfilename,
|
|
19
|
+
outpath,
|
|
20
|
+
outname,
|
|
21
|
+
GRID_XNUM = 701,
|
|
22
|
+
GRID_YNUM = 701,
|
|
23
|
+
GRID_RESO = 1000
|
|
24
|
+
):
|
|
25
|
+
|
|
26
|
+
#降水产品格点设置
|
|
27
|
+
# GRID_XNUM = 701 #X方向格点数
|
|
28
|
+
# GRID_YNUM = 701 #Y方向格点数
|
|
29
|
+
# GRID_RESO = 1000 #网格分辨率,米
|
|
30
|
+
|
|
31
|
+
GRID_SHAPE = (1,GRID_XNUM, GRID_YNUM)
|
|
32
|
+
GRID_LIMITS = ((GRID_RESO, GRID_RESO), (-1000*(GRID_XNUM-1)/2, 1000*(GRID_XNUM-1)/2), (-1000*(GRID_XNUM-1)/2, 1000*(GRID_XNUM-1)/2))
|
|
33
|
+
|
|
34
|
+
# radar = standard_data_to_pyart(f)
|
|
35
|
+
try:
|
|
36
|
+
radar = read_cnrad_fmt(inputfilepath + os.sep + inputfilename)
|
|
37
|
+
except:
|
|
38
|
+
print(inputfilepath + os.sep + inputfilename + ' read error!')
|
|
39
|
+
|
|
40
|
+
# 对于部分雷达,必须添加下面两行,要不然会报错
|
|
41
|
+
radar.nrays = radar.fields['reflectivity']['data'].shape[0]
|
|
42
|
+
radar.ngates = radar.fields['reflectivity']['data'].shape[1]
|
|
43
|
+
|
|
44
|
+
# rad_lon = radar.longitude['data']
|
|
45
|
+
# rad_lat = radar.latitude['data']
|
|
46
|
+
# rad_alti = radar.altitude['data']
|
|
47
|
+
# rad_name = radar.metadata['instrument_name']
|
|
48
|
+
|
|
49
|
+
rain = pyart.retrieve.est_rain_rate_z(radar)
|
|
50
|
+
radar.add_field('radar_estimated_rain_rate',rain)
|
|
51
|
+
# rfd = radar.fields['radar_estimated_rain_rate']['data']
|
|
52
|
+
# qpe = rfd[radar.get_slice(0)]
|
|
53
|
+
|
|
54
|
+
grid = pyart.map.grid_from_radars(
|
|
55
|
+
(radar,),
|
|
56
|
+
grid_shape=GRID_SHAPE,
|
|
57
|
+
grid_limits=GRID_LIMITS,
|
|
58
|
+
fields=['radar_estimated_rain_rate'])
|
|
59
|
+
grid.fields['radar_estimated_rain_rate']['_FillValue'] = 0
|
|
60
|
+
|
|
61
|
+
#输出雨强文件
|
|
62
|
+
|
|
63
|
+
# outname = filename.replace('.bz2','_rr.nc')
|
|
64
|
+
pyart.io.write_grid(outpath + os.sep + outname + '.lock',grid)
|
|
65
|
+
os.rename(outpath + os.sep + outname + '.lock',outpath + os.sep + outname)
|
|
66
|
+
print('%s done!'%outname)
|
|
67
|
+
return True
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
|
|
72
|
+
inputfilepath = '/data3/zwj/qpe_test/data/radarbase/Z9453'
|
|
73
|
+
outpath = '/data3/zwj/qpe_test/data/rain_rate/Z9453'
|
|
74
|
+
inputfilename = 'Z_RADR_I_Z9453_20210509105446_O_DOR_CC_CAP_FMT.bin.bz2'
|
|
75
|
+
|
|
76
|
+
outname = inputfilename.replace('.bz2','_rr.nc')
|
|
77
|
+
get_rainrate(inputfilepath = inputfilepath,
|
|
78
|
+
inputfilename = inputfilename,
|
|
79
|
+
outpath = '/data3/zwj/qpe_test/data/rain_rate/Z9453',
|
|
80
|
+
outname = outname)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
;定量降水估测程序配置文件
|
|
2
|
+
;联系人:朱文剑 zhuwj@cma.gov.cn
|
|
3
|
+
;请不要使用txt文本进行编辑,否则会导致配置文件读取出错,推荐使用notepad++进行编辑
|
|
4
|
+
|
|
5
|
+
[COMMON]
|
|
6
|
+
;程序运行模式,0为实时模式,1为历史模式
|
|
7
|
+
RUN_MODE=0
|
|
8
|
+
|
|
9
|
+
;输出路径设置
|
|
10
|
+
[PATH_SETTING]
|
|
11
|
+
;根目录
|
|
12
|
+
ROOT_PATH=/mnt/e/metradar_test/qpe
|
|
13
|
+
|
|
14
|
+
;雷达基数据存储路径,相对于根目录的路径, 路径下直接就是按站号存储的数据了
|
|
15
|
+
BASEDATA_PATH=radarbase
|
|
16
|
+
;PATH_RR 雨强文件存储路径,,相对于根目录,这是中间产品
|
|
17
|
+
PATH_RR=rain_rate
|
|
18
|
+
;QPE单站产品存储路径,相对于根目录,这是中间产品
|
|
19
|
+
PATH_QPE=out_qpe
|
|
20
|
+
;QPE拼图临时文件存储路径,,相对于根目录,这是中间产品
|
|
21
|
+
PATH_TMP=tmp
|
|
22
|
+
;QPE拼图产品存储路径,,相对于根目录,这是最终产品
|
|
23
|
+
PATH_QPE_MOSAIC=qpe_mosaic
|
|
24
|
+
|
|
25
|
+
RADAR_SITES_FILE=/home/wjzhu/OneDrive/PythonCode/MyWork/metradar/resources/stations/radars.csv
|
|
26
|
+
|
|
27
|
+
;参与QPE的站点,用半角逗号分割,也是下载程序要用的参数
|
|
28
|
+
[RADAR_SITES]
|
|
29
|
+
RADARS=Z9010,Z9220
|
|
30
|
+
|
|
31
|
+
;查询间隔-秒
|
|
32
|
+
[QUIRY_SETTING]
|
|
33
|
+
QUIRY_STEP=20
|
|
34
|
+
;查询最近多少分钟的数据,单位为分钟
|
|
35
|
+
QUIRY_RANGE=60
|
|
36
|
+
|
|
37
|
+
;数据保存时时长-小时
|
|
38
|
+
[DATA_SAVE_SETTING]
|
|
39
|
+
DATA_SAVE_HOURS=48
|
|
40
|
+
|
|
41
|
+
;天擎_API接口设置
|
|
42
|
+
[DAAS_API_SETTING]
|
|
43
|
+
RADAR_API=getRadaFileByTimeRangeAndStaId
|
|
44
|
+
;RADA_L2_ELEV_ST (逐仰角流数据) RADA_L2_FMT (新格式基数据)
|
|
45
|
+
DATA_CODE=RADA_L2_FMT
|
|
46
|
+
ELEMENTS=FILE_NAME
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
;其他计算参数
|
|
50
|
+
[PARAMS]
|
|
51
|
+
;单站数据转成格点后,x方向的格点数,y方向的格点数以及分辨率(米),一般不建议修改
|
|
52
|
+
GRID_XNUM=701
|
|
53
|
+
GRID_YNUM=701
|
|
54
|
+
GRID_RESO=500
|
|
55
|
+
|
|
56
|
+
;QPE拼图的格点分辨率,单位度
|
|
57
|
+
MOSAIC_RESO=0.005
|
|
58
|
+
|
|
59
|
+
;并行计算时,采用的cpu占总cpu资源的比例,0~1
|
|
60
|
+
CPU_RATE=0.6
|
|
61
|
+
|
|
62
|
+
;累计时段,单位:小时,用,分隔()半角
|
|
63
|
+
ACC_HOURS=1,3,6
|
|
64
|
+
;南纬,度
|
|
65
|
+
SOUTH_LAT=31.3
|
|
66
|
+
;北纬,度
|
|
67
|
+
NORTH_LAT=36.6
|
|
68
|
+
;西经,度
|
|
69
|
+
WEST_LON=110
|
|
70
|
+
;东经,度
|
|
71
|
+
EAST_LON=117
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
;拼图产品的时间间隔,分钟,建议设置为6分钟
|
|
75
|
+
MOSAIC_STEP=6
|
|
76
|
+
|
|
77
|
+
;每次循环处理时,重新计算过去多少分钟内的拼图,请设置为大于10分钟,建议设置为15或20
|
|
78
|
+
REDO_MINS=30
|
|
79
|
+
|
|
80
|
+
;绘图相关设置,存储为png格式
|
|
81
|
+
[GRAPH]
|
|
82
|
+
;图片存储路径,相对于根目录
|
|
83
|
+
PIC_PATH=pic
|
|
84
|
+
;图片分辨率,单位dpi,不建议太高,太高会降低出图效率,增加服务器负担
|
|
85
|
+
PIC_DPI=150
|