-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_radar.py
executable file
·50 lines (40 loc) · 1.62 KB
/
plot_radar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# coding: utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
__metaclass__ = type
import argparse
import matplotlib.pyplot as plt
from radpy.pyart_tools import radar_info
import pyart
def make_parser():
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
description='Plot radar file.')
parser.add_argument('file', metavar='FILE', type=str,
help='a file to plot')
parser.add_argument('-f', '--field', type=str,
help='radar variable to plot, default: DBZ')
parser.add_argument('-d', '--max-dist', type=int,
help='crop distance from radar (km)')
parser.add_argument('-v', '--vlim', type=float, nargs=2,
metavar=('vmin', 'vmax'), default=None,
help='minimum and maximum value to plot')
return parser
def plot_file(filepath, field='DBZ', max_dist=None, vlim=None, **kws):
radar = pyart.io.read(filepath)
radar_info(radar)
display = pyart.graph.RadarDisplay(radar)
fig, ax = plt.subplots()
display.plot(field, vmin=vlim[0], vmax=vlim[1], **kws)
display.plot_cross_hair(5)
if max_dist:
ax.set_ylim(-max_dist, max_dist)
ax.set_xlim(-max_dist, max_dist)
plt.show()
return radar
def main(*args, **kws):
return plot_file(*args, **kws)
if __name__ == '__main__':
parser = make_parser()
args = parser.parse_args()
radar = main(args.file, field=args.field, max_dist=args.max_dist,
vlim=args.vlim)