def re_thresh_csv(path, old_thresh, new_thresh, chan_thresh):
from eqcorrscan.core.match_filter import read_detections<EOL>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>old_detections = read_detections(path)<EOL>old_thresh = float(old_thresh)<EOL>new_thresh = float(new_thresh)<EOL>detections = []<EOL>detections_in = <NUM_LIT:0><EOL>detections_out = <NUM_LIT:0><EOL>for detection in old_detections:<EOL><INDENT>detections_in += <NUM_LIT:1><EOL>con1 = (new_thresh / old_thresh) * detection.threshold<EOL>con2 = detection.no_chans >= chan_thresh<EOL>requirted_thresh = (new_thresh / old_thresh) * detection.threshold<EOL>con3 = abs(detection.detect_val) >= requirted_thresh<EOL>if all([con1, con2, con3]):<EOL><INDENT>detections_out += <NUM_LIT:1><EOL>detections.append(detection)<EOL><DEDENT><DEDENT>print('<STR_LIT>' % detections_in)<EOL>print('<STR_LIT>' % detections_out)<EOL>return detections<EOL>
Remove detections by changing the threshold.

Can only be done to remove detection by increasing threshold,
threshold lowering will have no effect.

:type path: str
:param path: Path to the .csv detection file
:type old_thresh: float
:param old_thresh: Old threshold MAD multiplier
:type new_thresh: float
:param new_thresh: New threshold MAD multiplier
:type chan_thresh: int
:param chan_thresh: Minimum number of channels for a detection

:returns: List of detections
:rtype: list

.. rubric:: Example

>>> from eqcorrscan.utils.clustering import re_thresh_csv
>>> # Get the path to the test data
>>> import eqcorrscan
>>> import os
>>> TEST_PATH = os.path.dirname(eqcorrscan.__file__) + '/tests/test_data'
>>> det_file = os.path.join(TEST_PATH, 'expected_tutorial_detections.txt')
>>> detections = re_thresh_csv(path=det_file, old_thresh=8, new_thresh=10,
...                            chan_thresh=3)
Read in 22 detections
Left with 17 detections

.. Note::
    This is a legacy function, and will read detections from all versions.

.. Warning:: Only works if thresholding was done by MAD.