def mask_extreme_week(data, tech, var='r', how='sum', what='min'):
    df = data[var][tech]
    # Get length of a day in timesteps
    day_len = int(24 / data.time_res_data)
    # Get day-wise sums
    dff_index = list(range(0, len(df), day_len))
    dff = df.rolling(window=day_len).sum().reindex(dff_index)
    # If what is 'min', this will get the 'idxmin' attribute (a method),
    # similar for 'max', else most likely raise an error!
    idx_extr = lambda x: getattr(x, 'idx{}'.format(what))
    if how == 'mode':
        # Find day where var/tech is min/max across the most locations
        selected = idx_extr(dff)().mode()[0]
    elif how == 'sum':
        # Find day where var/tech is min/max across all locations
        selected = idx_extr(dff.sum(axis=1))()
    d = data._dt.at[selected]
    # Determine the range for the calendar week
    # (7 days) to keep at full resolution
    week_start = selected - day_len * d.dayofweek
    week_end = selected + day_len * (7 - d.dayofweek)
    # Mask where everything is 1 (reduce resolution) by default
    mask = pd.Series(1, index=list(range(len(df))))
    # For the desired week, change the mask to native resolution (0)
    mask.loc[week_start:week_end - 1] = 0
    mask.name = 'mask'
    return mask
Compute a list of hashes for each block of data given by `filedata`.
dataset/ETHPy150Open calliope-project/calliope/calliope/time_masks.py/mask_extreme_week--crossover with--dataset/ETHPy150Open christabor/MoAL/MOAL/data_structures/hashes/hash_list.py/HashList.compute_hashes