Exemple #1
0
def _shift_store(group: zarr.Group, dim: str, n_shift: int):
    """Shift local zarr store which represents an xarray dataset by n_shift along dim
    
    Args:
        group: zarr Group for an xarray dataset backed by a DirectoryStore
        dim: name of dimension of xarray dataset along which to shift zarr
        n_shift: how far to shift. The chunk size along dim of every array in group
            must evenly divide n_shift.

    Note:
        The zarr store represented by group will no longer be valid after this
        function is called since its chunks will not be listed starting at 0. It is
        intended that the output of this function be copied into another zarr store as
        a method of appending.
    """
    for array in group.values():
        if dim in array.attrs[XARRAY_DIM_NAMES_ATTR]:
            axis = array.attrs[XARRAY_DIM_NAMES_ATTR].index(dim)
            _shift_array(array, axis, n_shift)
Exemple #2
0
def _get_dim_size(group: zarr.Group, dim: str):
    """Get length of dim, assuming it is same for all arrays that contain it"""
    for array in group.values():
        if dim in array.attrs[XARRAY_DIM_NAMES_ATTR]:
            axis = array.attrs[XARRAY_DIM_NAMES_ATTR].index(dim)
            return array.shape[axis]