-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathionmap.py
53 lines (47 loc) · 1.93 KB
/
ionmap.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
51
52
53
#!/usr/bin/env python
# coding:utf-8
"""Plot ionex map."""
import argparse
from datetime import datetime
import ionex
import ionplot
def ionmap(ionfile, output, t, format, colorbar=None, area=None, all=False,
show=False):
ionexr = ionex.IONEXReader(format)
iondata = ionexr.read(ionfile)
iongraph = ionplot.IonGraph(area)
if not iondata:
return
if all:
for t in sorted(iondata.keys()):
iongraph.plot_map(iondata[t], output, format, colorbar, show)
elif t is not None:
if t in iondata:
iongraph.plot_map(iondata[t], output, format, colorbar, show)
else:
keys = sorted(iondata.keys())
if len(keys) == 0:
return
iongraph.plot_map(iondata[keys[0]], output, format, colorbar)
if __name__ == '__main__':
parser = argparse.ArgumentParser('ionmap')
parser.add_argument('-i', '--input', type=str, required=True,
help='ionex filepath')
parser.add_argument('-o', '--output', type=str, required=True,
help='output directory')
parser.add_argument('-t', '--time',
type=lambda s: datetime.strptime(s, '%Y%m%dT%H:%M:%S'),
help='time')
parser.add_argument('-f', '--format', type=str, default='TEC',
help='IONEX format')
parser.add_argument('-c', '--colorbar', type=float, nargs=2,
help='min max')
parser.add_argument('-r', '--region', type=float, nargs=4,
help='llcrnrlat urcrnrlat llcrnrlon urcrnrlon')
parser.add_argument('-a', '--all', action='store_true',
help='plot all time')
parser.add_argument('-s', '--show', action='store_true',
help='show picture')
args = parser.parse_args()
ionmap(args.input, args.output, args.time, args.format, args.colorbar,
args.region, args.all, args.show)