@@ -52,10 +52,11 @@ def __str__(self):
5252
5353def template_gen (method , lowcut , highcut , samp_rate , filt_order ,
5454 length , prepick , swin = "all" , process_len = 86400 ,
55- all_horiz = False , delayed = True , plot = False , plotdir = None ,
56- return_event = False , min_snr = None , parallel = False ,
57- num_cores = False , save_progress = False , skip_short_chans = False ,
58- ** kwargs ):
55+ all_vert = False , all_horiz = False , delayed = True , plot = False ,
56+ plotdir = None , return_event = False , min_snr = None ,
57+ parallel = False , num_cores = False , save_progress = False ,
58+ skip_short_chans = False , vertical_chans = ['Z' ],
59+ horizontal_chans = ['E' , 'N' , '1' , '2' ], ** kwargs ):
5960 """
6061 Generate processed and cut waveforms for use as templates.
6162
@@ -82,6 +83,10 @@ def template_gen(method, lowcut, highcut, samp_rate, filt_order,
8283 :func:`eqcorrscan.core.template_gen.template_gen`
8384 :type process_len: int
8485 :param process_len: Length of data in seconds to download and process.
86+ :type all_vert: bool
87+ :param all_vert:
88+ To use all channels defined in vertical_chans for P-arrivals even if
89+ there is only a pick on one of them. Defaults to False.
8590 :type all_horiz: bool
8691 :param all_horiz:
8792 To use both horizontal channels even if there is only a pick on one of
@@ -119,18 +124,26 @@ def template_gen(method, lowcut, highcut, samp_rate, filt_order,
119124 Whether to ignore channels that have insufficient length data or not.
120125 Useful when the quality of data is not known, e.g. when downloading
121126 old, possibly triggered data from a datacentre
127+ :type vertical_chans: list
128+ :param vertical_chans:
129+ List of channel endings on which P-picks are accepted.
130+ :type horizontal_chans: list
131+ :param horizontal_chans:
132+ List of channel endings for horizontal channels, on which S-picks are
133+ accepted.
122134
123135 :returns: List of :class:`obspy.core.stream.Stream` Templates
124136 :rtype: list
125137
126138 .. note::
127139 By convention templates are generated with P-phases on the
128- vertical channel and S-phases on the horizontal channels, normal
129- seismograph naming conventions are assumed, where Z denotes vertical
130- and N, E, R, T, 1 and 2 denote horizontal channels, either oriented
131- or not. To this end we will **only** use Z channels if they have a
132- P-pick, and will use one or other horizontal channels **only** if
133- there is an S-pick on it.
140+ vertical channel [can be multiple, e.g., Z (vertical) and H
141+ (hydrophone) for an ocean bottom seismometer] and S-phases on the
142+ horizontal channels. By default, normal seismograph naming conventions
143+ are assumed, where Z denotes vertical and N, E, 1 and 2 denote
144+ horizontal channels, either oriented or not. To this end we will
145+ **only** use vertical channels if they have a P-pick, and will use one
146+ or other horizontal channels **only** if there is an S-pick on it.
134147
135148 .. warning::
136149 If there is no phase_hint included in picks, and swin=all, all channels
@@ -388,8 +401,9 @@ def template_gen(method, lowcut, highcut, samp_rate, filt_order,
388401 # Cut and extract the templates
389402 template = _template_gen (
390403 event .picks , st , length , swin , prepick = prepick , plot = plot ,
391- all_horiz = all_horiz , delayed = delayed , min_snr = min_snr ,
392- plotdir = plotdir )
404+ all_vert = all_vert , all_horiz = all_horiz , delayed = delayed ,
405+ min_snr = min_snr , vertical_chans = vertical_chans ,
406+ horizontal_chans = horizontal_chans , plotdir = plotdir )
393407 process_lengths .append (len (st [0 ].data ) / samp_rate )
394408 temp_list .append (template )
395409 catalog_out += event
@@ -582,9 +596,10 @@ def _rms(array):
582596 return np .sqrt (np .mean (np .square (array )))
583597
584598
585- def _template_gen (picks , st , length , swin = 'all' , prepick = 0.05 ,
599+ def _template_gen (picks , st , length , swin = 'all' , prepick = 0.05 , all_vert = False ,
586600 all_horiz = False , delayed = True , plot = False , min_snr = None ,
587- plotdir = None ):
601+ plotdir = None , vertical_chans = ['Z' ],
602+ horizontal_chans = ['E' , 'N' , '1' , '2' ]):
588603 """
589604 Master function to generate a multiplexed template for a single event.
590605
@@ -607,6 +622,10 @@ def _template_gen(picks, st, length, swin='all', prepick=0.05,
607622 :param prepick:
608623 Length in seconds to extract before the pick time default is 0.05
609624 seconds.
625+ :type all_vert: bool
626+ :param all_vert:
627+ To use all channels defined in vertical_chans for P-arrivals even if
628+ there is only a pick on one of them. Defaults to False.
610629 :type all_horiz: bool
611630 :param all_horiz:
612631 To use both horizontal channels even if there is only a pick on one
@@ -630,18 +649,26 @@ def _template_gen(picks, st, length, swin='all', prepick=0.05,
630649 :param plotdir:
631650 The path to save plots to. If `plotdir=None` (default) then the figure
632651 will be shown on screen.
652+ :type vertical_chans: list
653+ :param vertical_chans:
654+ List of channel endings on which P-picks are accepted.
655+ :type horizontal_chans: list
656+ :param horizontal_chans:
657+ List of channel endings for horizontal channels, on which S-picks are
658+ accepted.
633659
634660 :returns: Newly cut template.
635661 :rtype: :class:`obspy.core.stream.Stream`
636662
637663 .. note::
638664 By convention templates are generated with P-phases on the
639- vertical channel and S-phases on the horizontal channels, normal
640- seismograph naming conventions are assumed, where Z denotes vertical
641- and N, E, R, T, 1 and 2 denote horizontal channels, either oriented
642- or not. To this end we will **only** use Z channels if they have a
643- P-pick, and will use one or other horizontal channels **only** if
644- there is an S-pick on it.
665+ vertical channel [can be multiple, e.g., Z (vertical) and H
666+ (hydrophone) for an ocean bottom seismometer] and S-phases on the
667+ horizontal channels. By default, normal seismograph naming conventions
668+ are assumed, where Z denotes vertical and N, E, 1 and 2 denote
669+ horizontal channels, either oriented or not. To this end we will
670+ **only** use vertical channels if they have a P-pick, and will use one
671+ or other horizontal channels **only** if there is an S-pick on it.
645672
646673 .. note::
647674 swin argument: Setting to `P` will return only data for channels
@@ -735,13 +762,18 @@ def _template_gen(picks, st, length, swin='all', prepick=0.05,
735762 continue
736763 starttime .update ({'picks' : s_pick })
737764 elif _swin == 'all' :
738- if all_horiz and tr .stats .channel [- 1 ] in ['1' , '2' , '3' ,
739- 'N' , 'E' ]:
765+ if all_vert and tr .stats .channel [- 1 ] in vertical_chans :
766+ # Get all picks on vertical channels
767+ channel_pick = [
768+ pick for pick in station_picks
769+ if pick .waveform_id .channel_code [- 1 ] in
770+ vertical_chans ]
771+ elif all_horiz and tr .stats .channel [- 1 ] in horizontal_chans :
740772 # Get all picks on horizontal channels
741773 channel_pick = [
742774 pick for pick in station_picks
743775 if pick .waveform_id .channel_code [- 1 ] in
744- [ '1' , '2' , '3' , 'N' , 'E' ] ]
776+ horizontal_chans ]
745777 else :
746778 channel_pick = [
747779 pick for pick in station_picks
@@ -751,16 +783,19 @@ def _template_gen(picks, st, length, swin='all', prepick=0.05,
751783 starttime .update ({'picks' : channel_pick })
752784 elif _swin == 'P' :
753785 p_pick = [pick for pick in station_picks
754- if pick .phase_hint .upper ()[0 ] == 'P' and
755- pick .waveform_id .channel_code == tr .stats .channel ]
786+ if pick .phase_hint .upper ()[0 ] == 'P' ]
787+ if not all_vert :
788+ p_pick = [pick for pick in p_pick
789+ if pick .waveform_id .channel_code ==
790+ tr .stats .channel ]
756791 if len (p_pick ) == 0 :
757792 Logger .debug (
758793 f"No picks with phase_hint P "
759794 f"found for { tr .stats .station } .{ tr .stats .channel } " )
760795 continue
761796 starttime .update ({'picks' : p_pick })
762797 elif _swin == 'S' :
763- if tr .stats .channel [- 1 ] in [ 'Z' , 'U' ] :
798+ if tr .stats .channel [- 1 ] in vertical_chans :
764799 continue
765800 s_pick = [pick for pick in station_picks
766801 if pick .phase_hint .upper ()[0 ] == 'S' ]
0 commit comments