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)VelocityToStrainRate
VelocityToStrainRate(
*args ,
step_multiple: Any = 2,
order: Any = 2,
)-> None
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.
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.
Methods
| Name | Description |
|---|---|
| check | Refuse a patch which does not carry what the operation needs. |
| get_metadata | Return strain rate metadata, and the spacing to differentiate by. |
| model_copy | Copy the model, dropping cached values the update invalidates. |
| new | Create new instance with some attributed updated. |
| numpy_kernel | Return the derivative of the data along the axes. |
| velocity_to_strain_rate | Convert velocity DAS data to strain rate using central differences. |
| reconcile | Return metadata or a patch holding the final data; default as is. |
| run | Run the operation: check, get_metadata, kernel, reconcile, record. |