Measuring amplitude and phase distribution of fields generated by gratings with sub-wavelength resolution