Blame view

src/idl/dustem_mpfit_sed.pro 1.77 KB
9ccf7615   Jean-Philippe Bernard   modified to fit u...
1
FUNCTION dustem_mpfit_sed,tol=tol,Nitermax=Nitermax,gtol=gtol,xtol=xtol,function_name=function_name,_extra=_extra
427f1205   Jean-Michel Glorian   version 4.2 merged
2
3
4
5
6
7
8
9
10

disp_str='====================================================='

IF not keyword_set(function_name) THEN BEGIN
  func_name='dustem_mpfit_run'
ENDIF ELSE BEGIN
  func_name=function_name
ENDELSE

9ccf7615   Jean-Philippe Bernard   modified to fit u...
11
;functargs={plot_it:1}
427f1205   Jean-Michel Glorian   version 4.2 merged
12
13
14
15
16
17
18
19
20
21
22
23
24

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, $
9ccf7615   Jean-Philippe Bernard   modified to fit u...
25
                 maxiter=use_Nitermax,gtol=gtol,errmsg=errmsg,functargs=_extra)
427f1205   Jean-Michel Glorian   version 4.2 merged
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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