Thermal radiative properties of disordered media and deep metal gratings