'Calculate the value for the ``DATASUM`` card in the HDU.'

def _calculate_datasum(self, blocking):

    if self._has_data:
        byteorder = self.data.dtype.fields[self.data.dtype.names[0]][0].str[0]
        if (byteorder != '>'):
            if self.data.flags.writeable:
                byteswapped = True
                d = self.data.byteswap(True)
                d.dtype = d.dtype.newbyteorder('>')
            else:
                d = self.data.byteswap(False)
                d.dtype = d.dtype.newbyteorder('>')
                byteswapped = False
        else:
            byteswapped = False
            d = self.data
        byte_data = d.view(type=np.ndarray, dtype=np.ubyte)
        cs = self._compute_checksum(byte_data, blocking=blocking)
        if byteswapped:
            d.byteswap(True)
            d.dtype = d.dtype.newbyteorder('<')
        return cs
    else:
        return super(GroupsHDU, self)._calculate_datasum(blocking=blocking)
