Imaging the outflow of ionospheric ions into the magnetosphere