Energy transfer channels at the diffraction-anomaly in transparent gratings and applications in sensors