def filter_catalog(catalog, **kwargs):
    bright_limit = kwargs.get('bright_limit', 1.00)
    max_bright = kwargs.get('max_bright', None)
    min_bright = kwargs.get('min_bright', 20)
    colname = kwargs.get('colname', 'vegamag')
    phot_column = catalog[colname]
    num_sources = len(phot_column)
    sort_indx = np.argsort(phot_column)
    if max_bright is None:
        max_bright = num_sources
    limit_num = max(int(num_sources * bright_limit), min_bright)
    limit_num = min(max_bright, limit_num, num_sources)
    new_catalog = catalog[sort_indx[:limit_num]]
    return new_catalog