@@ -70,7 +70,7 @@ def rf_inversion_export(input_h5_file, output_folder, network_list="*", station_
7070 min_station_weight = - 1 , apply_amplitude_filter = False , apply_similarity_filter = False ,
7171 min_slope_ratio = - 1 , dereverberate = False , baz_range = (0 , 360 ),
7272 apply_phase_weighting = False , pw_exponent = 1. ,
73- resample_freq = None , trim_window = (- 5.0 , 30.0 ),
73+ fmin = None , fmax = None , resample_freq = None , trim_window = (- 5.0 , 30.0 ),
7474 moveout = True , logger = None ):
7575 """Export receiver function to text format for ingestion into Fortran RF inversion code.
7676
@@ -93,6 +93,8 @@ def rf_inversion_export(input_h5_file, output_folder, network_list="*", station_
9393 :type min_slope_ratio: float
9494 :param dereverberate
9595 type: bool
96+ :param fmin: minimum frequency for bandpass filter
97+ :param fmax: maximum frequency for bandpass filter
9698 :param resample_freq: Sampling rate (Hz) of the output files. The default (None) preserves original sampling rate
9799 :type resample_freq: float, optional
98100 :param trim_window: Time window to export relative to onset, defaults to (-5.0, 30.0). If data needs
@@ -112,8 +114,9 @@ def rf_inversion_export(input_h5_file, output_folder, network_list="*", station_
112114 # 7. Apply back-azimuth filter if specified
113115 # 8. Quality filter to those that meet criteria (Sippl cross-correlation similarity)
114116 # 9. Moveout and stack the RFs
115- # 10. Resample (lanczos) and trim RF
116- # 11. Export one file per station in (time, amplitude format)
117+ # 10 Apply lowpass/highpass/bandpass filter based on fmin and fmax
118+ # 11. Resample (lanczos) and trim RF
119+ # 12. Export one file per station in (time, amplitude format)
117120
118121 TRIM_BUFFER = 10
119122 if (logger is None ): logger = setup_logger ('__func__' )
@@ -307,6 +310,18 @@ def rf_inversion_export(input_h5_file, output_folder, network_list="*", station_
307310 # end if
308311 trace = stack [0 ]
309312
313+ # Apply filter as specified
314+ if (fmin and fmax ):
315+ logger .info ('{}.{}.{}: Applying a bandpass filter..' .format (network_code , sta , loc ))
316+ stack .filter (type = 'bandpass' , freqmin = fmin , freqmax = fmax , corners = 1 , zerophase = True )
317+ elif (fmin ):
318+ logger .info ('{}.{}.{}: Applying a highpass filter..' .format (network_code , sta , loc ))
319+ stack .filter (type = 'highpass' , freq = fmin , corners = 1 , zerophase = True )
320+ elif (fmax ):
321+ logger .info ('{}.{}.{}: Applying a lowpass filter..' .format (network_code , sta , loc ))
322+ stack .filter (type = 'lowpass' , freq = fmax , corners = 1 , zerophase = True )
323+ # end if
324+
310325 if (resample_freq is not None ):
311326 exact_start_time = trace .stats .onset + trim_window [0 ]
312327 stack .interpolate (sampling_rate = resample_freq , method = 'lanczos' , a = 10 , starttime = exact_start_time )
@@ -449,11 +464,17 @@ def _plot(ax, t, d, i, label):
449464@click .option ('--pw-exponent' , type = float , default = 1 , show_default = True ,
450465 help = 'Exponent used in instantaneous phase-weighting of RF amplitudes. This parameter '
451466 'has no effect when --apply-phase-weighting is absent.' )
467+ @click .option ('--fmin' , type = float , default = None , show_default = True ,
468+ help = "Lowest frequency for bandpass filter; default is None."
469+ "If only --fmin in provided, a highpass filter is aplied." )
470+ @click .option ('--fmax' , type = float , default = None , show_default = True ,
471+ help = "Highest frequency for bandpass filter; default is None."
472+ "If only --fmax is provided, a lowpass filter is applied." )
452473@click .option ('--resample-rate' , default = None , type = float , show_default = True ,
453474 help = 'Resampling rate (Hz) for output traces.' )
454475def main (input_file , output_folder , output_plot_file , network_list , station_list , station_weights ,
455476 min_station_weight , apply_amplitude_filter , apply_similarity_filter , min_slope_ratio , baz_range ,
456- dereverberate , apply_phase_weighting , pw_exponent , resample_rate ):
477+ dereverberate , apply_phase_weighting , pw_exponent , fmin , fmax , resample_rate ):
457478 """
458479 INPUT_FILE : Input RFs in H5 format\n
459480 (output of generate_rf.py or rf_quality_filter.py)\n
@@ -474,6 +495,8 @@ def main(input_file, output_folder, output_plot_file, network_list, station_list
474495 dereverberate = dereverberate ,
475496 apply_phase_weighting = apply_phase_weighting ,
476497 pw_exponent = pw_exponent ,
498+ fmin = fmin ,
499+ fmax = fmax ,
477500 resample_freq = resample_rate ,
478501 trim_window = (- 5. , 30. ),
479502 moveout = True ,
0 commit comments