dustem_define_grid.pro
1.49 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
PRO dustem_define_grid,table_name,filters
;=== read the grid table
message,'reading grid data from '+table_name,/continue
info=file_info(table_name)
IF info.exists THEN BEGIN
st=mrdfits(table_name,1,h)
ENDIF ELSE BEGIN
message,'grid data '+table_name+' not found',/continue
stop
ENDELSE
;stop
;=== get filters and params names from grid table header
i=0L
table_filters=['']
fname='bidon'
count=1
WHILE count NE 0 DO BEGIN
fname=sxpar(h,'FNAME'+strtrim(i+1,2),count=count)
IF count NE 0 THEN table_filters=[table_filters,strtrim(fname,2)]
i=i+1
ENDWHILE
table_filters=table_filters[1:*]
Ntfilters=n_elements(table_filters)
table_params=['']
count=1
i=0L
WHILE count NE 0 DO BEGIN
pname=sxpar(h,'PNAME'+strtrim(i+1,2),count=count)
IF count NE 0 THEN table_params=[table_params,strtrim(pname,2)]
i=i+1
ENDWHILE
table_params=table_params[1:*]
Ntparams=n_elements(table_params)
;=== select only requested filters
;stop
Nfilters=n_elements(filters)
keep_tfilters=intarr(Ntfilters)
tags=tag_names(st)
FOR i=0L,Nfilters-1 DO BEGIN
ind=where(table_filters EQ filters[i],count)
IF count NE 0 THEN keep_tfilters[ind]=1
ENDFOR
;stop
;sst=st
FOR i=0L,Ntfilters-1 DO BEGIN
IF keep_tfilters[i] EQ 0 THEN BEGIN
col_name=tags[i+Ntparams]
st=structure_remove_column(st,col_name)
ENDIF
ENDFOR
Nsed=n_elements(st)
;stop
dustem_grid={Nsed:Nsed,Nfilters:Nfilters,Nparams:Ntparams,filters:filters,params:table_params,seds:st}
defsysv,'!dustem_grid',dustem_grid
message,'Defined !dustem_grid',/continue
END