A wavenumber calibration protocol is proposed that replaces polynomial fitting to relate the detector axis and the wavenumber shift. The physical model of the Raman spectrometer is used to derive a mathematical expression relating the detector plane to the wavenumber shift, in terms of the system parameters including the spectrograph focal length, the grating angle, and the laser wavelength; the model is general to both reflection and transmission gratings. A fast search algorithm detects the set of parameters that best explains the position of spectral lines recorded on the detector for a known reference standard. Using three different reference standards, four different systems, and hundreds of spectra recorded with a rotating grating, we demonstrate the superior accuracy of the technique, especially in bands outside of the outermost reference peaks when compared with polynomial fitting. We also provide a thorough review of wavenumber calibration for Raman spectroscopy and we introduce several new evaluation metrics to this field borrowed from chemometrics, including leave-one-out and leave-half-out cross-validation.