国家气象中心天气预报技术研发室
June, 2020
Kan Dai
StandardData
类, 用于读取"天气雷达基数据标准格式(V1.0)"standard_data_to_pyart
函数, 将StandardData
对象转化为pyart雷达数据类get_radar_mosaic
读取雷达拼图数据get_radar_mosaics
读取多个雷达拼图数据get_swan_radar
读取SWAN的131雷达格式数据get_radar_standard
读取单站雷达标准格式基数据# set up things
%matplotlib inline
%load_ext autoreload
%autoreload 2
import warnings
warnings.filterwarnings('ignore')
# load libraries
import numpy as np
import xarray as xr
import pyart
import matplotlib as mpl
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from nmc_met_io.read_radar import StandardData
from nmc_met_io.export_radar import standard_data_to_pyart
from nmc_met_io.retrieve_micaps_server import get_radar_mosaic, get_radar_mosaics, \
get_swan_radar, get_radar_standard
from nmc_met_graphics.plot.mapview import add_china_map_2cartopy
from metpy.plots import colortables
xr.set_options(display_style="text")
## You are using the Python ARM Radar Toolkit (Py-ART), an open source ## library for working with weather radar data. Py-ART is partly ## supported by the U.S. Department of Energy as part of the Atmospheric ## Radiation Measurement (ARM) Climate Research Facility, an Office of ## Science user facility. ## ## If you use this software to prepare a publication, please cite: ## ## JJ Helmus and SM Collis, JORS 2016, doi: 10.5334/jors.119
<xarray.core.options.set_options at 0x7f865f6d7fa0>
# read GuangZhou radar data.
data = StandardData('./samples/Z_RADR_I_Z9200_20200327114200_O_DOR_SAD_CAP_FMT.BIN.BZ2')
data
Radar station: GuangZhou/Z9200; Scan time: 2020-03-27 03:42:00; Longitude/Latitude: (113.355, 23.004); Height: 179m; Task name: VCP21D
# convert the standard data to pyart data
radar = standard_data_to_pyart(data)
/home/kan-dai/miniconda3/envs/MET/lib/python3.7/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above. and should_run_async(code)
# create the displays and figure
display = pyart.graph.RadarMapDisplay(radar)
# Setting projection and ploting the second tilt
projection = ccrs.LambertConformal(central_latitude=radar.latitude['data'][0],
central_longitude=radar.longitude['data'][0])
fig = plt.figure(figsize=(12,10))
display.plot_ppi_map('reflectivity', 0, vmin=0, vmax=64,
min_lon=111.35, max_lon=115.35, min_lat=21, max_lat=25,
lon_lines=np.arange(111, 116, 0.5), resolution='10m',
lat_lines=np.arange(21, 26, 0.5), projection=projection,
fig=fig, lat_0=radar.latitude['data'][0],
lon_0=radar.longitude['data'][0])
# Plot range rings at 10, 20, 30, 40km
display.plot_range_ring(50., line_style='k-')
display.plot_range_ring(100., line_style='k--')
display.plot_range_ring(150., line_style='k-')
display.plot_range_ring(200., line_style='k--')
# Indicate the radar location with a point
display.plot_point(radar.longitude['data'][0], radar.latitude['data'][0])
plt.show()
/home/kan-dai/miniconda3/envs/MET/lib/python3.7/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above. and should_run_async(code) /home/kan-dai/miniconda3/envs/MET/lib/python3.7/site-packages/pyart/graph/radarmapdisplay.py:507: DeprecationWarning: The outline_patch property is deprecated. Use GeoAxes.spines['geo'] or the default Axes properties instead. ax.outline_patch.get_path().vertices.tolist()) /home/kan-dai/miniconda3/envs/MET/lib/python3.7/site-packages/pyart/graph/radarmapdisplay.py:507: DeprecationWarning: The outline_patch property is deprecated. Use GeoAxes.spines['geo'] or the default Axes properties instead. ax.outline_patch.get_path().vertices.tolist())
data = get_radar_standard('SINGLERADAR/ARCHIVES/PRE_QC/广州/')
radar = standard_data_to_pyart(data)
data
Radar station: GuangZhou_Z9200/Z9200; Scan time: 2023-05-14 03:12:01; Longitude/Latitude: (113.355, 23.004); Height: 144m; Task name: VCP21D
display = pyart.graph.RadarDisplay(radar)
fig = plt.figure(figsize=(11, 9))
# plot super resolution reflectivity
ax = fig.add_subplot(111)
display.plot('reflectivity', 0, title='CINRAD Reflectivity',
vmin=0, vmax=64, colorbar_label='', ax=ax)
display.plot_range_ring(radar.range['data'][-1]/1000., ax=ax)
display.set_limits(xlim=(-500, 500), ylim=(-500, 500), ax=ax)
plt.show()
/home/kan-dai/miniconda3/envs/MET/lib/python3.7/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above. and should_run_async(code)
# 从"RADARMOSAIC/CREF/"数据目录下读取最新时刻的雷达拼图数据
cref = get_radar_mosaic("RADARMOSAIC/CREF/")
cref
/home/kan-dai/miniconda3/envs/MET/lib/python3.7/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above. and should_run_async(code)
<xarray.Dataset> Dimensions: (lat: 4200, lon: 6200, time: 1) Coordinates: * time (time) datetime64[ns] 2021-05-12T13:50:00 * lat (lat) float64 12.21 12.21 12.23 12.24 ... 54.16 54.17 54.19 54.2 * lon (lon) float64 73.0 73.01 73.02 73.03 ... 135.0 135.0 135.0 135.0 Data variables: data (time, lat, lon) float32 nan nan nan nan nan ... nan nan nan nan Attributes: Conventions: CF-1.6 Origin: MICAPS Cassandra Server
# set up map projection
map_center = (116, 28)
map_width = 20
datacrs = ccrs.PlateCarree()
plotcrs = ccrs.AlbersEqualArea(
central_latitude=map_center[1], central_longitude=map_center[0],
standard_parallels=[30., 60.])
# set up figure
fig = plt.figure(figsize=(14, 7))
gs = mpl.gridspec.GridSpec(1, 2, width_ratios=[1, .03], bottom=.01, top=.99,
hspace=0.01, wspace=0.01)
ax = plt.subplot(gs[0], projection=plotcrs)
# add model title
fig.suptitle('CREF (dBz)', horizontalalignment='left', fontsize=20)
# add map background
map_extent = (
map_center[0] - map_width/2.0, map_center[0] + map_width/2.0,
map_center[1] - map_width/3.0, map_center[1] + map_width/3.0)
ax.set_extent(map_extent, crs=datacrs)
add_china_map_2cartopy(ax, name='province', edgecolor='black', lw=2, zorder=100)
# draw composite reflectivity
x, y = np.meshgrid(cref['lon'].values, cref['lat'].values)
norm, cmap = colortables.get_with_steps('NWSReflectivity', 12, 4)
pm = ax.pcolormesh(x, y, np.squeeze(cref['data'].values), norm=norm, cmap=cmap, transform=datacrs)
cax = plt.subplot(gs[1])
cb = plt.colorbar(pm, cax=cax, orientation='vertical', extendrect='True')
cb.set_label('Composite reflectivity', size=12)
# show figure
gs.tight_layout(fig)
plt.show()
/home/kan-dai/miniconda3/envs/MET/lib/python3.7/site-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above. and should_run_async(code)
# 读取清华大学的外推QPF预报
data = get_swan_radar("RADARMOSAIC/EXTRAPOLATION/QPF/")
data
<xarray.Dataset> Dimensions: (lat: 4000, level: 1, lon: 7000, time: 1) Coordinates: * time (time) datetime64[ns] 2020-03-30T14:54:00 * level (level) float32 0.0 * lat (lat) float64 15.01 15.02 15.03 ... 54.99 55.0 * lon (lon) float64 70.0 70.0 70.01 ... 140.0 140.0 140.0 forecast_reference_time datetime64[ns] 2020-03-30T14:54:00 forecast_period (time) float64 0.0 Data variables: data (time, level, lat, lon) float32 0.0 0.0 ... 0.0 0.0 Attributes: Conventions: CF-1.6 Origin: MICAPS Cassandra Server
fig = plt.figure(figsize=(12,9))
ax = plt.axes(projection=ccrs.LambertConformal(central_longitude=120))
norm, cmap = colortables.get_with_steps('precipitation', 0.1, 0.4)
data['data'].plot(ax=ax, transform=ccrs.PlateCarree(), norm=norm, cmap=cmap, cbar_kwargs={'shrink': 0.8})
ax.coastlines(resolution='10m')
ax.gridlines()
ax.set_extent([108,120,20,32], crs=ccrs.PlateCarree())