from contextlib import suppress
import dascore as dc
from dascore.exceptions import MissingOptionalDependencyError
patch = dc.get_example_patch("deformation_rate_event_1")
# Example 1
# Estimate the strain rate with a gauge length twice the distance step.
patch_strain = patch.velocity_to_strain_rate(step_multiple=2)
# Example 2
# Estimate the strain rate with a 10th order filter. This will raise
# an exception if the package findiff is not installed.
with suppress(MissingOptionalDependencyError):
patch_strain = patch.velocity_to_strain_rate(order=10)
# Example 3
# Estimate strain rate with a 4th order filter and gauge length 4 times
# the distance step.
with suppress(MissingOptionalDependencyError):
patch_strain = patch.velocity_to_strain_rate(step_multiple=4, order=4)velocity_to_strain_rate
velocity_to_strain_rate(
self ,
step_multiple: int = 2,
order: int = 2,
)-> ‘Self’
Convert velocity DAS data to strain rate using central differences.
When order=2 and step_multiple=2 the derivative for non-edge values is estimated by:
\[ \hat{f}(x) = \frac{f(x + (n/2)dx) - f(x - (n/2)dx)}{n dx} \]
Where \(dx\) is the distance step and \(n\) is the step_multiple. Values for edges are estimate with the appropriate forward/backward stencils so that the shape of the output data match the input data. The equation becomes more complicated for higher order stencils.
Parameters
| Parameter | Description |
|---|---|
| patch |
A patch object containing DAS data. Note: attrs[‘data_type’] should be velocity. |
| step_multiple |
The multiples of spatial sampling for the central averaging stencil. Must be even as odd values result in a staggered grid. |
| order |
The order for the finite difference 1st derivative stencil (accuracy). It must be a multiple of 2 |
Examples
This is primarily used with Terra15 data and simply uses patch.differentiate under the hood to calculate spatial derivatives.
The output gauge length is equal to the step_multiple multiplied by the spacing along the distance coordinate, although the concept of gauge_length is more complex with higher order filters. See Yang, Shragge, and Jin (2022) for more info.
An unevenly sampled distance coordinate is differentiated by its labels and supports only the default step_multiple=2; the output then has no gauge_length, as there is no single step to multiply.
See the strain-rate note for more details on step_multiple and order effects.
The edgeless version of this function removes potential edge effects and supports even and odd step_multiple values.