aos2soa.pro 459 Bytes
FUNCTION aos2soa,st

;transform a structure of arrays into an array of structures

Ntags=N_tags(st)
tagnames=tag_names(st)
Nel=n_elements(st.(0))

one_st={bidon:0.}
out_st=replicate(one_st,Nel)

FOR i=0,Ntags-1 DO BEGIN
	col_name=tagnames[i]
	col_example=(st.(i))[0]
	out_st=structure_add_column(out_st,col_name,col_example)
ENDFOR
out_st=structure_remove_column(out_st,'BIDON')

FOR i=0,Ntags-1 DO BEGIN
   out_st.(i)=st.(i)
ENDFOR

;stop

RETURN,out_st

END