def filter_picks(catalog, stations=None, channels=None, networks=None,<EOL>locations=None, top_n_picks=None, evaluation_mode='<STR_LIT:all>'):
<EOL>filtered_catalog = catalog.copy()<EOL>if stations:<EOL><INDENT>for event in filtered_catalog:<EOL><INDENT>if len(event.picks) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>event.picks = [pick for pick in event.picks<EOL>if pick.waveform_id.station_code in stations]<EOL><DEDENT><DEDENT>if channels:<EOL><INDENT>for event in filtered_catalog:<EOL><INDENT>if len(event.picks) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>event.picks = [pick for pick in event.picks<EOL>if pick.waveform_id.channel_code in channels]<EOL><DEDENT><DEDENT>if networks:<EOL><INDENT>for event in filtered_catalog:<EOL><INDENT>if len(event.picks) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>event.picks = [pick for pick in event.picks<EOL>if pick.waveform_id.network_code in networks]<EOL><DEDENT><DEDENT>if locations:<EOL><INDENT>for event in filtered_catalog:<EOL><INDENT>if len(event.picks) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>event.picks = [pick for pick in event.picks<EOL>if pick.waveform_id.location_code in locations]<EOL><DEDENT><DEDENT>if evaluation_mode == '<STR_LIT>':<EOL><INDENT>for event in filtered_catalog:<EOL><INDENT>event.picks = [pick for pick in event.picks<EOL>if pick.evaluation_mode == '<STR_LIT>']<EOL><DEDENT><DEDENT>elif evaluation_mode == '<STR_LIT>':<EOL><INDENT>for event in filtered_catalog:<EOL><INDENT>event.picks = [pick for pick in event.picks<EOL>if pick.evaluation_mode == '<STR_LIT>']<EOL><DEDENT><DEDENT>elif evaluation_mode != '<STR_LIT:all>':<EOL><INDENT>warnings.warn('<STR_LIT>' %<EOL>evaluation_mode)<EOL><DEDENT>if top_n_picks:<EOL><INDENT>all_picks = []<EOL>for event in filtered_catalog:<EOL><INDENT>all_picks += [(pick.waveform_id.station_code,<EOL>pick.waveform_id.channel_code)<EOL>for pick in event.picks]<EOL><DEDENT>counted = Counter(all_picks).most_common()<EOL>all_picks = []<EOL>for i in range(counted[<NUM_LIT:0>][<NUM_LIT:1>]):<EOL><INDENT>highest = [item[<NUM_LIT:0>] for item in counted<EOL>if item[<NUM_LIT:1>] >= counted[<NUM_LIT:0>][<NUM_LIT:1>] - i]<EOL>highest = sorted(highest, key=lambda tup: tup[<NUM_LIT:0>])<EOL>for stachan in highest:<EOL><INDENT>if stachan not in all_picks:<EOL><INDENT>all_picks.append(stachan)<EOL><DEDENT><DEDENT>if len(all_picks) > top_n_picks:<EOL><INDENT>all_picks = all_picks[<NUM_LIT:0>:top_n_picks]<EOL>break<EOL><DEDENT><DEDENT>for event in filtered_catalog:<EOL><INDENT>if len(event.picks) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>event.picks = [pick for pick in event.picks<EOL>if (pick.waveform_id.station_code,<EOL>pick.waveform_id.channel_code) in all_picks]<EOL><DEDENT><DEDENT>tmp_catalog = Catalog()<EOL>for event in filtered_catalog:<EOL><INDENT>if len(event.picks) > <NUM_LIT:0>:<EOL><INDENT>tmp_catalog.append(event)<EOL><DEDENT><DEDENT>return tmp_catalog<EOL>
Filter events in the catalog based on a number of parameters.

:param catalog: Catalog to filter.
:type catalog: obspy.core.event.Catalog
:param stations: List for stations to keep picks from.
:type stations: list
:param channels: List of channels to keep picks from.
:type channels: list
:param networks: List of networks to keep picks from.
:type networks: list
:param locations: List of location codes to use
:type locations: list
:param top_n_picks: Filter only the top N most used station-channel pairs.
:type top_n_picks: int
:param evaluation_mode:
    To select only manual or automatic picks, or use all (default).
:type evaluation_mode: str


:return:
    Filtered Catalog - if events are left with no picks, they are removed
    from the catalog.
:rtype: obspy.core.event.Catalog

.. note::
    Will filter first by station, then by channel, then by network, if
    using top_n_picks, this will be done last, after the other filters
    have been applied.

.. note::
    Doesn't work in place on the catalog, your input catalog will be safe
    unless you overwrite it.

.. note:: Doesn't expand wildcard characters.

.. rubric:: Example

>>> from obspy.clients.fdsn import Client
>>> from eqcorrscan.utils.catalog_utils import filter_picks
>>> from obspy import UTCDateTime
>>> client = Client('NCEDC')
>>> t1 = UTCDateTime(2004, 9, 28)
>>> t2 = t1 + 86400
>>> catalog = client.get_events(starttime=t1, endtime=t2, minmagnitude=3,
...                             minlatitude=35.7, maxlatitude=36.1,
...                             minlongitude=-120.6, maxlongitude=-120.2,
...                             includearrivals=True)
>>> print(len(catalog))
12
>>> filtered_catalog = filter_picks(catalog, stations=['BMS', 'BAP',
...                                                    'PAG', 'PAN',
...                                                    'PBI', 'PKY',
...                                                    'YEG', 'WOF'])
>>> print(len(filtered_catalog))
12
>>> stations = []
>>> for event in filtered_catalog:
...     for pick in event.picks:
...         stations.append(pick.waveform_id.station_code)
>>> print(sorted(list(set(stations))))
['BAP', 'BMS', 'PAG', 'PAN', 'PBI', 'PKY', 'WOF', 'YEG']