def mask_extreme(data, tech, var='r', how='max',
                 length=24, locations=None, padding=None):
    df = data[var][tech]
    if locations:
        df = df.loc[:, locations]
    df = df.sum(axis=1)
    totals = []
    for i in range(0, len(df), length):
        totals.append(df[i:(i + 1) * length].sum(axis=0))
    totals = pd.Series(totals)
    if how == 'max':
        total_i = totals.argmax()
    elif how == 'min':
        total_i = totals.argmin()
    mask = pd.Series(1, index=list(range(len(df))))
    ifrom = total_i * length
    ito = (total_i + 1) * length - 1
    if padding:
        ifrom = ifrom - padding
        ito = ito + padding
        # Ensure ifrom and ito remain within bounds
        if ifrom < 0:
            ifrom = 0
        if ito > len(df):
            ito = len(df)
    mask.loc[ifrom:ito] = 0
    mask.name = 'mask'
    return mask
Returns the total number of instances of the given term
dataset/ETHPy150Open calliope-project/calliope/calliope/time_masks.py/mask_extreme--crossover with--dataset/ETHPy150Open dokipen/whoosh/src/whoosh/reading.py/IndexReader.frequency