def clip_region(nc_variable, region_mask, t_index, y_min, y_max, x_min, x_max):
    s = len(nc_variable.shape)
    if (s == 2):
        return (region_mask * nc_variable[y_min:y_max, x_min:x_max])
    elif (s == 3):
        return (region_mask * nc_variable[t_index, y_min:y_max, x_min:x_max])
    elif (s == 4):
        return (region_mask * nc_variable[t_index, 0, y_min:y_max, x_min:x_max])
    else:
        print('Input array needs to have 2- to 4-dimensions: {0} were given.'.format(s))
def clip_region(nc_variable, region_mask, t_index, y_min, y_max, x_min, x_max):
    s = len(nc_variable.shape)
    if (s == 2):
        return (region_mask * nc_variable[y_min:y_max, x_min:x_max])
    elif (s == 3):
        return (region_mask * nc_variable[t_index, y_min:y_max, x_min:x_max])
    elif (s == 4):
        return (region_mask * nc_variable[t_index, 0, y_min:y_max, x_min:x_max])
    else:
        print('Input array needs to have 2- to 4-dimensions: {0} were given.'.format(s))