Indexing (rojak.core.indexing)#

Utilities for indexing into and reshaping xarray/dask/pandas coordinate arrays

This module provides standalone helper functions for working with coordinates and indices, namely: building direction-aware value slices (make_value_based_slice()), detecting regular grid spacing (get_regular_grid_spacing()), mapping data values to their nearest coordinate index on regular and irregular grids (nearest_index(), map_values_to_nearest_coordinate_index(), map_values_to_nearest_index_irregular_grid()) and back (map_index_to_coordinate_value()), reordering a list according to a target order (map_order()), combining an array with shifted copies of itself along a dimension (shift_and_combine()), masking values with NaN (apply_nan_mask()), and concatenating arrays along a new dimension (concat_new_dim()).

Functions

apply_nan_mask(target_array, nan_mask[, drop])

Replace values in target_array with NaN wherever nan_mask is True

concat_new_dim(targets, *, dim_name, dim_values)

Concatenate a sequence of arrays along a new dimension

get_regular_grid_spacing(array)

Determines if array has a regular grid spacing

make_value_based_slice(coordinate, ...)

Make a slice from coordinate while accounting for whether values are increasing or decreasing.

map_index_to_coordinate_value(indices, ...)

Retrieve original value based on index

map_order(on, by)

Maps order of on based on the order specified in by.

map_values_to_nearest_coordinate_index(...)

Assuming the coordinate is a regular grid, compute the closest index that the values in the series correspond to.

map_values_to_nearest_index_irregular_grid(...)

Compute the closest index in coordinate that each value in series corresponds to

nearest_index(coordinate, values, *[, ...])

Compute the index of the value in coordinate that is closest to each of values

shift_and_combine(target_array, *[, ...])

Combine each element along shift_dim with the elements offset_start before and offset_end after it

Classes

NearestTieBreakConvention(*values)

Convention for breaking ties when a value is exactly halfway between two coordinate values