-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlotEvent.py
232 lines (193 loc) · 5.43 KB
/
PlotEvent.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
"""
A tool to plot out an event
"""
import numpy as np
from CIMP import Event as ev
from sunpy.net import attrs as a
#---------------------------------------------------
plotcase = 14
if plotcase == 1:
testcase = 1
nrgf = False
enhance = False
plotframes = (3, 6, 9, 12)
clip = (0.0, 1000.0)
scale = None
elif plotcase == 2:
testcase = 1
nrgf = True
enhance = False
plotframes = (3, 6, 9, 12)
scale = (0.0, 4.0)
elif plotcase == 3:
testcase = 1
nrgf = False
enhance = True
plotframes = (3, 6, 9, 12)
clip = (0.0, 1000.0)
scale = None
elif plotcase == 4:
testcase = 1
nrgf = True
enhance = True
plotframes = (3, 6, 9, 12)
scale = (0.0, 4.0)
clip = scale
elif plotcase == 5:
testcase = 2
nrgf = True
enhance = True
plotframes = (7, 14, 21, 29)
scale = (0.0, 4.0)
clip = scale
elif plotcase == 6:
testcase = 2
nrgf = False
enhance = True
plotframes = (7, 14, 21, 29)
scale = None
clip = (0.0,200)
elif plotcase == 7:
# Event 22 in NASA/NOAA MOU Annex Final Report (Mays et al 2015)
testcase = 3
instrument = a.Instrument.lasco
detector = a.Detector.c2
timerange = a.Time('2013/05/17 9:00:00', '2013/05/17 11:30:00')
nrgf = False
enhance = True
plotframes = (1, 2, 4, 6)
scale = (0, 100.0)
clip = scale
elif plotcase == 8:
# Event 22 in NASA/NOAA MOU Annex Final Report (Mays et al 2015)
testcase = 3
instrument = a.Instrument.lasco
detector = a.Detector.c2
timerange = a.Time('2013/05/17 9:00:00', '2013/05/17 11:30:00')
nrgf = True
enhance = True
plotframes = (1, 2, 4, 6)
scale = (0, 4.0)
clip = scale
elif plotcase == 9:
# Event 22 in NASA/NOAA MOU Annex Final Report (Mays et al 2015)
testcase = 4
instrument = a.Instrument.lasco
detector = a.Detector.c3
timerange = a.Time('2013/05/17 9:30:00', '2013/05/17 13:30:00')
nrgf = False
enhance = True
plotframes = (4, 8, 12, 18)
scale = None
clip = (0,100.0)
elif plotcase == 10:
# Event 22 in NASA/NOAA MOU Annex Final Report (Mays et al 2015)
testcase = 5
instrument = a.Instrument.secchi
detector = a.Detector.cor1
timerange = a.Time('2013/05/17 9:00:00', '2013/05/17 11:00:00')
nrgf = False
enhance = True
plotframes = None
scale = (0, 100.0)
clip = scale
elif plotcase == 11:
# Event 22 in NASA/NOAA MOU Annex Final Report (Mays et al 2015)
testcase = 6
instrument = a.Instrument.secchi
detector = a.Detector.cor2
timerange = a.Time('2013/05/17 9:30:00', '2013/05/17 13:00:00')
nrgf = False
enhance = False
plotframes = (1,2,3,5)
scale = (0, 300.0)
clip = scale
elif plotcase == 12:
# Event 22 in NASA/NOAA MOU Annex Final Report (Mays et al 2015)
testcase = 7
instrument = a.Instrument.secchi
detector = a.Detector.cor1
timerange = a.Time('2013/05/17 9:00:00', '2013/05/17 11:00:00')
nrgf = False
enhance = True
plotframes = None
scale = (0, 300.0)
clip = scale
elif plotcase == 13:
# Event 22 in NASA/NOAA MOU Annex Final Report (Mays et al 2015)
testcase = 8
instrument = a.Instrument.secchi
detector = a.Detector.cor2
timerange = a.Time('2013/05/17 9:30:00', '2013/05/17 13:00:00')
nrgf = False
enhance = True
plotframes = (1,2,3,5)
scale = None
clip = (0,600)
elif plotcase == 14:
# Testing ingest of polarized STEREO-A images
testcase = 9
nrgf = False
enhance = False
plotframes = (1,2,3,5)
scale = (-1.e-12,1.e-12)
clip = None
else:
print("specify a valid plotcase")
exit()
#---------------------------------------------------
# Create event
if testcase is None:
# if testcase is not specified, you have to specify an instrument, detector, and time range
x = ev.event.fromtime(instrument, detector, timerange)
else:
x = ev.event.testcase(testcase)
print(80*'-')
print(x)
print(80*'-')
print(repr(x))
print(80*'-')
#---------------------------------------------------
# pick 4 frames to plot
if plotframes == None:
n = np.uint16((x.nframes - 1)/4)
plotframes = (n, 2*n, 3*n, x.nframes-1)
print(f"PLOTFRAMES: {plotframes}")
#---------------------------------------------------
# Optionally Apply a filter
if nrgf:
x.nrgf()
if enhance:
#x.enhance(clip = clip, detail='mgn')
#x.enhance(clip = clip, detail='contrast')
x.enhance(clip = clip, detail='fnrgf')
#x.noise_gate(cubesize=(3,12,12)); scale=(0,100)
# ===================
import matplotlib.pyplot as plt
import astropy.units as u
fig = plt.figure(figsize=[18,10])
# ===================\
# plot the first frame, not as a diff image
amap = x.map(0)
ax = fig.add_subplot(2,3,1,projection=amap)
#amap.plot(clip_interval=[10,90]*u.percent)
amap.plot()
# pick a scale from one of the middle images
ref = x.map(plotframes[3])
print(f"Reference data range: {ref.min()} to {ref.max()}")
if scale is None:
scale = (ref.min(), ref.max())
print(f"image scale: {scale[0]} to {scale[1]}")
for i in np.arange(0,4):
amap = x.map(plotframes[i])
ax = fig.add_subplot(2,3,i+2,projection=amap)
if scale is None:
pplot = amap.plot()
else:
pplot = amap.plot(vmin = scale[0], vmax = scale[1])
print(f"color table {pplot.get_clim()}")
# plot sum in last frame
long_exposure = x.sum()
ax = fig.add_subplot(2,3,6,projection=long_exposure)
long_exposure.plot(clip_interval=[10,90]*u.percent)
plt.show()