mod_utils module
Xscale is a python package created by Guillaume Sérazin and available at https://github.com/serazing/xscale.
Xscale is a collection of signal processing and statistical tools initially designed for the analysis of the spatio-temporal scales of geophysical data. It is part of the pangeo-data project and works with xarray and dask objects.
Due to some deprecations of the package, only parts of it are used here in mod_xscale.py and mod_utils.py.
mod_utils.py is where useful internal functions are stored.
- mod_utils.get_dx(obj, dim, unit='s')
Get the coordinate spacing (sampling interval) along a dimension of a DataArray or Dataset.
- Parameters:
obj (DataArray or Dataset) – The input data structure.
dim (str) – The name of the dimension for which to calculate the spacing.
unit (str, optional) – The desired unit for the spacing. Default is ‘s’ (seconds).
- Returns:
The coordinate spacing (sampling interval) along the specified dimension.
- Return type:
float
- mod_utils.homogeneous_type(seq)
Check if all elements in a sequence have the same type.
- Parameters:
seq (iterable) – The sequence to be checked.
- Returns:
The common type of all elements in the sequence if homogeneous, False otherwise.
- Return type:
type or False
- mod_utils.infer_arg(arg, dims, default_value=None)
Infer an argument based on dimensions and default values.
- Parameters:
arg (any) – The input argument.
dims (str or iterable) – The dimensions for which the argument is applied.
default_value (any, optional) – The default value to be used if the argument is not provided.
- Returns:
A dictionary containing the inferred argument values.
- Return type:
dict
- mod_utils.infer_n_and_dims(obj, n, dims)
Infer window properties based on input arguments.
- Parameters:
obj (object) – The input object.
n (int, dict, iterable, or None) – The window size.
dims (str, iterable, or None) – The dimensions for which the window size is applied.
- Returns:
A tuple containing the inferred window size and dimensions.
- Return type:
tuple
- mod_utils.is_datetime(value)
Check if the input value is a datetime.
- Parameters:
value (any) – The value to be checked.
- Returns:
True if the value is a datetime, False otherwise.
- Return type:
bool
- mod_utils.is_dict_like(value)
Check if the input value is dictionary-like.
- Parameters:
value (any) – The value to be checked.
- Returns:
True if the value is dictionary-like, False otherwise.
- Return type:
bool
- mod_utils.is_iterable(value)
Check if the input value is iterable.
- Parameters:
value (any) – The value to be checked.
- Returns:
True if the value is iterable, False otherwise.
- Return type:
bool
- mod_utils.is_scalar(value)
Check if the input value is a scalar.
- Parameters:
value (any) – The value to be checked.
- Returns:
True if the value is a scalar, False otherwise.
- Return type:
bool