dustem_marginalize_grid.pro
3 KB
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
91
PRO dustem_marginalize_grid,fixed_parameters_description $
,fixed_parameters_values $
,seds $
,Nseds $
,Nparams $
,table_params $
,table_pmins $
,table_pmaxs $
,help=help
;+
; NAME:
; dustem_marginalize_grid
; PURPOSE:
; marginalize a grid on given fixed parameter
; CATEGORY:
; Dustem
; CALLING SEQUENCE:
; dustem_marginalize_grid,fixed_parameters_description,fixed_parameters_values,seds,Nseds,Nfilters,Nparams,table_params,table_pmins,table_pmaxs
; INPUTS:
; fixed_parameters_description : fixed parameters description
; fixed_parameters_values : fixed parameters values
; seds : sed grid to be marginalized (also an output)
; Nseds : Number of seds (also an output)
; Nparams : Number of parameters in sed grid (also an output)
; table_params : description of parameters in sed grid (also an output)
; table_pmins : min values of parameters in sed grid (also an output)
; table_pmaxs : max values of parameters in sed grid (also an output)
; OPTIONAL INPUT PARAMETERS:
; NONE
; OUTPUTS:
; None
; OPTIONAL OUTPUT PARAMETERS:
; seds : sed grid to be marginalized (also an output)
; Nseds : Number of seds (also an output)
; Nparams : Number of parameters in sed grid (also an output)
; table_params : description of parameters in sed grid (also an output)
; table_pmins : min values of parameters in sed grid (also an output)
; table_pmaxs : max values of parameters in sed grid (also an output)
; ACCEPTED KEY-WORDS:
; help = If set, print this help
; COMMON BLOCKS:
; None
; SIDE EFFECTS:
; None
; RESTRICTIONS:
; ;Caution: grids should have regularly spaced parameter values for this to work
; PROCEDURE:
; None
; EXAMPLES
;
; MODIFICATION HISTORY:
; Written by J.-Ph. Bernard (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_marginalize_grid'
goto,the_end
ENDIF
N_fixed_params=n_elements(fixed_parameters_description)
;Nparams=!dustem_grid.Nparams
FOR i=0L,N_fixed_params-1 DO BEGIN
ind=where(table_params EQ fixed_parameters_description[i],count,complement=indc,ncomplement=nc)
IF count NE 0 THEN BEGIN
fixed_parameter_value=fixed_parameters_values[ind[0]]
;compute distance between table parameter and the requested fixed value
distance=abs(fixed_parameter_value-seds[*].(ind[0]))
indd=where(distance EQ min(distance),ccount)
IF ccount EQ 0 THEN BEGIN
message,'This should not happen',/continue
stop
ENDIF
seds=seds[indd]
;Nseds=n_elements(seds) ;or ccount
Nseds=ccount
table_params=table_params[indc]
Nparams=nc
table_pmins=table_pmins[indc]
table_pmaxs=table_pmaxs[indc]
ENDIF
ENDFOR
the_end:
END