Count how many times each individual hydrogen bonds occured throughout the simulation.
        Returns numpy array.

def count_by_type(self,table,timesteps):
        """Count how many times each individual hydrogen bonds occured throughout the simulation.
        Returns numpy array."""
        hbonds = defaultdict(int)
        for contact in table:
            #count by residue name not by proteinring
            pkey = (contact.donor_idx,contact.acceptor_idx,contact.donor_atom, contact.acceptor_atom,contact.donor_resnm,contact.donor_resid, contact.acceptor_resnm,contact.acceptor_resid)
            hbonds[pkey]+=1
        dtype = [("donor_idx",int),("acceptor_idx",int),("donor_atom","|U4"),("acceptor_atom","|U4"),("donor_resnm","|U8"),("donor_resid","|U8"),("acceptor_resnm","|U8"),("acceptor_resid","|U8"),("frequency",float) ]
        out = np.empty((len(hbonds),),dtype=dtype)
        tsteps = float(len(timesteps))
        for cursor,(key,count) in enumerate(hbonds.iteritems()):
            out[cursor] = key + (count / tsteps,)
        return out.view(np.recarray)