FUNCTION dustem_mpfit_sed,tol=tol,Nitermax=Nitermax,gtol=gtol,xtol=xtol,function_name=function_name,_extra=_extra 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, $ maxiter=use_Nitermax,gtol=gtol,errmsg=errmsg,functargs=_extra) 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