source_modelling.slip

Utilities for slip and slip velocity functions.

  1"""Utilities for slip and slip velocity functions."""
  2
  3import numpy as np
  4import numpy.typing as npt
  5
  6
  7def rise_time_from_moment(moment: npt.ArrayLike) -> npt.NDArray[np.floating]:
  8    """Compute approximate rise time from rupture moment.
  9
 10    Parameters
 11    ----------
 12    moment : array-like
 13        Moment(s) to convert to rise times.
 14
 15    Returns
 16    -------
 17    ndarray
 18        Approximate rise time for rupture subfaults.
 19
 20    References
 21    ----------
 22    Baker, J., Bradley, B., & Stafford, P. (2021). Seismic hazard and risk
 23    analysis (p. 202). Cambridge University Press.
 24    """
 25    return 3.12e-7 * np.cbrt(moment)
 26
 27
 28def box_car_slip(
 29    t: npt.ArrayLike, t0: npt.ArrayLike, t1: npt.ArrayLike, slip: npt.ArrayLike
 30) -> npt.NDArray[np.floating]:
 31    """Boxcar slip velocity function.
 32
 33    Parameters
 34    ----------
 35    t : array-like
 36        Time to compute slip for.
 37    t0 : array-like
 38        Time slip begins.
 39    t1 : array-like
 40        Time slip ends.
 41    slip : array-like
 42        Total slip.
 43
 44    Returns
 45    -------
 46    ndarray
 47        Returns the slip for time t, according to
 48
 49        f(t) = slip / (t1 - t0) if t0 <= t <= t1
 50        f(t) = 0                otherwise
 51    """
 52    t0 = np.asarray(t0)
 53    t1 = np.asarray(t1)
 54    t = np.asarray(t)
 55    slip = np.asarray(slip)
 56    return np.where((t >= t0) & (t <= t1), slip / (t1 - t0), 0)
 57
 58
 59def triangular_slip(
 60    t: npt.ArrayLike,
 61    t0: npt.ArrayLike,
 62    t1: npt.ArrayLike,
 63    peak: npt.ArrayLike,
 64    slip: npt.ArrayLike,
 65) -> npt.NDArray[np.floating]:
 66    """Assymetric triangular slip function.
 67
 68    Parameters
 69    ----------
 70    t : array-like
 71        Time to compute slip for.
 72    t0 : array-like
 73        Time slip begins.
 74    t1 : array-like
 75        Time slip ends.
 76    peak : array-like
 77        Time when slip peaks.
 78    slip : array-like
 79        Total slip.
 80
 81    Returns
 82    -------
 83    ndarray
 84        Returns the slip for time t, according to
 85
 86        f(t) = 2 * slip / (t1 - t0) * (t - t0) / (peak - t0), if t0 <= t <= peak
 87        f(t) = 2 * slip / (t1 - t0) * (1 - (t - peak) / (t1 - peak))
 88        f(t) = 0 otherwise
 89    """
 90    t = np.asarray(t)
 91    t0 = np.asarray(t0)
 92    t1 = np.asarray(t1)
 93    peak = np.asarray(peak)
 94    slip = np.asarray(slip)
 95    return (
 96        np.where(
 97            (t >= t0) & (t <= t1),
 98            np.minimum((t - t0) / (peak - t0), 1 - (t - peak) / (t1 - peak)),
 99            0,
100        )
101        * 2
102        * slip
103        / (t1 - t0)
104    )
105
106
107def isoceles_triangular_slip(
108    t: npt.ArrayLike, t0: npt.ArrayLike, t1: npt.ArrayLike, slip: npt.ArrayLike
109) -> npt.NDArray[np.floating]:
110    """Symmetric triangular slip function.
111
112    Parameters
113    ----------
114    t : array-like
115        Time to compute slip for.
116    t0 : array-like
117        Time slip begins.
118    t1 : array-like
119        Time slip ends.
120    slip : array-like
121        Total slip.
122
123    Returns
124    -------
125    ndarray
126        Returns the slip for time t, according to assymetric triangular slip
127        with peak = (t0 + t1) / 2.
128    """
129    t0 = np.asarray(t0)
130    t1 = np.asarray(t1)
131    return triangular_slip(t, t0, t1, (t0 + t1) / 2, slip)
132
133
134def cosine_slip(
135    t: npt.ArrayLike, t0: npt.ArrayLike, t1: npt.ArrayLike, slip: npt.ArrayLike
136) -> npt.NDArray[np.floating]:
137    """Cosine slip velocity function.
138
139    Parameters
140    ----------
141    t : array-like
142        The time to evaluate the SVF at.
143    t0 : array-like
144        The time for slip to begin.
145    t1 : array-like
146        The time for slip to end.
147    slip : array-like
148        The total slip.
149
150    Returns
151    -------
152    np.ndarray
153        The slip for time t, according to the function
154
155        f(t) = cos(((t - t0) / (t1 - t0) - 1 / 2) * pi)  for t0 <= t <= t1
156        f(t) = 0 otherwise
157    """
158    t0 = np.asarray(t0)
159    t1 = np.asarray(t1)
160    slip = np.asarray(slip)
161    return (np.pi * slip / (2 * (t1 - t0))) * np.where(
162        (t >= t0) & (t <= t1), np.cos((t - t0) / (t1 - t0) * np.pi - np.pi / 2), 0
163    )
def rise_time_from_moment( moment: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) -> numpy.ndarray[typing.Any, numpy.dtype[numpy.floating]]:
 8def rise_time_from_moment(moment: npt.ArrayLike) -> npt.NDArray[np.floating]:
 9    """Compute approximate rise time from rupture moment.
10
11    Parameters
12    ----------
13    moment : array-like
14        Moment(s) to convert to rise times.
15
16    Returns
17    -------
18    ndarray
19        Approximate rise time for rupture subfaults.
20
21    References
22    ----------
23    Baker, J., Bradley, B., & Stafford, P. (2021). Seismic hazard and risk
24    analysis (p. 202). Cambridge University Press.
25    """
26    return 3.12e-7 * np.cbrt(moment)

Compute approximate rise time from rupture moment.

Parameters
  • moment (array-like): Moment(s) to convert to rise times.
Returns
  • ndarray: Approximate rise time for rupture subfaults.
References

Baker, J., Bradley, B., & Stafford, P. (2021). Seismic hazard and risk analysis (p. 202). Cambridge University Press.

def box_car_slip( t: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], t0: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], t1: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], slip: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) -> numpy.ndarray[typing.Any, numpy.dtype[numpy.floating]]:
29def box_car_slip(
30    t: npt.ArrayLike, t0: npt.ArrayLike, t1: npt.ArrayLike, slip: npt.ArrayLike
31) -> npt.NDArray[np.floating]:
32    """Boxcar slip velocity function.
33
34    Parameters
35    ----------
36    t : array-like
37        Time to compute slip for.
38    t0 : array-like
39        Time slip begins.
40    t1 : array-like
41        Time slip ends.
42    slip : array-like
43        Total slip.
44
45    Returns
46    -------
47    ndarray
48        Returns the slip for time t, according to
49
50        f(t) = slip / (t1 - t0) if t0 <= t <= t1
51        f(t) = 0                otherwise
52    """
53    t0 = np.asarray(t0)
54    t1 = np.asarray(t1)
55    t = np.asarray(t)
56    slip = np.asarray(slip)
57    return np.where((t >= t0) & (t <= t1), slip / (t1 - t0), 0)

Boxcar slip velocity function.

Parameters
  • t (array-like): Time to compute slip for.
  • t0 (array-like): Time slip begins.
  • t1 (array-like): Time slip ends.
  • slip (array-like): Total slip.
Returns
  • ndarray: Returns the slip for time t, according to

f(t) = slip / (t1 - t0) if t0 <= t <= t1 f(t) = 0 otherwise

def triangular_slip( t: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], t0: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], t1: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], peak: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], slip: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) -> numpy.ndarray[typing.Any, numpy.dtype[numpy.floating]]:
 60def triangular_slip(
 61    t: npt.ArrayLike,
 62    t0: npt.ArrayLike,
 63    t1: npt.ArrayLike,
 64    peak: npt.ArrayLike,
 65    slip: npt.ArrayLike,
 66) -> npt.NDArray[np.floating]:
 67    """Assymetric triangular slip function.
 68
 69    Parameters
 70    ----------
 71    t : array-like
 72        Time to compute slip for.
 73    t0 : array-like
 74        Time slip begins.
 75    t1 : array-like
 76        Time slip ends.
 77    peak : array-like
 78        Time when slip peaks.
 79    slip : array-like
 80        Total slip.
 81
 82    Returns
 83    -------
 84    ndarray
 85        Returns the slip for time t, according to
 86
 87        f(t) = 2 * slip / (t1 - t0) * (t - t0) / (peak - t0), if t0 <= t <= peak
 88        f(t) = 2 * slip / (t1 - t0) * (1 - (t - peak) / (t1 - peak))
 89        f(t) = 0 otherwise
 90    """
 91    t = np.asarray(t)
 92    t0 = np.asarray(t0)
 93    t1 = np.asarray(t1)
 94    peak = np.asarray(peak)
 95    slip = np.asarray(slip)
 96    return (
 97        np.where(
 98            (t >= t0) & (t <= t1),
 99            np.minimum((t - t0) / (peak - t0), 1 - (t - peak) / (t1 - peak)),
100            0,
101        )
102        * 2
103        * slip
104        / (t1 - t0)
105    )

Assymetric triangular slip function.

Parameters
  • t (array-like): Time to compute slip for.
  • t0 (array-like): Time slip begins.
  • t1 (array-like): Time slip ends.
  • peak (array-like): Time when slip peaks.
  • slip (array-like): Total slip.
Returns
  • ndarray: Returns the slip for time t, according to

f(t) = 2 * slip / (t1 - t0) * (t - t0) / (peak - t0), if t0 <= t <= peak f(t) = 2 * slip / (t1 - t0) * (1 - (t - peak) / (t1 - peak)) f(t) = 0 otherwise

def isoceles_triangular_slip( t: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], t0: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], t1: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], slip: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) -> numpy.ndarray[typing.Any, numpy.dtype[numpy.floating]]:
108def isoceles_triangular_slip(
109    t: npt.ArrayLike, t0: npt.ArrayLike, t1: npt.ArrayLike, slip: npt.ArrayLike
110) -> npt.NDArray[np.floating]:
111    """Symmetric triangular slip function.
112
113    Parameters
114    ----------
115    t : array-like
116        Time to compute slip for.
117    t0 : array-like
118        Time slip begins.
119    t1 : array-like
120        Time slip ends.
121    slip : array-like
122        Total slip.
123
124    Returns
125    -------
126    ndarray
127        Returns the slip for time t, according to assymetric triangular slip
128        with peak = (t0 + t1) / 2.
129    """
130    t0 = np.asarray(t0)
131    t1 = np.asarray(t1)
132    return triangular_slip(t, t0, t1, (t0 + t1) / 2, slip)

Symmetric triangular slip function.

Parameters
  • t (array-like): Time to compute slip for.
  • t0 (array-like): Time slip begins.
  • t1 (array-like): Time slip ends.
  • slip (array-like): Total slip.
Returns
  • ndarray: Returns the slip for time t, according to assymetric triangular slip with peak = (t0 + t1) / 2.
def cosine_slip( t: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], t0: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], t1: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]], slip: Union[Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) -> numpy.ndarray[typing.Any, numpy.dtype[numpy.floating]]:
135def cosine_slip(
136    t: npt.ArrayLike, t0: npt.ArrayLike, t1: npt.ArrayLike, slip: npt.ArrayLike
137) -> npt.NDArray[np.floating]:
138    """Cosine slip velocity function.
139
140    Parameters
141    ----------
142    t : array-like
143        The time to evaluate the SVF at.
144    t0 : array-like
145        The time for slip to begin.
146    t1 : array-like
147        The time for slip to end.
148    slip : array-like
149        The total slip.
150
151    Returns
152    -------
153    np.ndarray
154        The slip for time t, according to the function
155
156        f(t) = cos(((t - t0) / (t1 - t0) - 1 / 2) * pi)  for t0 <= t <= t1
157        f(t) = 0 otherwise
158    """
159    t0 = np.asarray(t0)
160    t1 = np.asarray(t1)
161    slip = np.asarray(slip)
162    return (np.pi * slip / (2 * (t1 - t0))) * np.where(
163        (t >= t0) & (t <= t1), np.cos((t - t0) / (t1 - t0) * np.pi - np.pi / 2), 0
164    )

Cosine slip velocity function.

Parameters
  • t (array-like): The time to evaluate the SVF at.
  • t0 (array-like): The time for slip to begin.
  • t1 (array-like): The time for slip to end.
  • slip (array-like): The total slip.
Returns
  • np.ndarray: The slip for time t, according to the function

f(t) = cos(((t - t0) / (t1 - t0) - 1 / 2) * pi) for t0 <= t <= t1 f(t) = 0 otherwise