def quantity_value(halo, field, operator, value, units):
    """
    Filter based on a value in the halo quantities dictionary.

    Parameters
    ----------
    halo : Halo object
        The Halo object to be provided by the HaloCatalog.
    field : string
        The field used for the evaluation.
    operator : string 
        The comparison operator to be used ("<", "<=", "==", ">=", ">", etc.)
    value : numneric
        The value to be compared against.
    units : string
        Units of the value to be compared.
        
    """
    if field not in halo.quantities:
        raise RuntimeError('Halo object does not contain %s quantity.' % field)
    h_value = halo.quantities[field].in_units(units).to_ndarray()
    return eval('%s %s %s' % (h_value, operator, value))
