Source code for gmprocess.waveform_processing.adjust_highpass_ridder
"""Module for the ridder_fchp processign step."""importinspectfromesi_core.gmprocess.waveform_processing.auto_fchpimportget_fchpfromgmprocess.waveform_processing.taperimporttaperfromgmprocess.waveform_processing.filteringimporthighpass_filterfromgmprocess.waveform_processing.processing_stepimportprocessing_stepFORDER=5.0
[docs]@processing_stepdefridder_fchp(st,target=0.02,tol=0.001,maxiter=30,maxfc=0.5,config=None):"""Search for highpass corner using Ridder's method. Search such that the criterion that the ratio between the maximum of a third order polynomial fit to the displacement time series and the maximum of the displacement timeseries is a target % within a tolerance. This algorithm searches between a low initial corner frequency a maximum fc. Method developed originally by Scott Brandenberg Args: st (StationStream): Stream of data. target (float): target percentage for ratio between max polynomial value and max displacement. tol (float): tolereance for matching the ratio target maxiter (float): maximum number of allowed iterations in Ridder's method maxfc (float): Maximum allowable value of the highpass corner freq. int_method (string): method used to perform integration between acceleration, velocity, and dispacement. Options are "frequency_domain", "time_domain_zero_init" or "time_domain_zero_mean" config (dict): Configuration dictionary (or None). See get_config(). Returns: StationStream: With the highpass corner adjusted using Ridder's method. """ifnotst.passed:returnsthp_sig=inspect.signature(highpass_filter)frequency_domain=hp_sig.parameters["frequency_domain"].defaulttaper_sig=inspect.signature(taper)taper_width=taper_sig.parameters["width"].defaultiffrequency_domain:filter_code=1else:filter_code=0fortrinst:ifnottr.passed:continueinitial_corners=tr.get_parameter("corner_frequencies")ifinitial_corners["type"]=="reviewed":continueinitial_f_hp=initial_corners["highpass"]new_f_hp=get_fchp(dt=tr.stats.delta,acc=tr.data,target=target,tol=tol,poly_order=FORDER,maxiter=maxiter,tukey_alpha=taper_width,fchp_max=maxfc,filter_type=filter_code,)# Method did not converge if new_f_hp reaches maxfcif(maxfc-new_f_hp)<1e-9:tr.fail("auto_fchp did not find an acceptable f_hp.")continueifnew_f_hp>initial_f_hp:tr.set_parameter("corner_frequencies",{"type":"snr_polyfit","highpass":new_f_hp,"lowpass":initial_corners["lowpass"],},)returnst