forked from somusset/foxsi4sim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
foxsi4_typical_flare_simulation.pro
315 lines (247 loc) · 23.3 KB
/
foxsi4_typical_flare_simulation.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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
PRO foxsi4_typical_flare_simulation, goesflux, goesclass, save=save
; goes flux is a number
; goes class is a string style 'c5'
DEFAULT, save, 0
screen_dimensions = GET_SCREEN_SIZE(RESOLUTION=resolution)
window_xsize = fix(0.25*screen_dimensions[0])
window_ysize = fix(window_xsize*1.2)
;------------------------------------------------------------------------------------------------------------------------------
; SIMULATE PHOTON FLUX
;------------------------------------------------------------------------------------------------------------------------------
; simulate photon spectrum and plot it
energy_in = indgen(4000)*0.01+1
phflux = foxsi4_flare_simulation_from_goesclass(goesflux, energy_in=energy_in, energy_out=energy_out)
set_line_color
window, 0, xs=window_xsize, ys=window_ysize
plot, phflux.energy_kev, phflux.photon_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Photon flux, '+goesclass+' flare', psym=10, xtitle='Energy (keV)', ytitle='Photons/s/cm2/keV'
oplot, phflux.energy_kev, phflux.thermal_flux, thick=3, color=3, linestyle=2
oplot, phflux.energy_kev, phflux.nonthermal_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_photon_flux.png', TVRD(/TRUE)
;------------------------------------------------------------------------------------------------------------------------------
; SIMULATE COUNT FLUX WITH CDTE + MODULE 6
;------------------------------------------------------------------------------------------------------------------------------
; simulate cdte+module6 optics without attenuator and plot
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cdte=1, energy_edges=energy_in)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cdte=1, energy_edges=energy_in)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cdte=1, energy_edges=energy_in)
set_line_color
window, 1, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CdTe + module 6', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['no att',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
; FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*SQRT(count.count_flux[k]), color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cdte_module6.png', TVRD(/TRUE)
; find best attenuator in al and do the same but with attenuation
bestatt = foxsi4_best_attenuator(phflux, energy_in, cdte=1, al=1)
al_um = round(bestatt)
attstr = strtrim(string(al_um),2)
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cdte=1, energy_edges=energy_in, al_um=al_um)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cdte=1, energy_edges=energy_in, al_um=al_um)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cdte=1, energy_edges=energy_in, al_um=al_um)
set_line_color
window, 2, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CdTe + module 6', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['Al '+attstr+' um',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
; FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*SQRT(count.count_flux[k]), color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cdte_module6_Al-'+attstr+'um.png', TVRD(/TRUE)
; find best attenuator in be and do the same but with attenuation
bestatt = foxsi4_best_attenuator(phflux, energy_in, cdte=1, be=1)
be_um = round(bestatt)
attstr = strtrim(string(be_um),2)
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cdte=1, energy_edges=energy_in, be_um=be_um)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cdte=1, energy_edges=energy_in, be_um=be_um)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cdte=1, energy_edges=energy_in, be_um=be_um)
set_line_color
window, 3, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CdTe + module 6', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['Be '+attstr+' um',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
; FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*SQRT(count.count_flux[k]), color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cdte_module6_Be-'+attstr+'um.png', TVRD(/TRUE)
;------------------------------------------------------------------------------------------------------------------------------
; SIMULATE COUNT FLUX WITH CMOS + J-EF
;------------------------------------------------------------------------------------------------------------------------------
; simulate cmos+jef optics without attenuator and plot
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cmos=1, high_res_j_optic=1, energy_edges=energy_in)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cmos=1, high_res_j_optic=1, energy_edges=energy_in)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cmos=1, high_res_j_optic=1, energy_edges=energy_in)
set_line_color
window, 4, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CMOS + J-EF', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['no att',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
;FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cmos_jef.png', TVRD(/TRUE)
; find best attenuator in al and do the same but with attenuation
bestatt = foxsi4_best_attenuator(phflux, energy_in, cmos=1, high_res_j_optic=1, al=1)
al_um = round(bestatt)
attstr = strtrim(string(al_um),2)
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cmos=1, high_res_j_optic=1, energy_edges=energy_in, al_um=al_um)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cmos=1, high_res_j_optic=1, energy_edges=energy_in, al_um=al_um)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cmos=1, high_res_j_optic=1, energy_edges=energy_in, al_um=al_um)
set_line_color
window, 5, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CMOS + J-EF', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['Al '+attstr+' um',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
;FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cmos_jef_Al-'+attstr+'um.png', TVRD(/TRUE)
; find best attenuator in be and do the same but with attenuation
bestatt = foxsi4_best_attenuator(phflux, energy_in, cmos=1, high_res_j_optic=1, be=1)
be_um = round(bestatt)
attstr = strtrim(string(be_um),2)
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cmos=1, high_res_j_optic=1, energy_edges=energy_in, be_um=be_um)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cmos=1, high_res_j_optic=1, energy_edges=energy_in, be_um=be_um)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cmos=1, high_res_j_optic=1, energy_edges=energy_in, be_um=be_um)
set_line_color
window, 6, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CMOS + J-EF', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['Be '+attstr+' um',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
;FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cmos_jef_Be-'+attstr+'um.png', TVRD(/TRUE)
;------------------------------------------------------------------------------------------------------------------------------
; SIMULATE COUNT FLUX WITH CDTE + J-EF
;------------------------------------------------------------------------------------------------------------------------------
; simulate cdte+jef optics without attenuator and plot
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cdte=1, high_res_j_optic=1, energy_edges=energy_in)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cdte=1, high_res_j_optic=1, energy_edges=energy_in)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cdte=1, high_res_j_optic=1, energy_edges=energy_in)
set_line_color
window, 7, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CdTe + J-EF', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['no att',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
; FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*SQRT(count.count_flux[k]), color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cdte_jef.png', TVRD(/TRUE)
; find best attenuator in al and do the same but with attenuation
bestatt = foxsi4_best_attenuator(phflux, energy_in, cdte=1, high_res_j_optic=1, al=1)
al_um = round(bestatt)
attstr = strtrim(string(al_um),2)
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cdte=1, high_res_j_optic=1, energy_edges=energy_in, al_um=al_um)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cdte=1, high_res_j_optic=1, energy_edges=energy_in, al_um=al_um)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cdte=1, high_res_j_optic=1, energy_edges=energy_in, al_um=al_um)
set_line_color
window, 8, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CdTe + J-EF', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['Al '+attstr+' um',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
; FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*SQRT(count.count_flux[k]), color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cdte_jef_Al-'+attstr+'um.png', TVRD(/TRUE)
; find best attenuator in be and do the same but with attenuation
bestatt = foxsi4_best_attenuator(phflux, energy_in, CdTe=1, high_res_j_optic=1, be=1)
be_um = round(bestatt)
attstr = strtrim(string(be_um),2)
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, CdTe=1, high_res_j_optic=1, energy_edges=energy_in, be_um=be_um)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, CdTe=1, high_res_j_optic=1, energy_edges=energy_in, be_um=be_um)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, CdTe=1, high_res_j_optic=1, energy_edges=energy_in, be_um=be_um)
set_line_color
window, 9, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CdTe + J-EF', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['Be '+attstr+' um',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
; FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*SQRT(count.count_flux[k]), color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cdte_jef_Be-'+attstr+'um.png', TVRD(/TRUE)
;------------------------------------------------------------------------------------------------------------------------------
; SIMULATE COUNT FLUX WITH CDTE + MSFC high resolution
;------------------------------------------------------------------------------------------------------------------------------
; simulate cdte+jef optics without attenuator and plot
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cdte=1, msfc_high_res=1, energy_edges=energy_in)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cdte=1, msfc_high_res=1, energy_edges=energy_in)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cdte=1, msfc_high_res=1, energy_edges=energy_in)
set_line_color
window, 10, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CdTe + MSFC high res', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['no att',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
; FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*SQRT(count.count_flux[k]), color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cdte_msfc.png', TVRD(/TRUE)
; find best attenuator in al and do the same but with attenuation
bestatt = foxsi4_best_attenuator(phflux, energy_in, cdte=1, msfc_high_res=1, al=1)
al_um = round(bestatt)
attstr = strtrim(string(al_um),2)
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, cdte=1, msfc_high_res=1, energy_edges=energy_in, al_um=al_um)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, cdte=1, msfc_high_res=1, energy_edges=energy_in, al_um=al_um)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, cdte=1, msfc_high_res=1, energy_edges=energy_in, al_um=al_um)
set_line_color
window, 11, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CdTe + MSFC high res', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['Al '+attstr+' um',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
; FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*SQRT(count.count_flux[k]), color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cdte_msfc_Al-'+attstr+'um.png', TVRD(/TRUE)
; find best attenuator in be and do the same but with attenuation
bestatt = foxsi4_best_attenuator(phflux, energy_in, CdTe=1, msfc_high_res=1, be=1)
be_um = round(bestatt)
attstr = strtrim(string(be_um),2)
count = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.PHOTON_FLUX, CdTe=1, msfc_high_res=1, energy_edges=energy_in, be_um=be_um)
totcount = total(count.count_Rate)
countth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.thermal_FLUX, CdTe=1, msfc_high_res=1, energy_edges=energy_in, be_um=be_um)
countnth = foxsi4_flare_response_simulation(phflux.energy_kev, phflux.nonthermal_FLUX, CdTe=1, msfc_high_res=1, energy_edges=energy_in, be_um=be_um)
set_line_color
window, 12, xs=window_xsize, ys=window_ysize
plot, count.energy_kev, count.count_flux, chars=3, thick=3, charth=3, xth=2, yth=2, background=1, color=0, $
/xlog, /ylog, /xsty, title='Count flux ('+goesclass+') CdTe + MSFC high res', psym=10, xtitle='Energy (keV)', ytitle='Counts/s/keV', yr=[1d-2,1d8]
oplot, countth.energy_kev, countth.count_flux, thick=3, color=3, linestyle=2
oplot, countnth.energy_kev, countnth.count_flux, thick=3, color=5, linestyle=2
al_legend, ['Total flux','Thermal flux','Nonthermal flux'], linestyle=[0,2,2], color=[0,3,5], thick=3, chars=3, charth=3, linsi=0.4, box=0, /right
al_legend, ['Be '+attstr+' um',strtrim(string(round(totcount)),2)+' c/s'], chars=3, charth=3, box=0, /bottom
; FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*count.error_count_flux[k], color=0, thick=3
FOR k=0, n_elements(count.count_flux)-1 DO oplot, [count.energy_kev[k],count.energy_kev[k]], count.count_flux[k]+[-0.5,+0.5]*SQRT(count.count_flux[k]), color=0, thick=3
IF save EQ 1 THEN WRITE_PNG, 'foxsi4_'+goesclass+'_count_flux_cdte_msfc_Be-'+attstr+'um.png', TVRD(/TRUE)
END