earthkit.data.utils.array¶
Functions¶
|
|
|
Flatten the array without copying the data. |
|
Performs an outer indexing of an array |
|
Reshape the array to the required shape. |
|
Return the target shape of the array. |
Module Contents¶
- earthkit.data.utils.array.adjust_array(v, flatten=False, dtype=None)¶
- earthkit.data.utils.array.flatten_array(array)¶
Flatten the array without copying the data.
- Parameters:
array (
array-like) – The array to be flattened.- Returns:
1-D array.
- Return type:
array-like
- earthkit.data.utils.array.outer_indexing(v, indices)¶
Performs an outer indexing of an array
v. The parameterindicesis a tuple of indices. Each index is either an int, a slice of an array of int’s. Each index formindicesrestricts/sub-selects the corresponding dimension of the arrayv, independently (orthogonally) to other indices (hence the name: “outer indexing”).This function mimics the behaviour of
xarray.DataArray(v)[indices].values, and in general it is different from the behaviour of e.g. the numpy indexing, i.e.v[indices](see https://numpy.org/doc/stable/user/basics.indexing.html#advanced-indexing).- Parameters:
v (
array-like) – The array to be reshaped.indices (
tupleofitems,each being an int,a sliceoran array-likeofint's)
- Returns:
Sub-selection of the array
vaccording toindices- Return type:
array-like
- earthkit.data.utils.array.reshape_array(v, shape)¶
Reshape the array to the required shape.
- Parameters:
v (
array-like) – The array to be reshaped.shape (
tuple) – The desired shape of the array.
- Returns:
Reshaped array.
- Return type:
array-like
- earthkit.data.utils.array.target_shape(array, flatten, field_shape)¶
Return the target shape of the array.
- Parameters:
array (
array-like) – The array to be reshaped.flatten (
bool) – If True, return a flat shape.
- Returns:
The target shape of the array.
- Return type:
tuple