dustem_init_fixed_params.pro 3.14 KB
PRO dustem_init_fixed_params,fpd,fiv

;+
; 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_params, pd, iv, [,fpd=fpd,fiv=fiv,ulimed=ulimed,llimed=llimed,ulims=ulims,lolims=llims,tied=tied,fixed=fixed]
;  
; INPUTS:
;    model -- the dust model
;    pd -- the parameter description vector
;    iv -- the initial values of the free parameters 
;
; OPTIONAL INPUT PARAMETERS:
;    
;
; OUTPUTS:
;    None
;
; OPTIONAL OUTPUT PARAMETERS:
;    None
;
; ACCEPTED KEY-WORDS:
;    model = specifies the interstellar dust mixture used by DustEM
;           'MC10' model from Compiegne et al 2010 (default)
;           'DBP90' model from Desert et al 1990
;           'DL01' model from Draine & Li 2001
;           'WD01_RV5p5B' model from Weingartner & Draine 2002 with Rv=5.5
;           'DL07' model from Draine & Li 2007
;           'J13' model from Jones et al 2013, as updated in
;                 Koehler et al 2014
;           'G17_ModelA' model A from Guillet et al (2018). Includes
;                 polarisation. See Tables 2 and 3 of that paper for details.
;           'G17_ModelB' model B from Guillet et al (2018)
;           'G17_ModelC' model C from Guillet et al (2018)
;           'G17_ModelD' model A from Guillet et al (2018)
;    help      = if set, print this help
;
; 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

;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, it's 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 use the regular parameter system variables to update
(*!dustem_fit).param_descs=ptr_new(fpd)
(*!dustem_fit).param_init_values=ptr_new(fiv)
dustem_set_func_ind,fpd,fiv
ind=where(fpd NE '',count)

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

;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 

the_end:
END