Esempio n. 1
0
def n_power_vespa(st, s, baz, n, winlen):
    '''
    Returns the nth root power vespa (i.e. the power in the nth root stack) for a seismic array, for a beam of given slowness and backazimuth.

    Parameters
    ----------
    st : ObsPy Stream object
        Stream of SAC format seismograms for the seismic array, length K = no. of stations in array
    s  : float
        Magnitude of slowness vector, in s / km
    baz : float
        Backazimuth of slowness vector, (i.e. angle from North back to epicentre of event)
    n   : int
        Order of the nth root process
    winlen : int
        Length of Hann window over which to calculate the power.

    Returns
    -------
    power : NumPy array
        The power of the nth root stack at the given slowness and backazimuth, as a time series.
    '''
    amplitude = nth_root_stack(st, s, baz, n)
    power = np.convolve(amplitude**2, np.hanning(winlen), mode='same')
    return power
Esempio n. 2
0
def vespagram_backazimuth(st,
                          s,
                          bazmin,
                          bazmax,
                          bazsteps,
                          winlen,
                          stat='power',
                          n=1):
    '''
    Calculates the vespagram for a seismic array over a given range of backazimuths, for a single scalar slowness, using the statistic specified.

    The chosen statistic is calculated as a function of time (in s) and backazimuth (in deg). This may be:-

    * 'amplitude' - the raw amplitude of the linear or nth root stack at each time and slowness step;
    * 'power' - the power in the linear or nth root beam calculated over a time window (length winlen) around each time step for each slowness;
    * 'F' - the F-statistic of the beam calculated over a time window (length winlen) around each time step for each slowness.

    Parameters
    ----------
    st : ObsPy Stream object
        Stream of SAC format seismograms for the seismic array, length K = no. of stations in array
    s : float
        Magnitude of the slowness vector, in s/km
    bazmin  : float
        Minimum backazimuth, in degrees
    bazmax  : float
        Maximum backazimuth, in degrees
    bazsteps  : int
        Integer number of steps between bazmin and bazmax for which to calculate the vespagram
    winlen : int
        Length of Hann window over which to calculate the power.
    stat : string
        Statistic to use for plotting the vespagram, either 'amplitude', 'power', or 'F'
        
    Returns
    -------
    vespagram_data : NumPy array
        Array of values for the chosen statistic at each backazimuth and time step. Dimensions: bazsteps*len(tr) for traces tr in st.
    '''

    if stat == 'amplitude':
        vespagram_data = np.array([
            nth_root_stack(st, s, baz, n)
            for baz in np.linspace(bazmin, bazmax, bazsteps)
        ])
    elif stat == 'power':
        vespagram_data = np.array([
            n_power_vespa(st, s, baz, n, winlen)
            for baz in np.linspace(bazmin, bazmax, bazsteps)
        ])
    elif stat == 'F':
        vespagram_data = np.array([
            f_vespa(st, s, baz, winlen)
            for baz in np.linspace(bazmin, bazmax, bazsteps)
        ])
    else:
        raise AssertionError(
            "'stat' argument must be one of 'amplitude', 'power' or 'F'")

    return vespagram_data
Esempio n. 3
0
def n_power_vespa(st, s, baz, n, winlen):
    """
    Returns the nth root power vespa (i.e. the power in the nth root stack) for a seismic array, for a beam of given slowness and backazimuth.

    Parameters
    ----------
    st : ObsPy Stream object
        Stream of SAC format seismograms for the seismic array, length K = no. of stations in array
    s  : float
        Magnitude of slowness vector, in s / km
    baz : float
        Backazimuth of slowness vector, (i.e. angle from North back to epicentre of event)
    n   : int
        Order of the nth root process
    winlen : int
        Length of Hann window over which to calculate the power.

    Returns
    -------
    power : NumPy array
        The power of the nth root stack at the given slowness and backazimuth, as a time series.
    """
    amplitude = nth_root_stack(st, s, baz, n)
    power = np.convolve(amplitude ** 2, np.hanning(winlen), mode="same")
    return power
Esempio n. 4
0
def vespagram(st, smin, smax, ssteps, baz, winlen, stat='power', n=1):
    '''
    Calculates the vespagram for a seismic array over a given slowness range, for a single backazimuth, using the statistic specified.

    The chosen statistic is calculated as a function of time (in s) and slowness (in s/km). This may be:-

    * 'amplitude' - the raw amplitude of the linear or nth root stack at each time and slowness step;
    * 'power' - the power in the linear or nth root beam calculated over a time window (length winlen) around each time step for each slowness;
    * 'F' - the F-statistic of the beam calculated over a time window (length winlen) around each time step for each slowness.

    Parameters
    ----------
    st : ObsPy Stream object
        Stream of SAC format seismograms for the seismic array, length K = no. of stations in array
    smin  : float
        Minimum magnitude of slowness vector, in s / km
    smax  : float
        Maximum magnitude of slowness vector, in s / km
    ssteps  : int
        Integer number of steps between smin and smax for which to calculate the vespagram
    baz : float
        Backazimuth of slowness vector, (i.e. angle from North back to epicentre of event)
    winlen : int
        Length of Hann window over which to calculate the power.
    stat : string
        Statistic to use for plotting the vespagram, either 'amplitude', 'power', or 'F'
        
    Returns
    -------
    vespagram_data : NumPy array
        Array of values for the chosen statistic at each slowness and time step. Dimensions: ssteps*len(tr) for traces tr in st.
    '''

    assert stat == 'amplitude' or stat == 'power' or stat == 'F', "'stat' argument must be one of 'amplitude', 'power' or 'F'"

    vespagram_data = np.array([])

    try:
        if stat == 'amplitude':
            vespagram_data = np.array([
                nth_root_stack(st, s, baz, n)
                for s in np.linspace(smin, smax, ssteps)
            ])
        elif stat == 'power':
            vespagram_data = np.array([
                n_power_vespa(st, s, baz, n, winlen)
                for s in np.linspace(smin, smax, ssteps)
            ])
        elif stat == 'F':
            vespagram_data = np.array([
                f_vespa(st, s, baz, winlen)
                for s in np.linspace(smin, smax, ssteps)
            ])
    except AssertionError as err:
        raise err

    return vespagram_data
Esempio n. 5
0
def vespagram(st, smin, smax, ssteps, baz, winlen, stat='power', n=1):
    '''
    Calculates the vespagram for a seismic array over a given slowness range, for a single backazimuth, using the statistic specified.

    The chosen statistic is calculated as a function of time (in s) and slowness (in s/km). This may be:-

    * 'amplitude' - the raw amplitude of the linear or nth root stack at each time and slowness step;
    * 'power' - the power in the linear or nth root beam calculated over a time window (length winlen) around each time step for each slowness;
    * 'F' - the F-statistic of the beam calculated over a time window (length winlen) around each time step for each slowness.

    Parameters
    ----------
    st : ObsPy Stream object
        Stream of SAC format seismograms for the seismic array, length K = no. of stations in array
    smin  : float
        Minimum magnitude of slowness vector, in s / km
    smax  : float
        Maximum magnitude of slowness vector, in s / km
    ssteps  : int
        Integer number of steps between smin and smax for which to calculate the vespagram
    baz : float
        Backazimuth of slowness vector, (i.e. angle from North back to epicentre of event)
    winlen : int
        Length of Hann window over which to calculate the power.
    stat : string
        Statistic to use for plotting the vespagram, either 'amplitude', 'power', or 'F'
        
    Returns
    -------
    vespagram_data : NumPy array
        Array of values for the chosen statistic at each slowness and time step. Dimensions: ssteps*len(tr) for traces tr in st.
    '''
    
    assert stat == 'amplitude' or stat == 'power' or stat == 'F', "'stat' argument must be one of 'amplitude', 'power' or 'F'" 
    
    vespagram_data = np.array([])    
    
    try:
        if stat == 'amplitude':
            vespagram_data = np.array([nth_root_stack(st, s, baz, n) for s in np.linspace(smin, smax, ssteps)])
        elif stat == 'power':
            vespagram_data = np.array([n_power_vespa(st, s, baz, n, winlen) for s in np.linspace(smin, smax, ssteps)])
        elif stat == 'F':
            vespagram_data = np.array([f_vespa(st, s, baz, winlen) for s in np.linspace(smin, smax, ssteps)])
    except AssertionError as err:
        raise err

    return vespagram_data
Esempio n. 6
0
def vespagram_backazimuth(st, s, bazmin, bazmax, bazsteps, winlen, stat='power', n=1):
    '''
    Calculates the vespagram for a seismic array over a given range of backazimuths, for a single scalar slowness, using the statistic specified.

    The chosen statistic is calculated as a function of time (in s) and backazimuth (in deg). This may be:-

    * 'amplitude' - the raw amplitude of the linear or nth root stack at each time and slowness step;
    * 'power' - the power in the linear or nth root beam calculated over a time window (length winlen) around each time step for each slowness;
    * 'F' - the F-statistic of the beam calculated over a time window (length winlen) around each time step for each slowness.

    Parameters
    ----------
    st : ObsPy Stream object
        Stream of SAC format seismograms for the seismic array, length K = no. of stations in array
    s : float
        Magnitude of the slowness vector, in s/km
    bazmin  : float
        Minimum backazimuth, in degrees
    bazmax  : float
        Maximum backazimuth, in degrees
    bazsteps  : int
        Integer number of steps between bazmin and bazmax for which to calculate the vespagram
    winlen : int
        Length of Hann window over which to calculate the power.
    stat : string
        Statistic to use for plotting the vespagram, either 'amplitude', 'power', or 'F'
        
    Returns
    -------
    vespagram_data : NumPy array
        Array of values for the chosen statistic at each backazimuth and time step. Dimensions: bazsteps*len(tr) for traces tr in st.
    '''
    
    if stat == 'amplitude':
        vespagram_data = np.array([nth_root_stack(st, s, baz, n) for baz in np.linspace(bazmin, bazmax, bazsteps)])
    elif stat == 'power':
        vespagram_data = np.array([n_power_vespa(st, s, baz, n, winlen) for baz in np.linspace(bazmin, bazmax, bazsteps)])
    elif stat == 'F':
        vespagram_data = np.array([f_vespa(st, s, baz, winlen) for baz in np.linspace(bazmin, bazmax,bazsteps)])
    else:
        raise AssertionError("'stat' argument must be one of 'amplitude', 'power' or 'F'")
        
    return vespagram_data