def run_tutorial(min_magnitude=<NUM_LIT:2>, shift_len=<NUM_LIT>, num_cores=<NUM_LIT:4>, min_cc=<NUM_LIT:0.5>):
if num_cores > cpu_count():<EOL><INDENT>num_cores = cpu_count()<EOL><DEDENT>client = Client('<STR_LIT>')<EOL>t1 = UTCDateTime(<NUM_LIT>, <NUM_LIT:9>, <NUM_LIT>)<EOL>t2 = t1 + <NUM_LIT><EOL>print('<STR_LIT>')<EOL>catalog = client.get_events(<EOL>starttime=t1, endtime=t2, minmagnitude=min_magnitude,<EOL>minlatitude=<NUM_LIT>, maxlatitude=<NUM_LIT>, minlongitude=-<NUM_LIT>,<EOL>maxlongitude=-<NUM_LIT>, includearrivals=True)<EOL>catalog = catalog_utils.filter_picks(<EOL>catalog, channels=['<STR_LIT>'], top_n_picks=<NUM_LIT:5>)<EOL>for pick in catalog[<NUM_LIT:3>].picks:<EOL><INDENT>if pick.waveform_id.station_code == '<STR_LIT>' andpick.onset == '<STR_LIT>':<EOL><INDENT>catalog[<NUM_LIT:3>].picks.remove(pick)<EOL><DEDENT><DEDENT>print('<STR_LIT>')<EOL>templates = template_gen.from_client(<EOL>catalog=catalog, client_id='<STR_LIT>', lowcut=<NUM_LIT>, highcut=<NUM_LIT>,<EOL>samp_rate=<NUM_LIT>, filt_order=<NUM_LIT:4>, length=<NUM_LIT>, prepick=<NUM_LIT>,<EOL>swin='<STR_LIT:all>', process_len=<NUM_LIT>)<EOL>start_time = UTCDateTime(<NUM_LIT>, <NUM_LIT:9>, <NUM_LIT>, <NUM_LIT>)<EOL>end_time = UTCDateTime(<NUM_LIT>, <NUM_LIT:9>, <NUM_LIT>, <NUM_LIT:20>)<EOL>process_len = <NUM_LIT><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>all_detections = []<EOL>picked_catalog = Catalog()<EOL>template_names = [str(template[<NUM_LIT:0>].stats.starttime)<EOL>for template in templates]<EOL>for t1, t2 in chunks:<EOL><INDENT>print('<STR_LIT>' % t1)<EOL>bulk_info = [(tr.stats.network, tr.stats.station, '<STR_LIT:*>',<EOL>tr.stats.channel, t1, t2) for tr in templates[<NUM_LIT:0>]]<EOL>st = client.get_waveforms_bulk(bulk_info)<EOL>st.merge(fill_value='<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)<EOL>detections = match_filter.match_filter(<EOL>template_names=template_names, template_list=templates, st=st,<EOL>threshold=<NUM_LIT>, threshold_type='<STR_LIT>', trig_int=<NUM_LIT>, plotvar=False,<EOL>plotdir='<STR_LIT:.>', cores=num_cores)<EOL>unique_detections = []<EOL>for master in detections:<EOL><INDENT>keep = True<EOL>for slave in detections:<EOL><INDENT>if not master == slave andabs(master.detect_time - slave.detect_time) <= <NUM_LIT:1.0>:<EOL><INDENT>if not master.detect_val > slave.detect_val:<EOL><INDENT>keep = False<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if keep:<EOL><INDENT>unique_detections.append(master)<EOL><DEDENT><DEDENT>all_detections += unique_detections<EOL>picked_catalog += lag_calc.lag_calc(<EOL>detections=unique_detections, detect_data=st,<EOL>template_names=template_names, templates=templates,<EOL>shift_len=shift_len, min_cc=min_cc, interpolate=False, plot=False,<EOL>parallel=True, debug=<NUM_LIT:3>)<EOL><DEDENT>return all_detections, picked_catalog, templates, template_names<EOL>
Functional, tested example script for running the lag-calc tutorial.