Calculate median absolute deviation of data array

def flag_calcmad(data):
    """ Calculate median absolute deviation of data array """

    absdev = np.abs(data - np.median(data))
    return np.median(absdev)