def _norm_from_cdiff_data(data, norm=None):
    """Determines normalization type from ccorr data"""
    try:
        d, c, s1, s2 = data
    except:
        raise ValueError('Not a valid difference data')
    if s1 is None or s2 is None:
        default_norm = 1
    else:
        default_norm = 3
    if norm is None:
        return default_norm
    else:
        if norm not in (1, 3):
            raise ValueError('Normalization mode can be 1 or 3')
        if norm & default_norm == norm:
            return norm
        else:
            raise ValueError('Normalization mode incompatible with input data.'
                )
