def apply_purging(self, catalogue, flag_vector, magnitude_table):
        '''
        Apply all the various purging conditions, if specified.

        :param catalogue:
            Earthquake catalogue as instance of :class:`openquake.hmtk.seismicity.catalogue.Catalogue`
        :param numpy.array flag_vector:
            Boolean vector specifying whether each event is valid (therefore
            written) or otherwise
        :param numpy.ndarray magnitude_table:
            Magnitude-time table specifying the year and magnitudes of
            completeness
        '''
        output_catalogue = deepcopy(catalogue)
        if magnitude_table is not None:
            if flag_vector is not None:
                output_catalogue.catalogue_mt_filter(
                    magnitude_table, flag_vector)
                return output_catalogue
            else:
                output_catalogue.catalogue_mt_filter(
                    magnitude_table)
                return output_catalogue

        if flag_vector is not None:
            output_catalogue.purge_catalogue(flag_vector)
        return output_catalogue
Apply all the various purging conditions, if specified.

        :param catalogue:
            Earthquake catalogue as instance of :class:`openquake.hmtk.seismicity.catalogue.Catalogue`
        :param numpy.array flag_vector:
            Boolean vector specifying whether each event is valid (therefore
            written) or otherwise
        :param numpy.ndarray magnitude_table:
            Magnitude-time table specifying the year and magnitudes of
            completeness