Integrate

class of dascore.transform.integrate
inherits from: PatchProcessor, DascoreBaseModel, pydantic.main.BaseModel
source

Integrate(
    *args ,
    dim: Any ,
    definite: Any = False,
)-> None

Integrate along a specified dimension using composite trapezoidal rule.

Parameters

Parameter Description
patch Patch object for integration.
dim The dimension(s) along which to integrate. If None, integrate along
all dimensions.
definite If True, consider the integration to be defined from the minimum to
the maximum value along specified dimension(s). In essence, this
collapses the integrated dimensions to a length of 1.
If define is False, the shape of the patch is preserved and a
“cumulative” type integration in performed.
Note

The number of dimensions will always remain the same regardless of definite value. To remove dimensions with length 1, use Patch.squeeze.

NaN samples are treated as missing: an interval with a NaN end adds nothing, a cumulative integral carries on past a gap, and NaN samples stay NaN.

Integer and boolean data are converted to float64 before integration. Floating-point and complex data are used without an explicit dtype cast.

The output data_type is mapped through the pairs an integral is known to relate, which are those of differentiate read backwards: along time strain_rate becomes strain and acceleration becomes velocity; along distance strain becomes displacement. An integral the pairs cannot name all the way through clears data_type rather than leaving a stale one on it.

A dimension of more than one segment (from concatenate, or samples removed from its middle) raises; use fill_gaps or split_gaps first. One list of labels, with or without a step, is an irregular axis, integrated by its label spacing.

Examples

import dascore as dc
patch = dc.get_example_patch()
# integrate along time axis, preserve patch shape with indefinite integral
time_integrated = patch.integrate(dim="time", definite=False)
# integrate along distance axis, collapse distance coordinate
dist_integrated = patch.integrate(dim="distance", definite=True)
# integrate along all dimensions.
all_integrated = patch.integrate(dim=None, definite=False)

Methods

Name Description
check Refuse a patch which does not carry what the operation needs.
chunk_contract Return what a chunk of the output needs of the input, or None.
get_metadata Return the integral’s coords, units and data_type, and the spacing.
halo Return how far along an axis the kernel reads to fill a sample.
model_copy Copy the model, dropping cached values the update invalidates.
new Create new instance with some attributed updated.
numpy_kernel Return the integral of the data along the axes.
integrate Integrate along a specified dimension using composite trapezoidal rule.
reconcile Return metadata or a patch holding the final data; default as is.
run Run the operation: check, get_metadata, kernel, reconcile, record.