apply_ufunc

method of dascore.core.patch.Patch source

apply_ufunc(
    self ,
    ufunc ,
    *args ,
    **kwargs ,
)-> ‘Patch’

Apply a ufunc with the patch as its first operand.

Parameters

Parameter Description
ufunc The ufunc to apply.
*args The remaining operands, which can contain patches.
**kwargs Keyword arguments which configure the operation, such as dim
for a reduction or accumulation.

Examples

import numpy as np
import dascore as dc
patch = dc.get_example_patch()

# Take the absolute value of the patch.
abs_patch = patch.apply_ufunc(np.abs)

# Multiply the patch by 10.
scaled_patch = patch.apply_ufunc(np.multiply, 10)

See Also

apply_ufunc