Function chianti_spec,temp,wave_edges,wstep=wstep,photon=photon,erg=erg, $ ab_ion=ab_ion, abun=abun,ion=ion ;+ ; NAME: ; chianti_spec ; PURPOSE: ; Compute a Chianti isothermal spectrum (line + continuum) in the specified wavelength bins. ; Calculation is made for EM=1.e44 cm^-3. ; ; CALLING SEQUENCE: ; Flux = chianti_spec(temp,wave_edges) ; ph s-1 ; Flux = chianti_spec(temp,wave_edges,/photon) ; ph s-1 ; Flux = chianti_spec(temp,wave_edges,/erg) ; erg s-1 ; Flux = chianti_spec(5.0e6,[1,8,20,30],/erg) ; erg s-1 ; ; INPUTS: ; Temp : Temperature (in K, may be a vector). ; Wave_edges : Vector of wavelengths (in Ang). ; Wave_edges value, [1,8,20,30], yields the 3-element Flux, ; Flux(*,0) : Fluxes for 1 - 8 A wavelength range. ; Flux(*,1) : Fluxes for 8 - 20 A wavelength range. ; Flux(*,2) : Fluxes for 20 - 30 A wavelength range. ; ; OUTPUTS: ; Flux : Fluxes in ph s-1 or erg s-1 (total flux with each bin) ; Fluxes = fltarr(N_elements(Te6),N_elements(wave)) ; ; OPTIONAL INPUT KEYWORDS: ; Wstep : wavelength step size of spectrum calculation (in Ang), ; (a bin size used in the ISOTHERMAL.PRO, default=0.05) ; Photon : If set, calculation is made in ph s-1 (default) ; Erg : If set, calculation is made in erg s-1 ; ; OPTIONAL INPUT KEYWORDS: ; Ab_ion : 1 : sun_coronal_ext.abund & chianti.ioneq are assumed. ; : 2 (default): sun_hybrid_ext.abund & chianti.ioneq are assumed. ; : 3 : sun_photospheric_grevesse07.abund & chianti.ioneq. ; Abun : Full pass name for the abundance file. ; Ion : Full pass name for the ionization equilbrium file. ; (If Ab_ion is set, Abun and Ioneq will be neglected.) ; ; METHOD: ; Calculate spectrum with isothermal.pro, then rebin the intensity ; into the user-specified wavelength bins. ; ; MODIFICATION HISTORY: ; 1-Jul-2010, Aki Takeda : Modified version of mewe_spec and ; mewe_spec_lwa.pro ; 3-Apr-2011, Aki T.: Default sre file, corona --> hybrid. ;- COMMON elements,abund,abund_ref,ioneq,ioneq_logt,ioneq_ref ;**************************************************************** ; With no calling arguments, display the calling sequence: ;**************************************************************** if n_params() eq 0 then begin return,' Flux= chianti_spec(Temp,wave_edges[,/erg]) ; for EM=1.e44 cm-3' endif if keyword_set(photon) and keyword_set(erg) then begin print,' **** Error in chianti_spec ****',string(7b),string(7b) print,' You cannot specify both /photon and /erg' return,-1 endif else if keyword_set(erg) then Units=1 else Units=0 if n_elements(wave_edges) eq 0 then begin print,' **** Error in chianti_spec ****',string(7b),string(7b) print,' Wave_edges or Temp is undefined' help,Temp,Wave_edges return,-1 endif if not keyword_set(Wstep) then begin Wstep=0.05 print,' *** Wstep set to 0.05 (A). ***' endif ; ************************************************************ ; Set up the adundance & ion equilbrium information ; ************************************************************ abund_name='-' ioneq_name='-' ;--------------------------------- if keyword_set(ab_ion) then begin ;--------------------------------- case ab_ion of 1 : begin ; (corona + chianti) ab_file='sun_coronal_ext.abund' ion_file='chianti.ioneq' end 2 : begin ; (hybrid + chianti : Default) ab_file='sun_hybrid_ext.abund' ion_file='chianti.ioneq' end 3 : begin ; (photospheric + chianti) ab_file='sun_photospheric_grevesse07.abund' ion_file='chianti.ioneq' end else : begin ; (invalid number --> default) ab_file='sun_hybrid_ext.abund' ion_file='chianti.ioneq' print,"*** 'sun_hybrid_ext.abund' and 'chianti.ioneq' assumed. ***" end endcase ; abund_name=concat_dir(!xuvtop,'abundance/'+ab_file) ioneq_name=concat_dir(!xuvtop,'ioneq/'+ion_file) ;------------------ endif else begin ;------------------ if keyword_set(abun) then begin chk=file_exist(string(abun)) if chk eq 1 then abund_name=abun $ else begin print,'**** Specified abundance file not exist, default assumed. ***' abund_name=concat_dir(!xuvtop,'abundance/'+'sun_hybrid_ext.abund') endelse endif ; if keyword_set(ion) then begin chk=file_exist(string(ion)) if chk eq 1 then ioneq_name=ion $ else begin print,'**** Specified ion-eq file not exist, default assumed. ***' ioneq_name=concat_dir(!xuvtop,'ioneq/'+'chianti.ioneq') endelse endif ; if abund_name eq '-' then begin abund_name=concat_dir(!xuvtop,'abundance/'+'sun_hybrid_ext.abund') print,"*** 'sun_hybrid_ext.abund' is assumed. ***" endif if ioneq_name eq '-' then begin ioneq_name=concat_dir(!xuvtop,'ioneq/'+'chianti.ioneq') print,"*** 'chianti.ioneq' assumed. ***" endif ;--------- endelse ;--------- ; read_abund,abund_name,abund,abund_ref read_ioneq,ioneq_name,ioneq_logt,ioneq,ioneq_ref ; ;***************************************************** ; Compute the line + cont flux (for EM=1.e44 cm-3): ;***************************************************** wmin = min(wave_edges) & wmax = max(wave_edges) n_wave=fix((wmax-wmin)/wstep)+1 wave=findgen(n_wave)*wstep+wmin em=replicate(1.d44,n_elements(temp)) isothermal,wmin,wmax,wstep,temp,edensity=1.e9,erg=erg,wave,spec, $ em=em, abund_name=abund_name, ioneq_name=ioneq_name, /cont tot_flux=spec*4*!pi ; ;************************************************* ; Rebin into the user-supplied wavelength bins. ;************************************************* nbin=n_elements(wave_edges)-1 ntemp=n_elements(temp) flux=dblarr(nbin,ntemp) ; for i=0,nbin-1 do begin ss=where(wave ge wave_edges(i) and wave le wave_edges(i+1)) flux(i,*)=total(tot_flux(ss,*),1) endfor ; return,reform(flux) ; end