Blame view

src/idl_extern/JPBLib_for_Dustemwrap/General/aos2soa.pro 459 Bytes
a6a77b32   Jean-Philippe Bernard   First commit
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
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