<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_percolation_threshold(self):
 r""" Find the invasion threshold at which a cluster spans from the inlet to the outlet sites """

        if np.sum(self['pore.inlets']) == 0:
            raise Exception('Inlet pores must be specified first')
        if np.sum(self['pore.outlets']) == 0:
            raise Exception('Outlet pores must be specified first')
        else:
            Pout = self['pore.outlets']
        # Do a simple check of pressures on the outlet pores first...
        if self.settings['access_limited']:
            thresh = np.amin(self['pore.invasion_pressure'][Pout])
        else:
            raise Exception('This is currently only implemented for access ' +
                            'limited simulations')
        return thresh