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