dustem_plot_fit_extsed.pro 4.29 KB
PRO dustem_plot_fit_extsed,st,sed, $
                          res=res, $
                          help=help, $
                          win=win, $
                          ps=ps, $
                          UV=UV, $
                          _extra=_extra

;+
; NAME:
;    dustem_plot_fit_extsed
; PURPOSE:
;    Plots a Dustem model and SED. Parameter values and error are
;    printed on plot. Used for plotting results during fit.
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
;    dustem_plot_fit_sed,st,sed,cont[,/no_spec_error][,res=][,errors=][,chi2=][,rchi2=][/help][_extra=]
; INPUTS:
;    st        = Dustem model output structure
;    sed       = Dustem model SED
;    cont      = Dustem model NIR continuum
; OPTIONAL INPUT PARAMETERS:
;    res       = fit result values. If set values are written on plot.
;    errors    = fit result errors. If set values are written on plot.
;    chi2      = fit chi^2. if set value is written on plot.
;    rchi2     = Reduced fit chi^2. if set value is written on plot.
;    _extra    = extra parameters for the plot routine
; OUTPUTS:
;    None
; OPTIONAL OUTPUT PARAMETERS:
;    None
; ACCEPTED KEY-WORDS:
;    help      = If set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    SED and model are plotted
; RESTRICTIONS:
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    None
; EXAMPLES
;    dustem_plot_fit_sed,st,sed,cont
; MODIFICATION HISTORY:
;    Written by J.-Ph. Bernard
;    see evolution details on the dustem cvs maintained at CESR
;    Contact J.-Ph. Bernard (Jean-Philippe.Bernard@cesr.fr) in case of problems.
;-

;stop

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_plot_fit_extsed'
  goto,the_end
ENDIF

IF keyword_set(ps) THEN BEGIN
   set_plot, 'PS'
   device, filename=ps, /color, /encapsulated
ENDIF ;ELSE BEGIN
;   set_plot,'X'
;    IF keyword_set(win) then window,win
;ENDELSE

;fact = 1.e4*1.E20/(4.*!pi)/(3.e8/1.e-6/st.sed.wav)*1.e20/1.e7

;use_col_data_filt=70
;use_col_sed_spec=170
use_col_data_filt='blue'
;use_col_sed_spec='red'
use_col_sed_spec='grey'
IF not keyword_set(col_sed) THEN BEGIN
  ;use_col_sed_filt=250     ;red
  use_col_sed_filt='red'     ;red
ENDIF ELSE BEGIN
  use_col_sed_filt=col_sed
ENDELSE
IF not keyword_set(col_tot) THEN BEGIN
  ;use_col_tot=200
  use_col_tot='black'
ENDIF ELSE BEGIN
  use_col_tot=col_tot
ENDELSE
IF not keyword_set(line_tot) THEN BEGIN
  use_line_tot=0
ENDIF ELSE BEGIN
  use_line_tot=line_tot
ENDELSE
;color and linestyle for continuum
IF not keyword_set(col_cont) THEN BEGIN
  ;use_col_cont=30
  use_col_cont='Navy'
ENDIF ELSE BEGIN
  use_col_count=col_cont
ENDELSE
IF not keyword_set(line_cont) THEN BEGIN
  use_line_cont=0
ENDIF ELSE BEGIN
  use_line_cont=line_cont
ENDELSE
;color and linestyle for freefree
IF not keyword_set(col_freefree) THEN BEGIN
  ;use_col_cont=30
  use_col_freefree='Dark Red'
ENDIF ELSE BEGIN
  use_col_freefree=col_freefree
ENDELSE
IF not keyword_set(line_freefree) THEN BEGIN
  use_line_freefree=0
ENDIF ELSE BEGIN
  use_line_freefree=line_freefree
ENDELSE
IF not keyword_set(col_synchrotron) THEN BEGIN
  ;use_col_cont=30
  use_col_synchrotron='Dark Red'
ENDIF ELSE BEGIN
  use_col_synchrotron=col_synchrotron
ENDELSE
IF not keyword_set(line_synchrotron) THEN BEGIN
  use_line_synchrotron=0
ENDIF ELSE BEGIN
  use_line_synchrotron=line_synchrotron
ENDELSE

;win=1
dustem_ext = interpol(st.ext.ext_tot,st.ext.wav,(*!dustem_data.ext).wav) 
chi2_ext   = total(((*!dustem_data.ext).values-dustem_ext)^2/(*!dustem_data.ext).sigma^2)
n_ext = n_elements((*!dustem_data.ext).values)
rchi2_ext  = chi2_ext / n_ext
wrchi2_ext  = rchi2_ext * (*!fit_rchi2_weight).ext
print,"chi2 EXT = ",chi2_ext,"  rchi2 EXT = ",rchi2_ext;," weighted rchi2 EXT=",wrchi2_ext
;xr=[0.3,40]
;yr=[1.e-26,1.e-21]
;dustem_plot_ext,st,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,/donotclose,multi=1,_extra=_extra
dustem_plot_ext,st,ps=filename,mergePAH=mergePAH,/donotclose,multi=1,_extra=_extra,UV=UV
dustem_plot_ext,st,ps=filename,mergePAH=mergePAH,multi=2,UV=UV,_extra=_extra

;win+=1
                    ;dustem_plot_ext,st,/UV,yr=[0,2.5],/ysty,xr=[0,10],/xsty,win=win
;xr=[0.2,10]
;yr=[0,3e-21]
;dustem_plot_ext,st,/UV,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,/donotclose,multi=1
;dustem_plot_ext,st,/UV,yr=yr,/ysty,xr=xr,/xsty,ps=filename,win=win,mergePAH=mergePAH,multi=2

;stop

the_end:

END