dustem_mpfit_sed.pro
1.75 KB
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
FUNCTION dustem_mpfit_sed,tol=tol,Nitermax=Nitermax,gtol=gtol,xtol=xtol,function_name=function_name
disp_str='====================================================='
IF not keyword_set(function_name) THEN BEGIN
func_name='dustem_mpfit_run'
ENDIF ELSE BEGIN
func_name=function_name
ENDELSE
functargs={plot_it:1}
use_tol=1.e-14 ;Default tolerance value
use_Nitermax=100 ;Default maximum number of iterations
IF keyword_set(tol) THEN use_tol=tol
IF keyword_set(Nitermax) THEN use_Nitermax=Nitermax
;modified to use our own mpfit (to allow for test on need to do color
;corrections for derivatives)
;p_min = mpfitfun(func_name,(*!dustem_data.sed).wav,(*!dustem_data.sed).values,(*!dustem_data.sed).sigma, $
p_min = dustem_mpfitfun(func_name,(*!dustem_data.sed).wav,(*!dustem_data.sed).values,(*!dustem_data.sed).sigma, $
parinfo=(*!dustem_parinfo), perror=perror, yfit=yfit, $
bestnorm=bestnorm, dof=dof,quiet=quiet, status=status, xtol=xtol, niter=niter_completed, ftol=use_tol, $
functargs=functargs,maxiter=use_Nitermax,gtol=gtol,errmsg=errmsg)
message,errmsg,/info
message,'mpfitfun Status='+strtrim(status,2),/info
;stop
p_dim=p_min*(*(*!dustem_fit).param_init_values)
p_er_dim=perror*(*(*!dustem_fit).param_init_values)
;PRINT RESULTS
print,'<°)))>< <°)))>< <°)))>< <°)))>< <°)))>< <°)))>< <°)))>< <°)))><'
print, 'Final parameters : ', p_dim
;=== store best fit values in syst variables
(*!dustem_fit).chi2=bestnorm
(*!dustem_fit).rchi2=bestnorm/dof
(*!dustem_fit).current_param_values=ptr_new(p_dim)
;The above was removed because it seems it was not used anywhere.
;!dustem_fit_sed=ptr_new(dustem_compute_sed(p_dim,st=st,cont=cont,_extra=extra))
(*!dustem_fit).current_param_errors=ptr_new(p_er_dim)
RETURN, p_dim
END