  We describe a spin-echo method for ultracold neutrons (UCNs) confined in a
precession chamber and exposed to a $|B_0|=1~\text{\mu T}$ magnetic field. We
have demonstrated that the analysis of UCN spin-echo resonance signals in
combination with knowledge of the ambient magnetic field provides an excellent
method by which to reconstruct the energy spectrum of a confined ensemble of
neutrons. The method takes advantage of the relative dephasing of spins arising
from a gravitationally induced striation of stored UCN of different energies,
and also permits an improved determination of the vertical magnetic-field
gradient with an exceptional accuracy of $1.1~\text{pT/cm}$. This novel
combination of a well-known nuclear resonance method and gravitationally
induced vertical striation is unique in the realm of nuclear and particle
physics and should prove to be invaluable for the assessment of systematic
effects in precision experiments such as searches for an electric dipole moment
of the neutron or the measurement of the neutron lifetime.
