Exemple #1
0
def get_corner_frequencies(st, method='constant', constant=None, snr=None):
    """
    Select corner frequencies.

    Args:
        st (StationStream):
            Stream of data.
        method (str):
            Which method to use; currently allowed "snr" or "constant".
        constant(dict):
            Dictionary of `constant` method config options.
        snr (dict):
            Dictionary of `snr` method config options.

    Returns:
        strea: Stream with selected corner frequencies added.
    """

    logging.info('Setting corner frequencies...')
    if method == 'constant':
        st = corner_frequencies.constant(st, **constant)
    elif method == 'snr':
        st = corner_frequencies.snr(st, **snr)
    else:
        raise ValueError("Corner frequency 'method' must be either "
                         "'constant' or 'snr'.")
    return st
def get_corner_frequencies(st, method='constant', constant=None, snr=None):
    """
    Select corner frequencies.

    Args:
        st (StationStream):
            Stream of data.
        method (str):
            Which method to use; currently allowed "snr" or "constant".
        constant(dict):
            Dictionary of `constant` method config options.
        snr (dict):
            Dictionary of `snr` method config options.

    Returns:
        strea: Stream with selected corner frequencies added.
    """

    logging.info('Setting corner frequencies...')
    if method == 'constant':
        st = corner_frequencies.constant(st, **constant)
    elif method == 'snr':
        st = corner_frequencies.snr(st, **snr)
    else:
        raise ValueError("Corner frequency 'method' must be either "
                         "'constant' or 'snr'.")
    return st
def get_corner_frequencies(st, method='constant', constant=None, snr=None):
    """
    Select corner frequencies.

    Args:
        st (StationStream):
            Stream of data.
        method (str):
            Which method to use; currently allowed "snr" or "constant".
        constant(dict):
            Dictionary of `constant` method config options.
        snr (dict):
            Dictionary of `snr` method config options.

    Returns:
        strea: Stream with selected corner frequencies added.
    """

    logging.info('Setting corner frequencies...')
    if method == 'constant':
        st = corner_frequencies.constant(st, **constant)
    elif method == 'snr':
        st = corner_frequencies.snr(st, **snr)
        if snr['same_horiz'] and st.passed and st.num_horizontal > 1:
            lps = [
                tr.getParameter('corner_frequencies')['lowpass'] for tr in st
            ]
            hps = [
                tr.getParameter('corner_frequencies')['highpass'] for tr in st
            ]
            chs = [tr.stats.channel for tr in st]
            hlps = []
            hhps = []
            for i in range(len(chs)):
                if "z" not in chs[i].lower():
                    hlps.append(lps[i])
                    hhps.append(hps[i])
            llp = np.min(hlps)
            hhp = np.max(hhps)
            for i in range(len(chs)):
                if "z" not in chs[i].lower():
                    cfdict = st[i].getParameter('corner_frequencies')
                    cfdict['lowpass'] = llp
                    cfdict['highpass'] = hhp
                    st[i].setParameter('corner_frequencies', cfdict)
    else:
        raise ValueError("Corner frequency 'method' must be either "
                         "'constant' or 'snr'.")
    return st