phangs_binid2weights.pro
2.5 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
FUNCTION phangs_binid2weights,st_muse_weights,vid,st_templates,age_values,metalicity_values,reddening=reddening,help=help
;+
; NAME:
; phangs_binid2weights
; PURPOSE:
; get the Muse weights of a given Muse voronoi bin
; CATEGORY:
; DustEM
; CALLING SEQUENCE:
; weights=phangs_binid2weights(st_muse_weights,vid,st_templates,age_values,metalicity_values[,reddening=])
; INPUTS:
; st_muse_weights = Muse weiths structure
; vid = Voronoi ID
; st_templates = Muse templates info structure (as returned by read_muse_templates_info.pro)
; age_values = age values (to be compares with st_templates.age)
; metalicity_values = Z values (to be compares with st_templates.Z)
; OPTIONAL INPUT PARAMETERS:
; None
; OUTPUTS:
; weights = weights array (dim [Nage,NZ])
; OPTIONAL OUTPUT PARAMETERS:
; reddening = redenning value for that bin (E(B-V))
; ACCEPTED KEY-WORDS:
; help = if set, print this help
; COMMON BLOCKS:
; None
; SIDE EFFECTS:
; None
; RESTRICTIONS:
; The DustEMWrap IDL code must be installed
; PROCEDURE:
; Scans the grid SEDs to find the best fit (lowest chi2)
; 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_binid2weights'
weights=0.
goto,the_end
ENDIF
ind=where(st_muse_weights.bin_id EQ vid,count)
IF count EQ 0 THEN BEGIN
message,'bin '+strtrim(vid,2)+' not found in structure provided',/continue
stop
ENDIF
st=st_muse_weights[ind]
reddening=st.reddening
Nage=n_elements(age_values)
NZ=n_elements(metalicity_values)
Nweights=Nage*Nz
weights=fltarr(Nage,Nz)
;help,age_values,metalicity_values,weights
;stop
tagnames=tag_names(st)
FOR i=0L,Nweights-1 DO BEGIN
indd=where(tagnames EQ 'W_'+strtrim(i,2),ccount)
value=st.(indd)
IF value NE 0 THEN BEGIN
ind=where(st_templates.id EQ i,count)
ii=where(age_values EQ st_templates[ind].age,counti)
jj=where(metalicity_values EQ round(st_templates[ind].Z*100.)/100.,countj)
IF counti NE 1 and countj NE 1 THEN BEGIN
message,'metalicity or age not found',/continue
stop
ENDIF
;ij=index2ij([i],[Nage,NZ])
;weights[ij[0,0],ij[0,1]]=st.(indd)
weights[ii,jj]=st.(indd)
message,'Found non zero weight '+strtrim(value,2)+' at age['+strtrim(ii,2)+']='+strtrim(age_values[ii],2)+' Z['+strtrim(jj,2)+']='+strtrim(metalicity_values[jj],2),/info
ENDIF
ENDFOR
the_end:
RETURN,weights
END