-
Notifications
You must be signed in to change notification settings - Fork 0
/
hessi_search_flares.pro
203 lines (181 loc) · 11.2 KB
/
hessi_search_flares.pro
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
;+
; This searches using RHESSI list
function hessi_search_flares, $
window_start=window_start, window_end=window_end, $
hi_pan=hi_pan, hi_pas=hi_pas, cor2_pa=cor2_pa, cor2_halo=cor2_halo, $
flare=flare, cme_exist=cme_exist, $
hcx_range=hcx_range, hcy_range=hcy_range
; Set up output structure
hessistr = {fl_type:' ', $
fl_starttime: ' ', fl_endtime: ' ', $
fl_peaktime: ' ', fl_goes: ' ', fl_loc: ' ', srs_no: 0., $
flare: 0., hgx: 0., hgy: 0., hcx: 0., hcy: 0.}
hessistr.hcx = !Values.F_NAN
hessistr.hcy = !Values.F_NAN
hessistr.hgx = !Values.F_NAN
hessistr.hgy = !Values.F_NAN
hessistr.flare = flare
hessi_list = hsi_read_flarelist()
;hsi_read_flarelist(info=info)
;print,info.flag_ids
;SAA_AT_START SAA_AT_END SAA_DURING_FLARE ECLIPSE_AT_START ECLIPSE_AT_END ECLIPSE_DURING_FLARE FLARE_AT_SOF FLARE_AT_EOF NON_SOLAR FAST_RATE_MODE FRONT_DECIMATION ATT_STATE_AT_PEAK DATA_GAP_AT_START DATA_GAP_AT_END DATA_GAP_DURING_FLARE PARTICLE_EVENT DATA_QUALITY POSITION_QUALITY ATTEN_0 ATTEN_1 ATTEN_2 ATTEN_3 REAR_DECIMATION MAGNETIC_REGION IMAGE_STATUS SPECTRUM_STATUS SOLAR_UNCONFIRMED SOLAR
; will use hessi_list.flags[17] which is position quality, as well as hessi_list.flags[16] which is data quality (max is 7)
; Define y position above which dont want events
polar = 625. ;750
; Get the closest flare to the search time window and CME position
; Note that 'sflag = 1' means a solar event - could say 'ne 0' which would include the maybes (2)
hessi_dates = -1
; Check location of CME vs flare. Use position angle from CME identified by COR2.
; If no COR2 event identified then use HI angle.
; If theres a halo dont restrict the location
case cme_exist of
0: begin
hi_pa = (hi_pan + hi_pas) / 2.
if (hi_pa GE 0. and hi_pa LT 180.) then begin
if (hi_pa GE 0. and hi_pa LT 90.) then hessi_dates = where((hessi_list.start_time ge anytim(window_start)) and $
(hessi_list.start_time le anytim(window_end)) and $
(hessi_list.sflag1 eq 1.) and (hessi_list.flags[17] eq 1.) and (hessi_list.flags[16] le 4.) and $
(hessi_list.x_position LE hcx_range) and (hessi_list.y_position GE -hcy_range) and $
(hessi_list.y_position LE polar) and (hessi_list.y_position GE -polar))
if (hi_pa GE 90. and hi_pa LT 180.) then hessi_dates = where((hessi_list.start_time ge anytim(window_start)) and $
(hessi_list.start_time le anytim(window_end)) and $
(hessi_list.sflag1 eq 1.) and (hessi_list.flags[17] eq 1.) and (hessi_list.flags[16] le 4.) and $
(hessi_list.x_position LE hcx_range) and (hessi_list.y_position LE hcy_range) and $
(hessi_list.y_position LE polar) and (hessi_list.y_position GE -polar))
endif
if (hi_pa GE 180. and hi_pa LE 360.) then begin
if (hi_pa GE 180. and hi_pa LT 270.) then hessi_dates = where((hessi_list.start_time ge anytim(window_start)) and $
(hessi_list.start_time le anytim(window_end)) and $
(hessi_list.sflag1 eq 1.) and (hessi_list.flags[17] eq 1.) and (hessi_list.flags[16] le 4.) and $
(hessi_list.x_position GE -hcx_range) and (hessi_list.y_position LE hcy_range) and $
(hessi_list.y_position LE polar) and (hessi_list.y_position GE -polar))
if (hi_pa GE 270. and hi_pa LT 360.) then hessi_dates = where((hessi_list.start_time ge anytim(window_start)) and $
(hessi_list.start_time le anytim(window_end)) and $
(hessi_list.sflag1 eq 1.) and (hessi_list.flags[17] eq 1.) and (hessi_list.flags[16] le 4.) and $
(hessi_list.x_position GE -hcx_range) and (hessi_list.y_position GE -hcy_range) and $
(hessi_list.y_position LE polar) and (hessi_list.y_position GE -polar))
endif
end
1: begin
if (cor2_halo) EQ 'II' or (cor2_halo) EQ 'III' or (cor2_halo) EQ 'IV' then begin
hessi_dates = where((hessi_list.start_time ge anytim(window_start)) and $
(hessi_list.start_time le anytim(window_end)) and $
(hessi_list.sflag1 eq 1.) and (hessi_list.flags[17] eq 1.) and (hessi_list.flags[16] le 4.) and $
(hessi_list.y_position LE polar) and (hessi_list.y_position GE -polar))
endif else begin
if (cor2_pa GE 0. and cor2_pa LT 180.) then begin
if (cor2_pa GE 0. and cor2_pa LT 90.) then hessi_dates = where((hessi_list.start_time ge anytim(window_start)) and $
(hessi_list.start_time le anytim(window_end)) and $
(hessi_list.sflag1 eq 1.) and (hessi_list.flags[17] eq 1.) and (hessi_list.flags[16] le 4.) and $
(hessi_list.x_position LE hcx_range) and (hessi_list.y_position GE -hcy_range) and $
(hessi_list.y_position LE polar) and (hessi_list.y_position GE -polar))
if (cor2_pa GE 90. and cor2_pa LT 180.) then hessi_dates = where((hessi_list.start_time ge anytim(window_start)) and $
(hessi_list.start_time le anytim(window_end)) and $
(hessi_list.sflag1 eq 1.) and (hessi_list.flags[17] eq 1.) and (hessi_list.flags[16] le 4.) and $
(hessi_list.x_position LE hcx_range) and (hessi_list.y_position LE hcy_range) and $
(hessi_list.y_position LE polar) and (hessi_list.y_position GE -polar))
endif
if (cor2_pa GE 180. and cor2_pa LE 360.) then begin
if (cor2_pa GE 180. and cor2_pa LT 270.) then hessi_dates = where((hessi_list.start_time ge anytim(window_start)) and $
(hessi_list.start_time le anytim(window_end)) and $
(hessi_list.sflag1 eq 1.) and (hessi_list.flags[17] eq 1.) and (hessi_list.flags[16] le 4.) and $
(hessi_list.x_position GE -hcx_range) and (hessi_list.y_position LE hcy_range) and $
(hessi_list.y_position LE polar) and (hessi_list.y_position GE -polar))
if (cor2_pa GE 270. and cor2_pa LT 360.) then hessi_dates = where((hessi_list.start_time ge anytim(window_start)) and $
(hessi_list.start_time le anytim(window_end)) and $
(hessi_list.sflag1 eq 1.) and (hessi_list.flags[17] eq 1.) and (hessi_list.flags[16] le 4.) and $
(hessi_list.x_position GE -hcx_range) and (hessi_list.y_position GE -hcy_range) and $
(hessi_list.y_position LE polar) and (hessi_list.y_position GE -polar))
endif
endelse
end
endcase
if (hessi_dates(0) ne -1) then begin
; Get closest match based on start time
; Search for X, then M, then C -
hessi_x = where(strmid(hessi_list(hessi_dates).goes_class,0,1) eq 'X')
hessi_m = where(strmid(hessi_list(hessi_dates).goes_class,0,1) eq 'M')
hessi_c = where(strmid(hessi_list(hessi_dates).goes_class,0,1) eq 'C')
hessi_b = where((strmid(hessi_list(hessi_dates).goes_class,0,1) eq 'B') or (strmid(hessi_list(hessi_dates).goes_class,0,1) eq 'A'))
;Note here it is not allowing any that dont have a class
if (hessi_x(0) or hessi_m(0) or hessi_c(0) or hessi_b(0)) ne -1 then begin
if hessi_x(0) ne -1 then begin
hessi_candidate_index = closest(anytim(hessi_list(hessi_dates(hessi_x)).start_time), anytim(window_start))
hessi_candidate = hessi_list(hessi_dates(hessi_x(hessi_candidate_index)))
endif else begin
if hessi_m(0) ne -1 then begin
hessi_candidate_index = closest(anytim(hessi_list(hessi_dates(hessi_m)).start_time), anytim(window_start))
hessi_candidate = hessi_list(hessi_dates(hessi_m(hessi_candidate_index)))
endif else begin
if hessi_c(0) ne -1 then begin
hessi_candidate_index = closest(anytim(hessi_list(hessi_dates(hessi_c)).start_time), anytim(window_start))
hessi_candidate = hessi_list(hessi_dates(hessi_c(hessi_candidate_index)))
endif else begin
hessi_candidate_index = closest(anytim(hessi_list(hessi_dates(hessi_b)).start_time), anytim(window_start))
hessi_candidate = hessi_list(hessi_dates(hessi_b(hessi_candidate_index)))
endelse
endelse
endelse
if typename(hessi_candidate) ne 'INT' then hessistr.flare = 1.
; Output this initial info
hessistr.fl_starttime = anytim(hessi_candidate.start_time, /vms)
hessistr.fl_endtime = anytim(hessi_candidate.end_time, /vms)
hessistr.fl_peaktime = anytim(hessi_candidate.peak_time, /vms)
hessistr.fl_goes = STRTRIM(hessi_candidate.goes_class)
hessistr.srs_no = hessi_candidate.active_region
hessistr.fl_type = 'hessi'
; Get position coordinates for later use with NOAA SRS and running SMART
if hessi_candidate.x_position ne 0. then begin
hcx = hessi_candidate.x_position
hcy = hessi_candidate.y_position
hc2hg, hcx, hcy, hgx, hgy, date = hessistr.fl_peaktime
flarelocstring = locint2string(latitude=hgy, longitude=hgx)
hessistr.fl_loc = flarelocstring
hessistr.hcx = hcx
hessistr.hcy = hcy
hessistr.hgx = hgx
hessistr.hgy = hgy
endif else begin
; If no position information...
hessistr.hcx = !Values.F_NAN
hessistr.hcy = !Values.F_NAN
hessistr.hgx = !Values.F_NAN
hessistr.hgy = !Values.F_NAN
endelse
;Here theres no class defined in the structure so just choose closest start time
endif else begin
hessi_candidate_index = closest(anytim(hessi_list(hessi_dates).start_time), anytim(window_start))
hessi_candidate = hessi_list(hessi_dates(hessi_candidate_index))
if typename(hessi_candidate) ne 'INT' then hessistr.flare = 1.
; Output this initial info
hessistr.fl_starttime = anytim(hessi_candidate.start_time, /vms)
hessistr.fl_endtime = anytim(hessi_candidate.end_time, /vms)
hessistr.fl_peaktime = anytim(hessi_candidate.peak_time, /vms)
hessistr.fl_goes = STRTRIM(hessi_candidate.goes_class)
hessistr.srs_no = hessi_candidate.active_region
hessistr.fl_type = 'hessi'
; Get position coordinates for later use with NOAA SRS and running SMART
if hessi_candidate.x_position ne 0. then begin
hcx = hessi_candidate.x_position
hcy = hessi_candidate.y_position
hc2hg, hcx, hcy, hgx, hgy, date = hessistr.fl_peaktime
flarelocstring = locint2string(latitude=hgy, longitude=hgx)
hessistr.fl_loc = flarelocstring
hessistr.hcx = hcx
hessistr.hcy = hcy
hessistr.hgx = hgx
hessistr.hgy = hgy
endif else begin
; If no position information...
hessistr.hcx = !Values.F_NAN
hessistr.hcy = !Values.F_NAN
hessistr.hgx = !Values.F_NAN
hessistr.hgy = !Values.F_NAN
endelse
endelse
; No flare identified
endif else begin
hessistr.flare = 0.
endelse
return, hessistr
end