dustem_set_params.pro 2.37 KB
PRO dustem_set_params,params,help=help

;+
; NAME:
;    dustem_set_params
;
; PURPOSE:
;    Initialise the *!dustem_fit system variable with the free
;    parameters used in the fit and their general handling by DustEMWrap.
;
; CATEGORY:
;    DustEMWrap, Mid-Level, Distributed, Initialization
;
; CALLING SEQUENCE:
;    dustem_set_params,params[,/help]
;
; INPUTS:
;    params -- free parameters to be used in the fit
;
; OPTIONAL INPUT PARAMETERS:
;
; OUTPUTS:
;    None
;
; OPTIONAL OUTPUT PARAMETERS:
;    None
;
; ACCEPTED KEY-WORDS:
;    help      = If set print this help
;
; COMMON BLOCKS:
;    None
;
; SIDE EFFECTS:
;    initializes information in !dustem_fit
;
; RESTRICTIONS:
;    The DustEMWrap IDL code must be installed
; 
; PROCEDURE:
;    None
;
; EXAMPLES
;
; MODIFICATION HISTORY:
;    Written by J.-Ph. Bernard 2007
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-

IF keyword_set(help) THEN BEGIN
  doc_library,'dustem_set_params'
  goto,the_end
ENDIF

;if empty description, do nothing
ind=where(*(*!dustem_fit).param_descs EQ '',count)
IF count EQ n_elements(*(*!dustem_fit).param_descs) THEN BEGIN
  message,'param_descs not set. Doing nothing',/continue
  stop
  goto,the_end
ENDIF

;stop
Nparams=n_elements(*(*!dustem_fit).param_descs)
IF n_elements(params) NE Nparams THEN BEGIN
    message,'Inconsistent number of parameters passed',/info
    stop
ENDIF

;Trimmed JPB on 08 March 2024
;dustem_set_func_ind,*(*!dustem_fit).param_descs,params

;SET THE PARAMETER VALUES IN DUSTEM INPUT FILES
FOR i=0L,Nparams-1 DO BEGIN
    
   status=dustem_parameter_description2type((*(*!dustem_fit).param_descs)[i],string_name=string_name)
   IF !dustem_verbose THEN BEGIN
        message,(*(*!dustem_fit).param_descs)[i]+' is '+status,/continue
   ENDIF
   
   CASE status OF
    'WRAPPER': BEGIN
        str=(*(*!dustem_fit).param_descs)(i)+'=params[i]'
        toto=execute(str)
        IF !dustem_verbose NE 0 THEN message,str,/info
    END
    'FORTRAN': BEGIN
        str=(*(*!dustem_fit).param_descs)(i)+'=params[i]';'=params['+strtrim(string(i),2)+']'
        toto=execute(str)
        IF !dustem_verbose NE 0 THEN message,str,/info
    END
    'PLUGIN': BEGIN 
    
    ;Not to be used for the moment.
    
    END
   ENDCASE
ENDFOR

;==== This writes the input files for the fortran
dustem_write_all,*!dustem_params,!dustem_dat

the_end:

END