Blame view

LabTools/IRAP/JPB/phangs_stellar_continuum_plugin_weight2params.pro 3.02 KB
0211d44a   Jean-Philippe Bernard   first commit
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
FUNCTION phangs_stellar_continuum_plugin_weight2params,weights,parameter_values=parameter_values,redenning=reddening,amplitude=amplitude, $
													force_include_reddening=force_include_reddening,force_include_amplitude=force_include_amplitude,help=help

;+
; NAME:
;    phangs_stellar_continuum_plugin_weight2params
; PURPOSE:
;    converts weights (and reddening and amplitude) into parameter decription and parameter value arrays. Only non-zero weights are set.
; CATEGORY:
;    DustEM
; CALLING SEQUENCE:
;    parameter_description=phangs_stellar_continuum_plugin_weight2params(weights[,parameter_values=][,redenning=][,amplitude=])
; INPUTS:
;    weights = a 2-D weights array (understood has having dimension [Nage,NZ])
; OPTIONAL INPUT PARAMETERS:
;    reddening  = reddening value (for null values, use an array [0.] to force setting the keyword)
;    amplitude  = amplitude value (for null values, use an array [0.] to force setting the keyword)
; OUTPUTS:
;    weights = weights array (dim [Nage,NZ])
; OPTIONAL OUTPUT PARAMETERS:
;    parameter_values = parameter values
; ACCEPTED KEY-WORDS:
;    force_include_reddening = if set, force including reddening as a parameter, even if redenning=0.
;    force_include_amplitude = if set, force including amplitude as a parameter, even if amplitude=0.
;    help                  = if set, print this help
; COMMON BLOCKS:
;    None
; SIDE EFFECTS:
;    None
; RESTRICTIONS:
;    
; PROCEDURE:
;    
; EXAMPLES
;    
; MODIFICATION HISTORY:
;    Written by JPB Jan 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,'phangs_stellar_continuum_plugin_weight2params'
  parameter_description=0.
  goto,the_end
ENDIF

params_str='dustem_plugin_phangs_stellar_continuum_'

Nage=(size(weights))[1]
NZ=(size(weights))[2]

parameter_description=['']
parameter_values=[0.]

IF keyword_set(amplitude) or keyword_set(force_include_amplitude) THEN BEGIN
	IF not keyword_set(amplitude) THEN use_amplitude=0. ELSE use_amplitude=amplitude
	parameter_description=[parameter_description,params_str+'1']
    parameter_values=[parameter_values,use_amplitude]
ENDIF

IF keyword_set(reddening) or keyword_set(force_include_reddening) THEN BEGIN
	IF not keyword_set(reddening) THEN use_reddening=0. ELSE use_reddening=reddening
	parameter_description=[parameter_description,params_str+'2']
    parameter_values=[parameter_values,use_reddening]
ENDIF

ij=lonarr(1,2)
pd_offset=n_elements(fpd)
weights_offset=2   ;first offset is element#2 of parameters
FOR i=0L,Nage-1 DO BEGIN
	FOR j=0L,NZ-1 DO BEGIN
		IF weights[i,j] NE 0. THEN BEGIN
			ij[0,0]=i
			ij[0,1]=j
			ind=ij2index(ij,[Nage,Nz])+weights_offset+1    ;+1 because parameters numbering start at 1
			parameter_description=[parameter_description,params_str+strtrim(ind[0],2)]
			parameter_values=[parameter_values,weights[i,j]] 
		ENDIF
	ENDFOR
ENDFOR

parameter_description=parameter_description[1:*]
parameter_values=parameter_values[1:*]

the_end:

RETURN,parameter_description

END