Blame view

src/idl/dustem_gb_plot_fit_sed.pro 3.34 KB
427f1205   Jean-Michel Glorian   version 4.2 merged
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
PRO dustem_gb_plot_fit_sed,ww,spec,sed, $
                        res=res,errors=errors,chi2=chi2,rchi2=rchi2, $
                        no_spec_error=no_spec_error, $
                        help=help,_extra=extra

;+
; NAME:
;    dustem_gb_plot_fit_sed
; PURPOSE:
;    Plots a model and SED. Parameter values and error are
;    printed on plot. Used for plotting results during fit.
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
;    dustem_gb_plot_fit_sed,ww,spec,sed[,/no_spec_error][,res=][,errors=][,chi2=][,rchi2=][/help][_extra=]
; INPUTS:
;    ww        = wavelengths for spec (micron)
;    spec      = Model spectrum
;    sed       = SED corresponding to the model
; 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_gb_plot_fit_sed,ww,spec,sed
; 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.
;-

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

use_col_sed_spec=170    ;color used for the model SED in spectrum channels
use_col_sed_filt=80    ;color used for the model SED in filters

use_model_color=150     ;color used for the model
use_model_line=3        ;linestyle used for the model

;=== plot the data SED
dustem_plot_data_sed,_extra=extra

;=== Over-Plot the computed SED
ind_filt=where((*!dustem_data.sed).filt_names NE 'SPECTRUM',count_filt)
ind_spec=where((*!dustem_data.sed).filt_names EQ 'SPECTRUM',count_spec)
IF count_filt NE 0 THEN BEGIN
  plotsym,8
66aff855   Jean-Philippe Bernard   modified to impro...
67
  cgoplot,((*!dustem_data.sed).wav)(ind_filt),sed(ind_filt),color=use_col_sed_filt,psym=8,syms=2
427f1205   Jean-Michel Glorian   version 4.2 merged
68
69
70
ENDIF
IF count_spec NE 0 THEN BEGIN
  plotsym,0
66aff855   Jean-Philippe Bernard   modified to impro...
71
  cgoplot,((*!dustem_data.sed).wav)(ind_spec),sed(ind_spec),color=use_col_sed_spec,psym=8,syms=0.5
427f1205   Jean-Michel Glorian   version 4.2 merged
72
73
74
75
ENDIF
;stop

;=== Over-Plot the Model
66aff855   Jean-Philippe Bernard   modified to impro...
76
cgoplot,ww,spec,color=use_model_color,linestyle=use_model_line
427f1205   Jean-Michel Glorian   version 4.2 merged
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

frmt0='(A20)'      ;used for parameter name
frmt1='(1E10.2)'   ;used for parameter value and error
frmt2='(E10.2)'    ;used for chi^2
IF keyword_set(res) THEN BEGIN
  offset=0.2
  xy_xpos=500.
  Npar=n_elements(res)
  FOR i=0L,Npar-1 DO BEGIN
    sstr=(str_sep((*(*!dustem_fit).param_descs)(i),'(*!dustem_params).'))
    ssstr=sstr(n_elements(sstr)-1)
    str=string(ssstr+'=',format=frmt0)+string(res(i),format=frmt1)
    IF keyword_set(errors) THEN BEGIN
      str=str+textoidl('\pm')+string(errors(i),format=frmt1)
    ENDIF
    xyouts,xy_xpos,10^(1.-(i+1)*offset),str
  ENDFOR
ENDIF
IF keyword_set(chi2) THEN BEGIN
  xyouts,xy_xpos,10^(1.-(Npar+1)*offset),string('chi2=',format=frmt0)+string(chi2,format=frmt2)
;stop
ENDIF
IF keyword_set(rchi2) THEN BEGIN
  xyouts,xy_xpos,10^(1.-(Npar+2)*offset),string('red. chi2=',format=frmt0)+string(rchi2,format=frmt2)
;stop
ENDIF

the_end:

END