MCPcopy Index your code
hub / github.com/pydata/xarray / integrate

Method integrate

xarray/core/dataarray.py:5538–5590  ·  view source on GitHub ↗

Integrate along the given coordinate using the trapezoidal rule. .. note:: This feature is limited to simple cartesian geometry, i.e. coord must be one dimensional. Parameters ---------- coord : Hashable, or sequence of Hashable C

(
        self,
        coord: Hashable | Sequence[Hashable] = None,
        datetime_unit: DatetimeUnitOptions = None,
    )

Source from the content-addressed store, hash-verified

5536 return self._from_temp_dataset(ds)
5537
5538 def integrate(
5539 self,
5540 coord: Hashable | Sequence[Hashable] = None,
5541 datetime_unit: DatetimeUnitOptions = None,
5542 ) -> Self:
5543 """Integrate along the given coordinate using the trapezoidal rule.
5544
5545 .. note::
5546 This feature is limited to simple cartesian geometry, i.e. coord
5547 must be one dimensional.
5548
5549 Parameters
5550 ----------
5551 coord : Hashable, or sequence of Hashable
5552 Coordinate(s) used for the integration.
5553 datetime_unit : {'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns', \
5554 'ps', 'fs', 'as', None}, optional
5555 Specify the unit if a datetime coordinate is used.
5556
5557 Returns
5558 -------
5559 integrated : DataArray
5560
5561 See Also
5562 --------
5563 Dataset.integrate
5564 numpy.trapz : corresponding numpy function
5565
5566 Examples
5567 --------
5568
5569 >>> da = xr.DataArray(
5570 ... np.arange(12).reshape(4, 3),
5571 ... dims=["x", "y"],
5572 ... coords={"x": [0, 0.1, 1.1, 1.2]},
5573 ... )
5574 >>> da
5575 <xarray.DataArray (x: 4, y: 3)> Size: 96B
5576 array([[ 0, 1, 2],
5577 [ 3, 4, 5],
5578 [ 6, 7, 8],
5579 [ 9, 10, 11]])
5580 Coordinates:
5581 * x (x) float64 32B 0.0 0.1 1.1 1.2
5582 Dimensions without coordinates: y
5583 >>>
5584 >>> da.integrate("x")
5585 <xarray.DataArray (y: 3)> Size: 24B
5586 array([5.4, 6.6, 7.8])
5587 Dimensions without coordinates: y
5588 """
5589 ds = self._to_temp_dataset().integrate(coord, datetime_unit)
5590 return self._from_temp_dataset(ds)
5591
5592 def cumulative_integrate(
5593 self,

Callers 2

test_integrateFunction · 0.95
test_trapezoid_datetimeFunction · 0.95

Calls 2

_to_temp_datasetMethod · 0.95
_from_temp_datasetMethod · 0.95

Tested by 2

test_integrateFunction · 0.76
test_trapezoid_datetimeFunction · 0.76