def apply_calibration_tables(cb, calibration_tables):
    """Applies calibration tables to an open calibrater object.

    Parameters
    ----------
    cb : cc.calibrater() instance
        Measurement set should be opened already.
    calibration_tables : list
        Calibration tables to apply. Each entry is a dictionary containing the
        keywords 'type' (calibration type, e.g. 'K'), 'spwmap' (spwmap for the
        calibration), and 'table' (full path to the calibration table).

    Returns
    -------
    int
        The number of errors that occured during calibration.
    """
    error = 0
    for caltable in calibration_tables:
        error += not cb.setapply(type=caltable['type'],
                                 spwmap=caltable['spwmap'],
                                 table=caltable['table'])
    return error