Blame view

src/idl/dustem_gb_plot_fit_sed.pro 3.4 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
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

cdd2763e   Jean-Philippe Bernard   brought up to dat...
62
63
64
65
66
wav=(*(*!dustem_data).sed).wav
values=(*(*!dustem_data).sed).values
filt_names=(*(*!dustem_data).sed).filt_names
sigma=(*(*!dustem_data).sed).sigma

427f1205   Jean-Michel Glorian   version 4.2 merged
67
;=== Over-Plot the computed SED
cdd2763e   Jean-Philippe Bernard   brought up to dat...
68
69
ind_filt=where(filt_names NE 'SPECTRUM',count_filt)
ind_spec=where(filt_names EQ 'SPECTRUM',count_spec)
427f1205   Jean-Michel Glorian   version 4.2 merged
70
71
IF count_filt NE 0 THEN BEGIN
  plotsym,8
cdd2763e   Jean-Philippe Bernard   brought up to dat...
72
  cgoplot,wav[ind_filt],sed[ind_filt],color=use_col_sed_filt,psym=8,syms=2
427f1205   Jean-Michel Glorian   version 4.2 merged
73
74
75
ENDIF
IF count_spec NE 0 THEN BEGIN
  plotsym,0
cdd2763e   Jean-Philippe Bernard   brought up to dat...
76
  cgoplot,wav[ind_spec],sed[ind_spec],color=use_col_sed_spec,psym=8,syms=0.5
427f1205   Jean-Michel Glorian   version 4.2 merged
77
78
79
80
ENDIF
;stop

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

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