The photochemistry of the midlatitude ionosphere