;+ ; ; NAME: spex_nontherm_energy.pro ; ; ; PURPOSE: ; Compute the nonthermal electron energy based on the spectral fitting results for MULTIPLE time intervals ; The spectral models must include a bremsstrahlung thick-target model. ; CATEGORY: ; SPECTRA, XRAYS ; ; CALLING SEQUENCE: ; spex_nontherm_energy, 'xxxxxx.fits', model_para, timearr, engarr, indexstart = indexstart ; ; CALLS: ; bremthick_energy.pro, get_edges.pro ; ; INPUTS: ; ospexfile: name of the fits file from OSPEX ; indexstart: the index for the first thick-target fitting parameter parameter (see details in brm_bremthick.pro) ; OUTPUT: ; return fitting parameters, mean time, nonthermal energy for each time interval, ; ; model_para: fitting model parameters for those spectra with a nonthermal component ; time: mean value of each time interval (in seconds since 79/1/1, 00:00) ; energy: nonthermal energy input (in ergs) at each time interval ; ; PRINT the summation of the nonthermal energy at all time intervals ; ; History: ; Linhui Sui (linhui.sui@gsfc.nasa.gov), 09/2005 ; ;- pro spex_nontherm_energy, ospexfile, model_para, time, energy, indexstart = indexstart IF N_PARAMs(ospexfile) NE 4 then begin message, "Specify the name of the fits file obtained from OSPEX" endif IF not N_ELEMENTS(indexstart) EQ 0 THEN begin print, "The starting index of the nonthermal parameters is not specified !!!!!!!!!!!!!!!!!!!!!!!! It is set to be 2." indexstart = 2 endif ;restore the fits file save in ospex result = spex_read_fit_results(ospexfile) ;retrieve parameters timeedges = result.spex_summ_time_interval ;time edges model_para = result.spex_summ_params ;fitting model parameters tmean = get_edges(timeedges,/mean) ;mean value of each time interval twidth = get_edges(timeedges,/width) ;time interval twidth = twidth / 2.0 ;find spectra fitting with a nonthermal component, nonstart = where (model_para[indexstart, *] gt 1.0e-5, intnum) ;print, 'start time: ' ;ptim, tmean[nonstart[0]] time = tmean[nonstart[0]:*] ;fitting parameters of thick-target model na = model_para(indexstart, nonstart[0]:*) ;integrated electron flux lowind = model_para(indexstart + 1, nonstart[0]:*) ;low index brkeng = model_para(indexstart + 2, nonstart[0]:*) ;break energy highind = model_para(indexstart + 3, nonstart[0]:*) ;high index lowcut = model_para(indexstart + 4, nonstart[0]:*) ;low-energy cutoff highcut = model_para(indexstart + 5, nonstart[0]:*) ;high-energy cutoff timeintvl = twidth * 2.0 energy= fltarr(intnum) ;summation of nonthermal energy fluxarr= fltarr(intnum) ;nonthermal energy flux (total energy = flux * time) sumeng = 0. for i = 0, intnum-1 do begin nthengflux = brmthick_power(na[i], lowind[i], brkeng[i], highind[i], lowcut[i], highcut[i]) fluxarr[i] = nthengflux sumeng = sumeng + nthengflux * timeintvl[i] energy[i] = sumeng endfor ;save, model_para, time, energy, fluxarr, filename = 'nonthermal_parameter_energy_flux.sav' ;print, 'Total time interval: ', intnum print, 'Total nonthermal electron energy: ', energy[intnum-1], ' ergs' end