def mask_zero(data, tech, var='r', locations=None):
    """
    Mask where ``var`` for the technology ``tech``
    across the given list of ``locations`` is zero.

    ``var`` defaults to ``r``.

    If ``locations`` not given, uses all available locations.

    """
    df = data[var][tech]
    if locations:
        df = df.loc[:, locations]
    # Retain original resolution everywhere by default (0)
    mask = pd.Series(0, index=list(range(len(df))))
    # Sum over all locations to find those times where the data==0 everywhere
    mask[df.sum(1) <= 0] = 1
    mask.name = 'mask'
    return mask
dataset/ETHPy150Open calliope-project/calliope/calliope/time_masks.py/mask_zero/original