spiketools.spatial.utils.convert_2dindices¶
- spiketools.spatial.utils.convert_2dindices(xbins, ybins, bins)[source]¶
Convert a set of 2d bin indices into the equivalent 1d indices.
- Parameters:
- xbins, ybins1d array
Bin assignment indices for the x and y dimension of a 2d binning.
- binslist of [int, int]
- Returns:
- indices1d array
Bin assignment indices for a 1d binning.
Notes
The equivalent 1d indices for a set of 2d indices are those that access the equivalent values once the data array has been flattened into a 1d array.
Examples
Convert 2d bins with shape [3, 2] into the equivalent 1d indices:
>>> xbins, ybins = np.array([2, 0, 1, 0, 1, 2]), np.array([0, 1, 1, 0, 0, 1]) >>> bins = [3, 2] >>> convert_2dindices(xbins, ybins, bins) array([2, 3, 4, 0, 1, 5])