Blame view

src/idl/dustem_param_range2param_values.pro 2.26 KB
d339db1c   Jean-Philippe Bernard   improved
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
FUNCTION dustem_param_range2param_values,iv_min,iv_max,iv_Nvalues,Nc=Nc,log=log,help=help


;+
; NAME:
;    dustem_param_range2param_values
; PURPOSE:
;    computes sets (combinations) of dustem parameter values with no duplicate combination, based on min-max values for each parameter
; CATEGORY:
;    Dustem
; CALLING SEQUENCE:
;    params_set=dustem_param_range2param_values(iv_min,iv_max,iv_Nvalues[,Nc=][,log=])
; INPUTS:
;    iv_min                 : minimum values of parameters (array of Npar values)
;    iv_max                 : maximum values of parameters (array of Npar values)
;    iv_Nvalues             : Number of individual parameter cvalues needed (array of Npar values)
; OPTIONAL INPUT PARAMETERS:
;    log                    : array indicating which parameter should be sampled in log scale (1) or linear scale (0). Default is linear for all parameters
; OUTPUTS:
;    params_set             :array of pointers containing parameter values (has Nc elements each pointing to an array of Npar values)
; OPTIONAL OUTPUT PARAMETERS:
;    Nc                     : nmeber of parameter combinations
; ACCEPTED KEY-WORDS:
;    help                   : If set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    
; PROCEDURE:
;    None
; EXAMPLES
;    res=dustem_param_range2param_values([0,2.],[8.,3.e1],[9,5],Nc=Nc,log=[0,1])
;    print,*res[13]
;      4.00000      3.93598
; MODIFICATION HISTORY:
;    Written by J.-Ph. Bernard (2023)
;    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_param_range2param_values'
  ivs=0.
  goto,the_end
ENDIF
205feff5   Jean-Philippe Bernard   First commit
48
49
50
51
52
53
54
55
56
57

Nparams=n_elements(iv_min)

;==compute number of combinations
Nc=1L
FOR i=0L,Nparams-1 DO Nc=Nc*iv_Nvalues[i]

;compute parameters possible values
par_values=ptrarr(Nparams)
FOR i=0L,Nparams-1 DO BEGIN
d339db1c   Jean-Philippe Bernard   improved
58
	vv=range_gen(iv_Nvalues[i],[iv_min[i],iv_max[i]],log=log[i])
205feff5   Jean-Philippe Bernard   First commit
59
60
61
62
63
64
65
66
67
68
69
70
	par_values[i]=ptr_new(vv)
ENDFOR
;=== compute combinations
ivs=ptrarr(Nc)

vec=fltarr(Nparams)      ;individual vector of parameter values
FOR i=0L,Nc-1 DO BEGIN
	ij=index2ij([i],iv_Nvalues)
	FOR j=0L,Nparams-1 DO BEGIN
		vec[j]=(*par_values[j])[ij[0,j]]
	ENDFOR
	ivs[i]=ptr_new(vec)
25370043   Jean-Philippe Bernard   src/idl/dustem_ac...
71
	;print,vec
205feff5   Jean-Philippe Bernard   First commit
72
73
74
	;stop
ENDFOR

d339db1c   Jean-Philippe Bernard   improved
75
the_end:
205feff5   Jean-Philippe Bernard   First commit
76
RETURN,ivs
d339db1c   Jean-Philippe Bernard   improved
77

205feff5   Jean-Philippe Bernard   First commit
78
END