def run_tutorial(plot=False, process_len=<NUM_LIT>, num_cores=cpu_count()):
<EOL>template_names = glob.glob('<STR_LIT>')<EOL>if len(template_names) == <NUM_LIT:0>:<EOL><INDENT>raise IOError('<STR_LIT>' +<EOL>'<STR_LIT>')<EOL><DEDENT>templates = [read(template_name) for template_name in template_names]<EOL>stations = []<EOL>for template in templates:<EOL><INDENT>for tr in template:<EOL><INDENT>stations.append((tr.stats.station, tr.stats.channel))<EOL><DEDENT><DEDENT>stations = list(set(stations))<EOL>start_time = UTCDateTime(<NUM_LIT>, <NUM_LIT:1>, <NUM_LIT:4>)<EOL>end_time = UTCDateTime(<NUM_LIT>, <NUM_LIT:1>, <NUM_LIT:5>)<EOL>chunks = []<EOL>chunk_start = start_time<EOL>while chunk_start < end_time:<EOL><INDENT>chunk_end = chunk_start + process_len<EOL>if chunk_end > end_time:<EOL><INDENT>chunk_end = end_time<EOL><DEDENT>chunks.append((chunk_start, chunk_end))<EOL>chunk_start += process_len<EOL><DEDENT>unique_detections = []<EOL>client = Client("<STR_LIT>")<EOL>for t1, t2 in chunks:<EOL><INDENT>bulk_info = []<EOL>for station in stations:<EOL><INDENT>bulk_info.append(('<STR_LIT>', station[<NUM_LIT:0>], '<STR_LIT:*>',<EOL>station[<NUM_LIT:1>][<NUM_LIT:0>] + '<STR_LIT:H>' + station[<NUM_LIT:1>][-<NUM_LIT:1>], t1, t2))<EOL><DEDENT>print('<STR_LIT>')<EOL>st = client.get_waveforms_bulk(bulk_info)<EOL>st.merge(fill_value='<STR_LIT>')<EOL>print('<STR_LIT>')<EOL>st = pre_processing.shortproc(<EOL>st, lowcut=<NUM_LIT>, highcut=<NUM_LIT>, filt_order=<NUM_LIT:4>, samp_rate=<NUM_LIT>,<EOL>debug=<NUM_LIT:0>, num_cores=num_cores, starttime=t1, endtime=t2)<EOL>st = Stream(st)<EOL>detections = match_filter.match_filter(<EOL>template_names=template_names, template_list=templates,<EOL>st=st, threshold=<NUM_LIT>, threshold_type='<STR_LIT>', trig_int=<NUM_LIT>,<EOL>plotvar=plot, plotdir='<STR_LIT:.>', cores=num_cores, debug=<NUM_LIT:0>,<EOL>plot_format='<STR_LIT>')<EOL>for master in detections:<EOL><INDENT>keep = True<EOL>for slave in detections:<EOL><INDENT>if not master == slave and abs(master.detect_time -<EOL>slave.detect_time) <= <NUM_LIT:1.0>:<EOL><INDENT>if not master.detect_val > slave.detect_val:<EOL><INDENT>keep = False<EOL>print('<STR_LIT>'<EOL>% (master.detect_time, master.detect_val))<EOL>print('<STR_LIT>'<EOL>% (slave.detect_time, slave.detect_val))<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if keep:<EOL><INDENT>unique_detections.append(master)<EOL>print('<STR_LIT>' + str(master.detect_time) +<EOL>'<STR_LIT>' + master.template_name +<EOL>'<STR_LIT>' +<EOL>str(master.detect_val))<EOL>if plot:<EOL><INDENT>stplot = st.copy()<EOL>template = templates[template_names.index(<EOL>master.template_name)]<EOL>lags = sorted([tr.stats.starttime for tr in template])<EOL>maxlag = lags[-<NUM_LIT:1>] - lags[<NUM_LIT:0>]<EOL>stplot.trim(starttime=master.detect_time - <NUM_LIT:10>,<EOL>endtime=master.detect_time + maxlag + <NUM_LIT:10>)<EOL>plotting.detection_multiplot(<EOL>stplot, template, [master.detect_time.datetime])<EOL><DEDENT><DEDENT><DEDENT><DEDENT>print('<STR_LIT>' + str(len(unique_detections)) + '<STR_LIT>')<EOL>return unique_detections<EOL>
Main function to run the tutorial dataset.