clouddrift.ragged.obs_index_to_row

clouddrift.ragged.obs_index_to_row#

clouddrift.ragged.obs_index_to_row(index: int | list[int] | ndarray | DataArray, rowsize: list[int] | ndarray | DataArray) list[source]#

Obtain a list of row indices from a list of observation indices of a ragged array.

Parameters#

indexint or list or np.ndarray

A integer observation index or a list of observation indices of a ragged array.

rowsizelist or np.ndarray or xr.DataArray

A sequence of row sizes of a ragged array.

Returns#

list

A list of row indices.

Examples#

To obtain the row index of observation 5 within a ragged array of three consecutive rows of sizes 2, 4, and 3: >>> obs_index_to_row(5, [2, 4, 3]) [1]

To obtain the row indices of observations 0, 2, and 4 within a ragged array of three consecutive rows of sizes 2, 4, and 3: >>> obs_index_to_row([0, 2, 4], [2, 4, 3]) [0, 1, 1]