import dascore as dc
= dc.get_example_patch()
patch # 2nd order stencil for 1st derivative along time dimension
= patch.tran.differentiate(dim='time', order=2)
patch_diff_1 # 1st derivative along all dimensions
= patch.tran.differentiate(dim=None) patch_diff_2
differentiate
differentiate(
patch: Patch ,
dim: str | None[str, None] ,
order = 2,
)-> ‘PatchType’
Calculate first derivative along dimension(s) using centeral diferences.
The shape of the output patch is the same as the input patch. Derivative along edges are calculated with the same order (accuarcy) as centeral points using non-centered stencils.
Parameters
Parameter | Description |
---|---|
patch | The patch to differentiate. |
dim | The dimension(s) along which to differentiate. If None differentiates over all dimensions. |
order | The order of the differentiation operator. Must be a possitive, even integar. |
Note
For order=2 (the default) numpy’s gradient function is used. When order != the optional package findiff must be installed in which case order is interpreted as accuracy (“order” means order of differention in that package).