Atomic nitrogen ions in the upper atmosphere