dustem_get_param_values_default.pro 2.44 KB
FUNCTION dustem_get_param_values_default,param_descs,param_current_values=param_current_values,verbose=verbose,help=help

;+
; NAME:
;    dustem_get_param_values_default
; PURPOSE:
;    returns the default values of dust model parameters for the model currently in use by dustemwrap
; CATEGORY:
;    Dustem, Distributed, Mid-Level
; CALLING SEQUENCE:
;    res=dustem_get_param_values_default(param_descs[,param_current_values=][,/verbose][,/help])
; INPUTS:
;    param_descs = parameter description
; OPTIONAL INPUT PARAMETERS:
;    None
; OUTPUTS:
;    res: parameters default values
; OPTIONAL OUTPUT PARAMETERS:
;    param_current_values : parameters current values
; ACCEPTED KEY-WORDS:
;    help         = If set, print this help
;    verbose      = If set, prints results
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    The DustEM fortran code must be installed
;    The DustEMWrap idl code must be installed
;    dustem_init must have been run
; PROCEDURE:
;    default parameter values are read using dustem_read_all.pro
;    current parameter values are taken from !dustem_params
; EXAMPLES
;	dustem_init,model='DBP90'
;	res=dustem_get_param_values_default(/verbose,['(*!dustem_params).grains[0].MDUST_O_MH','(*!dustem_params).grains[1].MDUST_O_MH'],param_current_values=param_current_values)
; MODIFICATION HISTORY:
;    Written by JPB Mai-2024
;    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_get_param_values_default'
  param_default_values=0.
  goto,the_end
ENDIF

use_param_descs=[param_descs]
Nparams=n_elements(use_param_descs)

;==== This reads the default parameter values into st_model
dir_in=!dustem_soft_dir
st_model=dustem_read_all(dir_in,/silent)

param_current_values=dblarr(Nparams)
param_default_values=dblarr(Nparams)
str_to_be_replaced='(*!dustem_params)'
str_to_replace='st_model'

FOR i=0L,Nparams-1 DO BEGIN
  str='aa='+param_descs[i]
  toto=execute(str)
  param_current_values[i]=aa
  str='aa='+textoidl_str_replace(param_descs[i],str_to_be_replaced,str_to_replace)
  toto=execute(str)
  param_default_values[i]=aa  
ENDFOR

IF keyword_set(verbose) THEN BEGIN
  message,'Default parameter values',/continue
  FOR i=0L,Nparams-1 DO BEGIN
  	message,param_descs[i]+' current ='+strtrim(param_current_values[i],2)+' default ='+strtrim(param_default_values[i],2),/info
  ENDFOR
ENDIF

the_end:
RETURN,param_default_values

END