def remove_s_mean(data, mean):
    """Remove the spatial mean of a time series matrix
    """
    n = min(data.shape[0],data.shape[1])
    for i in range(0, n):
        if data.shape[0]==n:
            data[i] -= mean[i]
        else :
            data[:,i] -= mean[i]
    return data