dustem_greybody_mpfit.pro 2.05 KB
FUNCTION dustem_greybody_mpfit,x,params,_EXTRA=extra,cc_sed=cc_sed,help=help

;+
; NAME:
;    dustem_greybody_mpfit
; PURPOSE:
;    function used to fit greybody with dustem_mpfit_sed
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
;    res=dustem_greybody_mpfit(x,params[,_EXTRA=extra][,cc_sed=cc_sed][,/help])
; INPUTS:
;    x         = necessary for interface but unused
;    params    = Model parameters normalized to initial values ([amplitude,T,beta])
; OPTIONAL INPUT PARAMETERS:
;    cc_sed    = SED color correction factors
;    _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 if !dustem_show_plot
; RESTRICTIONS:
;    The dustem idl wrapper must be installed
; PROCEDURE:
;    None
; EXAMPLES
;    res=dustem_greybody_mpfit(x,params[,_EXTRA=extra][,cc_sed=cc_sed][,/help])
; 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_greybody_mpfit'
  sed=0.
  goto,the_end
ENDIF

pp=params*(*(*!dustem_fit).PARAM_INIT_VALUES)

;sed=dustem_compute_gb_sed(pp,_extra=extra,waves=ww,spec=spectre)
sed=dustem_compute_gb_sed_fast(pp,_extra=extra,waves=ww,spec=spectre)
;stop
;====== Plot if needed
IF !dustem_show_plot NE 0 THEN BEGIN
  dustem_gb_plot_fit_sed,ww,spectre,sed,_extra=extra,res=params*(*(*!dustem_fit).param_init_values),chi2=(*!dustem_fit).chi2,rchi2=(*!dustem_fit).rchi2
;  wait,0.1  ;Sorry for efficiency but needed to see the plot
ENDIF

;=== Caution, do not use message below here, even
;=== with the /info and /continue options, or the
;=== fit procedure will detect an error !
;=== use print instead.
;IF defined(extra) THEN BEGIN
;  IF keyword_set(extra.plot_it) THEN BEGIN
;    print,'dustem_greybody_mpfit: Current parameters values:',pp
;  ENDIF
;ENDIF

the_end:

RETURN,sed
END