DO NOT USE ANY MORE - DEPRECIATED!

def compute_norrec_differences(df, keys_diff):
    """DO NOT USE ANY MORE - DEPRECIATED!

    """
    raise Exception('This function is depreciated!')
    print('computing normal-reciprocal differences')
    # df.sort_index(level='norrec')

    def norrec_diff(x):
        """compute norrec_diff"""
        if x.shape[0] != 2:
            return np.nan
        else:
            return np.abs(x.iloc[1] - x.iloc[0])

    keys_keep = list(set(df.columns.tolist()) - set(keys_diff))
    agg_dict = {x: _first for x in keys_keep}
    agg_dict.update({x: norrec_diff for x in keys_diff})
    for key in ('id', 'timestep', 'frequency'):
        if key in agg_dict:
            del(agg_dict[key])

    # for frequencies, we could (I think) somehow prevent grouping by
    # frequencies...
    df = df.groupby(('timestep', 'frequency', 'id')).agg(agg_dict)
    # df.rename(columns={'r': 'Rdiff'}, inplace=True)
    df.reset_index()
    return df