def count_by_type(self):
        """Count how many times each individual pi-pi interaction occured throughout the simulation.
        Returns numpy array."""
        pistack = defaultdict(int)
        for contact in self.timeseries:
            #count by residue name not by proteinring
            pkey = (contact.ligandring,contact.type, contact.resid,contact.resname,contact.segid)
            pistack[pkey]+=1
        dtype = [("ligand_ring_ids",list),("type","|U4"),("resid",int),("resname","|U4"),("segid","|U8"),("frequency",float) ]
        out = np.empty((len(pistack),),dtype=dtype)
        tsteps = float(len(self.timesteps))
        for cursor,(key,count) in enumerate(pistack.iteritems()):
            out[cursor] = key + (count / tsteps,)
        return out.view(np.recarray)