A real-space measure of the scale-by-scale distribution of turbulent kinetic energy was introduced in [P. A. Davidson, Turbulence: An Introduction for Scientists and Engineers (Oxford University Press, Oxford, 2004)], called the signature function. However, this signature function has two weaknesses. First, although measurements suggest that it is positive in fully developed turbulence, non-negative results cannot be guaranteed. Second, its definition involves derivatives, and so its calculation from experimental data is sensitive to noise. Here, we develop a refinement of the original signature function. This version improves on the original in that it can be shown to be strictly positive in isotropic turbulence. Moreover, it is obtained from experimental data through a process of integration, rather than differentiation, and so is less sensitive to noise. We apply this diagnostic to grid turbulence. Here the signature function is shown to recover many of the expected features of a scale-by-scale energy density. For example, it falls off below ten Kolmogorov scales and also for scales that exceed the integral scale. Moreover, it exhibits a 2/3 law in the inertial subrange, coupled to a bottleneck at the top of the dissipation range. We also apply the signature function to the near-wall region of smooth and rough-wall boundary layers. Although the diagnostic is not guaranteed to stay positive in such a shear layer, in practice it is observed to remain positive. As with grid turbulence, the signature function captures the expected features of a scale-by-scale energy distribution. In particular, it confirms that the energy of the large eddies near the wall scales on the square of the shear velocity.