function of dascore.proc.detrend source

    required_dims: Tuple[str, …] | Callable | None ,
    required_attrs: Dict[str, Any] | str | Sequence[str] | None ,
    history: Literal[‘full’, ‘method_name’, None] ,

Decorator to mark a function as a patch method.


Parameter Description
required_dims A tuple of dimensions which must be found in the Patch.
required_attrs A dict of attributes which must be found in the Patch and whose values must be equal to those provided.
history Specifies how to track history on Patch. Full - Records function name and str version of input arguments. method_name - Only records method name. Useful if args are long. None - Function call is not recorded in history attribute.


# 1. A patch method which requires dimensions (time, distance)
import dascore as dc
@dc.patch_function(required_dims=('time', 'distance'))
def do_something(patch):
    ...   # raises a PatchCoordsError if patch doesn't have time,
    #  distance

# 2. A patch method which requires an attribute 'data_type' == 'DAS'
import dascore as dc
@dc.patch_function(required_attrs={'data_type': 'DAS'})
def do_another_thing(patch):
    ...  # raise PatchAttributeError if patch doesn't have attribute
    # called "data_type" or its values is not equal to "DAS"

The original function can still be accessed with the .func attribute. This may be useful for avoiding calling the patch_func machinery multiple times from within another patch function.