cogpy.utils.xarr
Module: xarr Status: REVIEW Last Updated: 2025-08-26 Author: Arash Shahidi, A.Shahidi@campus.lmu.de
- Summary:
This module provides utility functions for working with xarray objects.
- Functions:
spaced_sample_around_coord: Returns indices spaced around a center coordinate. drop_attrs: Removes attributes from an xarray DataArray except specified ones. save_xarray: Saves an xarray DataArray to disk with attributes in a JSON file. load_xarray: Loads an xarray DataArray from disk and restores attributes. reshape_dimension: Reshapes a dimension of an xarray DataArray into new dimensions. unstack: Unstacks a multi-indexed dimension in an xarray DataArray. coords_from_multitindex: Extracts coordinates from a multi-indexed xarray dimension. axis_dim_from_xarr: Maps between axis numbers and dimension names in xarray. roll_dim: Rolls the dimensions of an xarray DataArray. inject_fs: Decorator to inject the ‘fs’ attribute from xarray DataArray into a function.
Example:
Functions
|
Handle axis and dim arguments for xarray DataArray. |
|
|
|
Return a slice of the time series based on fraction and duration. |
|
Returns a slice of the time series based on fraction and duration. |
|
A much quicker version of unstacking a DataArray than the built-in unstack method. |
|
Rolls the dimensions of an xarray.DataArray by nroll positions. |
|
|
|
Returns indices spaced around a center coordinate. |
|
|
|
Decorator to wrap a function that takes numpy arrays as input and output and applies it to xarray.DataArray objects, retaining the original metadata. |
|
Returns indices spaced around a center coordinate. |