def function(self,p):
        """
        Return a square-wave grating (alternating black and white bars).
        """
        return np.around(
            0.5 +
            0.5*np.sin(pi*(p.duty_cycle-0.5)) +
            0.5*np.sin(p.frequency*2*pi*self.pattern_y + p.phase))