Coherence theory of the electromagnetic field