  Inhomogeneous media commonly support a discrete number of wave modes that are
trapped along interfaces defined by spatially varying parameters. When they are
robust against continuous deformations of parameters, such waves are said to be
of topological origin. It has been realized over the last decades that such
waves of topological origin can be predicted by computing a single topological
invariant, the first Chern number, in a dual bulk wave problem that is much
simpler to solve than the original wave equation involving spatially varying
coefficients. The correspondence between the simple bulk problem and the more
complicated interface problem is usually justified by invoking an abstract
index theorem. Here, by applying ray tracing machinery to the paradigmatic
example of equatorial shallow water waves, we propose a physical interpretation
of this correspondence. We first compute ray trajectories in a phase space
given by position and wavenumber of the wave packet, using Wigner-Weyl
transforms. We then apply a quantization condition to describe the spectral
properties of the original wave operator. We show that the Chern number emerges
naturally from this quantization relation.
