pro mvn_swia_swindave, reg = reg, npo = npo
common mvn_swia_data
if not keyword_set(npo) then npo = 1
if keyword_set(reg) then begin
ureg = interpol(reg.y(*,0),reg.x,swim.time_unix+2.0)
w = where(ureg eq 1)
uswim = swim(w)
endif else begin
uswim = swim
endelse
times = uswim.time_unix
vels = sqrt(total(uswim.velocity*uswim.velocity,1))
densities = uswim.density
orb = mvn_orbit_num(time = times)
orb = floor(orb*npo)
mino = min(orb)
maxo = max(orb)
norb = maxo-mino+1
nout = fltarr(norb)
vout = fltarr(norb)
tout = dblarr(norb)
for i = 0,norb-1 do begin
w = where(orb eq (mino+i),nw)
if nw gt 10 then begin
nout(i) = mean(densities(w),/nan)
vout(i) = mean(vels(w),/nan)
tout(i) = mean(uswim(w).time_unix,/double,/nan)
endif
endfor
w = where(tout ne 0)
store_data,'nsw',data = {x:tout(w),y:nout(w)}
store_data,'vsw',data = {x:tout(w),y:vout(w)}
end