pro swe_3d_stitch
@mvn_swe_com
ddd = {time : 0D , $
met : 0D , $
n_e : 0 , $
group : 0B , $
period : 0B , $
npkt : 0B , $
lut : 0B , $
data : fltarr(80,64) , $
var : fltarr(80,64) }
if (size(a0,/type) eq 8) then begin
npkt = n_elements(a0)
e0 = a0.e0
istart = where(e0 eq 0, n3d)
swe_3d = replicate(ddd, n3d)
swe_3d.time = a0[istart].time
swe_3d.met = a0[istart].met
swe_3d.group = a0[istart].group
swe_3d.period = a0[istart].period
swe_3d.npkt = a0[istart].npkt
swe_3d.lut = a0[istart].lut
swe_3d.n_e = swe_ne[swe_3d.group]
nframes = swe_3d.n_e/16
for i=0L,(n3d-1L) do begin
if ((istart[i]+nframes[i]) le npkt) then begin
for j=0,(nframes[i]-1) do begin
if (e0[istart[i]+j] eq j) then begin
k = j*16
swe_3d[i].data[*,k:(k+15)] = a0[istart[i]+j].data
swe_3d[i].var[*,k:(k+15)] = a0[istart[i]+j].var
endif else print,"A0 frame out of order: ",istart[i] + j
endfor
endif else print,"A0 not enough frames left: ",istart[i]
endfor
endif
if (size(a1,/type) eq 8) then begin
npkt = n_elements(a1)
e0 = a1.e0
istart = where(e0 eq 0, n3d)
tframe = a1.time
tstart = tframe[istart]
swe_3d_arc = replicate(ddd, n3d)
swe_3d_arc.time = a1[istart].time
swe_3d_arc.met = a1[istart].met
swe_3d_arc.group = a1[istart].group
swe_3d_arc.period = a1[istart].period
swe_3d_arc.npkt = a1[istart].npkt
swe_3d_arc.lut = a1[istart].lut
swe_3d_arc.n_e = swe_ne[swe_3d_arc.group]
nframes = swe_3d_arc.n_e/16
for i=0L,(n3d-1L) do begin
if ((istart[i]+nframes[i]) le npkt) then begin
dt = where(tframe[istart[i]:(istart[i]+nframes[i]-1)] ne tstart[i],count)
if (count eq 0L) then begin
for j=0,(nframes[i]-1) do begin
if (e0[istart[i]+j] eq j) then begin
k = j*16
swe_3d_arc[i].data[*,k:(k+15)] = a1[istart[i]+j].data
swe_3d_arc[i].var[*,k:(k+15)] = a1[istart[i]+j].var
endif else print,"A1 frame out of order: ",istart[i] + j," ",j," ",nframes[i]
endfor
endif else print,"A1 frames have different time tags: ",istart[i]," ",time_string(tstart[i])
endif else print,"A1 not enough frames left: ",istart[i]
endfor
endif
return
end