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 oplot,((*!dustem_data.sed).wav)(ind_filt),sed(ind_filt),color=use_col_sed_filt,psym=8,syms=2 ENDIF IF count_spec NE 0 THEN BEGIN plotsym,0 oplot,((*!dustem_data.sed).wav)(ind_spec),sed(ind_spec),color=use_col_sed_spec,psym=8,syms=0.5 ENDIF ;stop ;=== Over-Plot the Model oplot,ww,spec,color=use_model_color,linestyle=use_model_line 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