Skip to content

pysmo.tools.signal #

envelope(seismogram, Tn, alpha) #

Calculates the envelope of a gaussian filtered seismogram.

Parameters:

Name Type Description Default
seismogram Seismogram

Name of the seismogram object passed to this function.

required
Tn float

Center period of Gaussian filter [in seconds]

required
alpha float

Set alpha (which determines filterwidth)

required

Returns:

Type Description
MiniSeismogram

Seismogram containing the envelope

Examples:

>>> from pysmo import SAC
>>> from pysmo.tools.signal import envelope
>>> seis = SAC.from_file('sacfile.sac').seismogram
>>> Tn = 50 # Center Gaussian filter at 50s period
>>> alpha = 50 # Set alpha (which determines filterwidth) to 50
>>> envelope_seis = envelope(seis, Tn, alpha)
Source code in pysmo/tools/signal.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def envelope(seismogram: Seismogram, Tn: float, alpha: float) -> MiniSeismogram:
    """
    Calculates the envelope of a gaussian filtered seismogram.

    Parameters:
        seismogram: Name of the seismogram object passed to this function.
        Tn: Center period of Gaussian filter [in seconds]
        alpha: Set alpha (which determines filterwidth)

    Returns:
        Seismogram containing the envelope

    Examples:
        >>> from pysmo import SAC
        >>> from pysmo.tools.signal import envelope
        >>> seis = SAC.from_file('sacfile.sac').seismogram
        >>> Tn = 50 # Center Gaussian filter at 50s period
        >>> alpha = 50 # Set alpha (which determines filterwidth) to 50
        >>> envelope_seis = envelope(seis, Tn, alpha)
    """
    clone = MiniSeismogram.clone(seismogram, skip_data=True)
    clone.data = __gauss(seismogram, Tn, alpha)[0]
    return clone

gauss(seismogram, Tn, alpha) #

Returns a gaussian filtered seismogram.

Parameters:

Name Type Description Default
seismogram Seismogram

Name of the SAC object passed to this function.

required
Tn float

Center period of Gaussian filter [in seconds]

required
alpha float

Set alpha (which determines filterwidth)

required

Returns:

Type Description
Seismogram

Gaussian filtered seismogram.

Examples:

>>> from pysmo import SAC
>>> from pysmo.tools.signal import gauss
>>> seis = SAC.from_file('sacfile.sac').seismogram
>>> Tn = 50 # Center Gaussian filter at 50s period
>>> alpha = 50 # Set alpha (which determines filterwidth) to 50
>>> gauss_seis = gauss(seis, Tn, alpha)
Source code in pysmo/tools/signal.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def gauss(seismogram: Seismogram, Tn: float, alpha: float) -> Seismogram:
    """
    Returns a gaussian filtered seismogram.

    Parameters:
        seismogram: Name of the SAC object passed to this function.
        Tn: Center period of Gaussian filter [in seconds]
        alpha: Set alpha (which determines filterwidth)

    Returns:
        Gaussian filtered seismogram.

    Examples:
        >>> from pysmo import SAC
        >>> from pysmo.tools.signal import gauss
        >>> seis = SAC.from_file('sacfile.sac').seismogram
        >>> Tn = 50 # Center Gaussian filter at 50s period
        >>> alpha = 50 # Set alpha (which determines filterwidth) to 50
        >>> gauss_seis = gauss(seis, Tn, alpha)
    """
    clone = MiniSeismogram.clone(seismogram, skip_data=True)
    clone.data = __gauss(seismogram, Tn, alpha)[1]
    return clone