phangs_binid2weights.pro
1.18 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
FUNCTION phangs_binid2weights,st_muse_weights,vid,st_templates,age_values,metalicity_values,reddening=reddening
;stop
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
RETURN,weights
END