dustem_init_fixed_params.pro 2.82 KB
PRO dustem_init_fixed_params,fpd,fiv,help=help,clear=clear

;+
; NAME:
;    dustem_init_fixed_params
;
; PURPOSE:
; This routine updates the fixed parameters of both the
; dust models and plugins in the input files
;  
; CATEGORY:
;    DustEMWrap, Distributed, Low-Level, Initialization
;
; CALLING SEQUENCE:
;    dustem_init_fixed_params, fpd, fiv
;  
; INPUTS:
;    fpd -- the fixed parameter description vector
;    fiv -- the initial values of the fixed parameters 
;
; OPTIONAL INPUT PARAMETERS:
;    
; OUTPUTS:
;    None
;
; OPTIONAL OUTPUT PARAMETERS:
;    None
;
; ACCEPTED KEY-WORDS:
;    help      = if set, print this help
;    clear     = if set, clear all existing fixed parameters
;
; COMMON BLOCKS:
;    None
;
; SIDE EFFECTS:
;    None
;
; RESTRICTIONS:
;    The DustEM fortran code must be installed
;    The DustEMWrap IDL code must be installed
;
; PROCEDURES AND SUBROUTINES USED:
;   dustem_init_parinfo
;   dustem_init_plugins
;   dustem_init_fixed_params
;  
; EXAMPLES
;
; MODIFICATION HISTORY:
;    Written by AH October-2022
;    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_init_fixed_params'
  goto,the_end
END

if keyword_set(clear) then begin
;   message,'Clearing the fixed parameters',/info
;   stop
   (*!dustem_fit).fixed_param_descs=ptr_new()
   (*!dustem_fit).fixed_param_init_values=ptr_new()
  goto,the_end
end

;Save the values of fit parameter descriptions and values
need_save=0
;This routine will use (*!dustem_fit).param_descs)
;Therefore, if the variable already exists, its content is saved, and will be put back in place later
IF ptr_valid((*!dustem_fit).param_descs) THEN BEGIN
  pd=*(*!dustem_fit).param_descs
  iv=*(*!dustem_fit).param_init_values
  ;find=*(*!dustem_fit).param_func
  need_save=1
ENDIF

;TEMPORARILY put FPD and FIV into the regular parameter system
;variables. This allows us to the use the dustem_set_params routine
(*!dustem_fit).param_descs=ptr_new(fpd)
(*!dustem_fit).param_init_values=ptr_new(fiv)
;Trimmed JPB on 08 March 2024
;dustem_set_func_ind,fpd,fiv
ind=where(fpd NE '',count)

;fixing the parameters
IF count NE 0 THEN $
  dustem_set_params,[fiv]

;set the fixed system variables, used to keep memory of the fixed
;parameters description and values
(*!dustem_fit).fixed_param_descs=ptr_new(fpd)
(*!dustem_fit).fixed_param_init_values=ptr_new(fiv)

;put back in place fit parameter descriptions and values into system variables, if needed.
IF need_save EQ 1 THEN BEGIN
  (*!dustem_fit).param_descs=ptr_new(pd)
  (*!dustem_fit).param_init_values=ptr_new(iv)
  ;(*!dustem_fit).param_func=ptr_new(find)
ENDIF 
IF need_save EQ 0 THEN BEGIN
  (*!dustem_fit).param_descs=ptr_new()
  (*!dustem_fit).param_init_values=ptr_new()
  ;(*!dustem_fit).param_func=ptr_new(find)
ENDIF 

the_end:
END