def add_slab(self, height, n_background=1., position='top'):
        '''
        Creates and adds a :class:`Slab` object.

        Args:
            height (float): Height of the slab.
            n_background (float): The nominal refractive
                index of the slab.  Default is 1 (air).

        Returns:
            str: The name of the slab.
        '''
        assert position in ('top', 'bottom')

        name = str(self.slab_count)

        if not callable(n_background):
            n_back = lambda wl: n_background
        else:
            n_back = n_background

        height_discretised = self.y_step*((height // self.y_step) + 1)

        y_min = self._next_start
        y_max = y_min + height_discretised
        self.slabs[name] = Slab(name, self.x_step, self.y_step, self.x_max,
                                 y_max, self.x_min, y_min, n_back, self._wl)

        self.y_max = y_max
        self._next_start = y_min + height_discretised
        self.slab_count += 1

        if position == 'bottom':
            slabs = {}
            for k in self.slabs.keys():
                slabs[str(int(k)+1)] = self.slabs[k]
            slabs['0'] = slabs.pop(str(self.slab_count))
            self.slabs = slabs

        return name
Creates and adds a :class:`Slab` object.

        Args:
            height (float): Height of the slab.
            n_background (float): The nominal refractive
                index of the slab.  Default is 1 (air).

        Returns:
            str: The name of the slab.