-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcplot.py
executable file
·166 lines (136 loc) · 6.2 KB
/
concplot.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env python3
# ---------------------------------------------------------------------------
# NOAA Air Resources Laboratory
#
# concplot.py
#
# Produces concentration plots from a cdump file.
#
# usage: python concplot.py [OPTIONS] -iCDUMP
# ---------------------------------------------------------------------------
import logging
import os
import sys
import threading
from pandas.plotting import register_matplotlib_converters
import hysplitplot
# Register a converter to avoid a warning message.
register_matplotlib_converters()
logger = logging.getLogger(__name__)
the_plot = None
the_timer = None
call_refresh_overlay = True
def print_usage():
print("""\
USAGE: concplot -[options (default)]
-a[Arcview GIS: 0-none 1-log10 2-value 3-KML 4-partial KML]
+a[KML altitude mode: (0)-clampedToGround, 1-relativeToGround]
-A[KML options: 0-none 1-KML with no extra overlays]
-b[Bottom display level: (0) m]
-c[Contours: type, type:#contours
where type=(0)-dyn/exp, 1-fix/exp, 2-dyn/lin, 3-fix/lin, 4-set
50-0 with interval 10, 51-1 with interval 10
60-0 with interval sqrt(10), 61-1 with interval sqrt(10)]
+c[Write contour values to text output file CONTUR: (0)-no 1-yes]
-d[Display: (1)-by level, 2-levels averaged]
-e[Exposure units flag: (0)-concentrations, 1-exposure, 2-chemical threshold,
3-hypothetical volcanic ash, 4-mass loading]
-f[Frames: (0)-all frames one file, 1-one frame per file]
-g[Circle overlay: ( )-auto, #circ(4), #circ:dist_km]
-h[Hold map at center lat-lon: (source point), lat:lon]
-i[Input file name: (cdump)]
-j[Graphics map background file name: (arlmap) or shapefiles.<(txt)|process suffix>]
-k[Kolor: 0-B&W, (1)-Color, 2-No Lines Color, 3-No Lines B&W]
-l[Label options: ascii code, (73)-open star]
+l[Use THIS IS A TEST label: (0)-no, 1-yes]
-L[LatLonLabels: none=0 auto=(1) set=2:value(tenths)]
-m[Map projection: (0)-Auto 1-Polar 2-Lamb 3-Merc 4-CylEqu 5-WebMerc]
+m[Maximum square value: 0=none, (1)=both, 2=value, 3=square]
-n[Number of time periods: (0)-all, numb, min:max, -incr]
-o[Output file name: (concplot.ps)]
-p[Process file name suffix: (ps) or process ID]
-q[Quick data plot: ( )-none, filename]
-r[Removal: 0-none, (1)-each time, 2-sum, 3-total]
-s[Species: 0-sum, (1)-select, #-multiple]
-t[Top display level: (99999) m]
-u[Units label for mass: (mass), see "labels.cfg" file]
-v[Values[:labels:RRRGGGBBB color (optional,but must have 2 colons to specify color without label)
for <= 25 fixed contours: val1:lab1:RGB1+val2:lab2:RGB2+val3:lab3:RGB3+val4:lab4:RGB4]
-w[Grid point scan for contour smoothing (0)-none 1,2,3, grid points]
-x[Concentration multiplier: (1.0)]
-y[Deposition multiplier: (1.0)]
-z[Zoom factor: 0-least zoom, (50), 100-most zoom]
-1[Minimum concentration contour value when -c=0 or 1: (0.0)-none, ( )-value]
-2[Minimum deposition contour value when -c=0 or 1: (0.0)-none, ( )-value]
-3[Allow colors to change for dynamic contours (-c=0 or 2): (0)-no, 1-yes]
-4[Plot below threshold minimum contour for chemical output (-e=2): (0)-no, 1-yes]
-5[Use -o prefix name for output kml file when -a=3 or 4: (0)-no, 1-yes]
-8[Create map(s) even if all values zero: (0)-no, 1-yes]
+8[Add a contour near min: multiplier[:RRRGGGBBB] (0.8:153153153)]
-9[Force sample start time label to start of release: (0)-no, 1-yes]
--debug print debug messages
--interactive show an interactive plot
--more-formats=f1[,f2,...] specify one or more additional output format(s)
where f1 = jpg, pdf, png, tif, etc.
--more-gis-options=o1[,o2,...] specify additional GIS output format(s)
where o1 = 1, 3, 4, or 5. Refer to the -a option.
--source-time-zone show local time at the source location
--street-map[=n] show street map in the background; n = 0 or 1.
--time-zone=tz show local time at a time zone; tz = US/Eastern, US/Central, etc.
NOTE: leave no space between option and value""")
def refresh_overlay(event):
the_plot.on_update_plot_extent()
# next on_draw() should not call this.
global call_refresh_overlay
call_refresh_overlay = False
event.canvas.draw()
def delayed_refresh_overlay(event):
if the_plot.settings.interactive_mode:
global the_timer
if the_timer is not None:
the_timer.cancel()
the_timer = threading.Timer(the_plot.settings.street_map_update_delay,
refresh_overlay,
args=(event,))
the_timer.start()
else:
refresh_overlay(event)
def on_draw(event):
global call_refresh_overlay
if call_refresh_overlay:
# Consecutive on_draw() calls are contracted to one call.
delayed_refresh_overlay(event)
else:
call_refresh_overlay = True
def on_resize(event):
logger.debug("on_resize: event %s", event)
logger.debug("canvas width %d, height %d (pixel)", event.width,
event.height)
# Important to call canvas.draw() here to get spines of the initial
# plot right.
event.canvas.draw()
def main():
global the_plot
hysplitplot.print_version()
the_plot = hysplitplot.ConcentrationPlot()
the_plot.merge_plot_settings(None, sys.argv[1:])
the_plot.read_custom_labels_if_exists()
the_plot.read_data_files()
logger.info("Started Concentration Drawing")
the_plot.draw({"resize_event": on_resize, "draw_event": on_draw})
logger.info("Complete Concplot: {}".format(the_plot.get_plot_count_str()))
return 0
if __name__ == "__main__":
if len(sys.argv) == 1:
print_usage()
sys.exit(1)
else:
if "SHAPE_RESTORE_SHX" not in os.environ:
# when reading a shapefile and its corresponding shx file is
# missing, automatically generate the missing file.
os.environ['SHAPE_RESTORE_SHX'] = 'YES'
if sys.argv.count("--debug") > 0:
log_level = logging.DEBUG
else:
log_level = logging.INFO
hysplitplot.run(main, "CONCPLOT", log_level=log_level)