Wavelength measurement of narrowband terahertz radiation using a diffraction grating