xradar.util.map_over_sweeps#

xradar.util.map_over_sweeps(func)[source]#

Decorator to apply a function only to sweep nodes in a DataTree.

This decorator first checks whether the dataset provided to the function has the ‘range’ dimension, indicating it’s a sweep node. If true, the function is applied. Non-sweep nodes are left unchanged.

Parameters:

func (callable()) – A function that operates on an xarray Dataset. The function must accept a Dataset as its first argument and return a modified Dataset.

Returns:

callable() – A function that can be applied to all sweep nodes in a DataTree.

Examples

>>> @map_over_sweeps
>>> def calculate_rain_rate(ds, ref_field='DBZH'):
>>>     # Function logic to calculate rain rate
>>>     return ds